Completed
Push — spip-3.0 ( 484b62...e817f1 )
by cam
34:33
created
ecrire/public/debusquer.php 1 patch
Braces   +108 added lines, -82 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
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('public/decompiler');
16 18
 include_spip('inc/filtres_mini');
@@ -86,17 +88,23 @@  discard block
 block discarded – undo
86 88
 		set_request('var_mode', 'debug');
87 89
 		$GLOBALS['bouton_admin_debug'] = true;
88 90
 		// Permettre a la compil de continuer
89
-		if (is_object($lieu) AND (!isset($lieu->code) OR !$lieu->code))
90
-			$lieu->code = "''";
91
+		if (is_object($lieu) AND (!isset($lieu->code) OR !$lieu->code)) {
92
+					$lieu->code = "''";
93
+		}
91 94
 		// forcer l'appel au debusqueur en cas de boucles infernales
92 95
 		$urgence = (_DEBUG_MAX_SQUELETTE_ERREURS AND count($tableau_des_erreurs)>_DEBUG_MAX_SQUELETTE_ERREURS);
93
-		if (!$urgence) return;
96
+		if (!$urgence) {
97
+		    return;
98
+		}
99
+	}
100
+	if (empty($debug_objets['principal'])) {
101
+			$debug_objets['principal'] = $GLOBALS['fond'];
94 102
 	}
95
-	if (empty($debug_objets['principal']))
96
-		$debug_objets['principal'] = $GLOBALS['fond'];
97 103
 
98 104
 	include_spip('inc/autoriser');
99
-	if (!autoriser('debug')) return;
105
+	if (!autoriser('debug')) {
106
+	    return;
107
+	}
100 108
 	include_spip('inc/headers');
101 109
 	include_spip('inc/filtres');
102 110
 
@@ -122,24 +130,29 @@  discard block
 block discarded – undo
122 130
 		. '<br />'
123 131
 		. debusquer_squelette($fonc, $mode, $self);
124 132
 
125
-	if (!_DIR_RESTREINT OR headers_sent()) return $res;
126
-	if ($tableau_des_erreurs) http_status(503);
133
+	if (!_DIR_RESTREINT OR headers_sent()) {
134
+	    return $res;
135
+	}
136
+	if ($tableau_des_erreurs) {
137
+	    http_status(503);
138
+	}
127 139
 
128 140
 	http_no_cache();
129 141
 	if (isset($_GET['var_profile'])){
130 142
 		$titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', '');
131 143
 		$titre = parametre_url($titre, 'var_mode', '');
132
-	}
133
-	else {
134
-		if (!$fonc) $fonc = $debug_objets['principal'];
144
+	} else {
145
+		if (!$fonc) {
146
+		    $fonc = $debug_objets['principal'];
147
+		}
135 148
 		$titre = !$mode ? $fonc : ($mode . ' ' . $debug_objets['sourcefile'][$fonc]);
136 149
 	}
137 150
 	if ($message===false){
138 151
 		lang_select();
139 152
 		return debusquer_entete($titre, $res);
153
+	} else {
154
+			echo debusquer_entete($titre, $res);
140 155
 	}
141
-	else
142
-		echo debusquer_entete($titre, $res);
143 156
 	exit;
144 157
 }
145 158
 
@@ -169,25 +182,29 @@  discard block
 block discarded – undo
169 182
 	if (!empty($erreurs)){
170 183
 		$n = array(count($erreurs) . ' ' . _T('zbug_erreur_squelette'));
171 184
 		return debusquer_navigation($erreurs, $n);
172
-	}
173
-	elseif (!empty($GLOBALS['tableau_des_temps'])) {
185
+	} elseif (!empty($GLOBALS['tableau_des_temps'])) {
174 186
 		include_spip('public/tracer');
175 187
 		list($temps, $nav) = chrono_requete($GLOBALS['tableau_des_temps']);
176 188
 		return debusquer_navigation($temps, $nav, 'debug-profile');
189
+	} else {
190
+			return '';
191
+	}
177 192
 	}
178
-	else
179
-		return '';
180
-}
181 193
 
182 194
 function debusquer_contexte($env){
183 195
 
184
-	if (is_array($env_tab = @unserialize($env))) $env = $env_tab;
196
+	if (is_array($env_tab = @unserialize($env))) {
197
+	    $env = $env_tab;
198
+	}
185 199
 
186
-	if (!$env) return '';
200
+	if (!$env) {
201
+	    return '';
202
+	}
187 203
 	$res = "";
188 204
 	foreach ($env as $nom => $valeur){
189
-		if (is_array($valeur))
190
-			$valeur = '(' . count($valeur) . ' items) [' . join(',', $valeur) . ']';
205
+		if (is_array($valeur)) {
206
+					$valeur = '(' . count($valeur) . ' items) [' . join(',', $valeur) . ']';
207
+		}
191 208
 		$res .= "\n<tr><td><strong>" . nl2br(entites_html($nom))
192 209
 			. "</strong></td><td>:&nbsp;" . nl2br(entites_html($valeur))
193 210
 			. "</td></tr>\n";
@@ -201,7 +218,9 @@  discard block
 block discarded – undo
201 218
 
202 219
 function debusquer_navigation($tableau, $caption = array(), $id = 'debug-nav'){
203 220
 
204
-	if (_request('exec')=='valider_xml') return '';
221
+	if (_request('exec')=='valider_xml') {
222
+	    return '';
223
+	}
205 224
 	$GLOBALS['bouton_admin_debug'] = true;
206 225
 	$res = '';
207 226
 	$href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug'));
@@ -285,8 +304,7 @@  discard block
 block discarded – undo
285 304
 	// il serait plus prudent certainement d'avoir une fonction d'analyse par moteur
286 305
 	if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)){
287 306
 		$errno = $regs[2];
288
-	}
289
-	elseif (is_numeric($errno) and ($errno==1030 OR $errno<=1026)
307
+	} elseif (is_numeric($errno) and ($errno==1030 OR $errno<=1026)
290 308
 		AND preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs)
291 309
 	) {
292 310
 		$errno = $regs[1];
@@ -325,25 +343,27 @@  discard block
 block discarded – undo
325 343
 	if (is_array($debug_objets['sequence'][$id])){
326 344
 		foreach ($debug_objets['sequence'][$id] as $v){
327 345
 
328
-			if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r))
329
-				$y = substr_count($v[0], "\n");
330
-			else {
331
-				if ($v[1][0]=='#')
332
-					// balise dynamique
346
+			if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) {
347
+							$y = substr_count($v[0], "\n");
348
+			} else {
349
+				if ($v[1][0]=='#') {
350
+									// balise dynamique
333 351
 					$incl = $debug_objets['resultat'][$v[2]];
334
-				else
335
-					// inclusion
352
+				} else {
353
+									// inclusion
336 354
 					$incl = $debug_objets['squelette'][trouve_squelette_inclus($v[0])];
355
+				}
337 356
 				$y = substr_count($incl, "\n")
338 357
 					+substr_count($r[1], "\n")
339 358
 					+substr_count($r[3], "\n");
340 359
 			}
341 360
 			if ($n<=($y+$debut)){
342
-				if ($v[1][0]=='?')
343
-					return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1));
344
-				elseif ($v[1][0]=='!') {
345
-					if ($incl = trouve_squelette_inclus($v[1]))
346
-						return trouve_boucle_debug($n, $incl, $debut);
361
+				if ($v[1][0]=='?') {
362
+									return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1));
363
+				} elseif ($v[1][0]=='!') {
364
+					if ($incl = trouve_squelette_inclus($v[1])) {
365
+											return trouve_boucle_debug($n, $incl, $debut);
366
+					}
347 367
 				}
348 368
 				return array($nom, $boucle, $v[2]-1+$n-$debut);
349 369
 			}
@@ -359,16 +379,19 @@  discard block
 block discarded – undo
359 379
 	preg_match('/include\(.(.*).php3?.\);/', $script, $reg);
360 380
 	// si le script X.php n'est pas ecrire/public.php
361 381
 	// on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux)
362
-	if ($reg[1]=='ecrire/public')
363
-		// si c'est bien ecrire/public on cherche le param 'fond'
382
+	if ($reg[1]=='ecrire/public') {
383
+			// si c'est bien ecrire/public on cherche le param 'fond'
364 384
 		if (!preg_match("/'fond' => '([^']*)'/", $script, $reg))
365 385
 			// a defaut on cherche le param 'page'
366 386
 			if (!preg_match("/'param' => '([^']*)'/", $script, $reg))
367 387
 				$reg[1] = "inconnu";
388
+	}
368 389
 	$incl = ',' . $reg[1] . '[.]\w$,';
369 390
 
370 391
 	foreach ($debug_objets['sourcefile'] as $k => $v){
371
-		if (preg_match($incl, $v)) return $k;
392
+		if (preg_match($incl, $v)) {
393
+		    return $k;
394
+		}
372 395
 	}
373 396
 	return "";
374 397
 }
@@ -377,13 +400,13 @@  discard block
 block discarded – undo
377 400
 function reference_boucle_debug($n, $nom, $self){
378 401
 	list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom);
379 402
 
380
-	if (!$boucle)
381
-		return !$ligne ? "" :
403
+	if (!$boucle) {
404
+			return !$ligne ? "" :
382 405
 			(" (" .
383 406
 				(($nom!=$skel) ? _T('squelette_inclus_ligne') :
384 407
 					_T('squelette_ligne')) .
385 408
 				" <a href='$self&amp;var_mode_objet=$skel&amp;var_mode_affiche=squelette&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)");
386
-	else {
409
+	} else {
387 410
 		$self .= "&amp;var_mode_objet=$skel$boucle&amp;var_mode_affiche=boucle";
388 411
 
389 412
 		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" :
@@ -397,7 +420,9 @@  discard block
 block discarded – undo
397 420
 function ancre_texte($texte, $fautifs = array(), $nocpt = false){
398 421
 
399 422
 	$var_mode_ligne = _request('var_mode_ligne');
400
-	if ($var_mode_ligne) $fautifs[] = array($var_mode_ligne);
423
+	if ($var_mode_ligne) {
424
+	    $fautifs[] = array($var_mode_ligne);
425
+	}
401 426
 	$res = '';
402 427
 
403 428
 	$s = highlight_string($texte, true);
@@ -420,11 +445,14 @@  discard block
 block discarded – undo
420 445
 	$i = 1;
421 446
 	$flignes = array();
422 447
 	$loc = array(0, 0);
423
-	foreach ($fautifs as $lc)
424
-		if (is_array($lc)){
448
+	foreach ($fautifs as $lc) {
449
+			if (is_array($lc)){
425 450
 			$l = array_shift($lc);
451
+	}
426 452
 			$flignes[$l] = $lc;
427
-		} else $flignes[$lc] = $loc;
453
+		} else {
454
+		    $flignes[$lc] = $loc;
455
+		}
428 456
 
429 457
 	$ancre = md5($texte);
430 458
 	foreach ($tableau as $ligne){
@@ -467,39 +495,38 @@  discard block
 block discarded – undo
467 495
 			$res = "<div id='spip-boucles'>\n"
468 496
 				. debusquer_navigation_squelettes($self)
469 497
 				. "</div>";
498
+		} else {
499
+					$res = '';
470 500
 		}
471
-		else
472
-			$res = '';
473 501
 		if ($fonc){
474 502
 			$id = " id='$fonc'";
475 503
 			if (!empty($GLOBALS['debug_objets'][$mode][$fonc])){
476 504
 				list($legend, $texte, $res2) = debusquer_source($fonc, $mode);
477 505
 				$texte .= $res2;
478
-			}
479
-			elseif (!empty($debug_objets[$mode][$fonc . 'tout'])) {
506
+			} elseif (!empty($debug_objets[$mode][$fonc . 'tout'])) {
480 507
 				$legend = _T('zbug_' . $mode);
481 508
 				$texte = $debug_objets[$mode][$fonc . 'tout'];
482 509
 				$texte = ancre_texte($texte, array('', ''));
483 510
 			}
484
-		}
485
-		else
486
-			return strlen(trim($res))
511
+		} else {
512
+					return strlen(trim($res))
487 513
 			? "<img src='".chemin_image('compat-16.png')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"
488 514
 			// cas de l'appel sur erreur: montre la page
489 515
 			: $GLOBALS['debug_objets']['resultat']['tout'];
490
-	}
491
-	else {
516
+		}
517
+	} else {
492 518
 		$valider = charger_fonction('valider', 'xml');
493 519
 		$val = $valider($debug_objets['validation'][$fonc . 'tout']);
494 520
 		// Si erreur, signaler leur nombre dans le formulaire admin
495 521
 		$debug_objets['validation'] = $val->err ? count($val->err) : '';
496 522
 		list($texte, $err) = emboite_texte($val, $fonc, $self);
497
-		if ($err===false)
498
-			$err = _T('impossible');
499
-		elseif ($err===true)
500
-			$err = _T('correcte');
501
-		else
502
-			$err = ": $err";
523
+		if ($err===false) {
524
+					$err = _T('impossible');
525
+		} elseif ($err===true) {
526
+					$err = _T('correcte');
527
+		} else {
528
+					$err = ": $err";
529
+		}
503 530
 		$legend = _T('validation') . ' ' . $err;
504 531
 		$res = $id = '';
505 532
 	}
@@ -520,10 +547,12 @@  discard block
 block discarded – undo
520 547
 	$errs = $res->err;
521 548
 	$texte = $res->entete . ($errs ? '' : $res->page);
522 549
 
523
-	if (!$texte and !$errs)
524
-		return array(ancre_texte('', array('', '')), false);
525
-	if (!$errs)
526
-		return array(ancre_texte($texte, array('', '')), true);
550
+	if (!$texte and !$errs) {
551
+			return array(ancre_texte('', array('', '')), false);
552
+	}
553
+	if (!$errs) {
554
+			return array(ancre_texte($texte, array('', '')), true);
555
+	}
527 556
 
528 557
 	if (!isset($GLOBALS['debug_objets'])){
529 558
 
@@ -550,9 +579,9 @@  discard block
 block discarded – undo
550 579
 			$i++;
551 580
 			list($msg, $ligne, $col) = $r;
552 581
 			#spip_log("$r = list($msg, $ligne, $col");
553
-			if (isset($encore2[$msg]))
554
-				$ref = ++$encore2[$msg];
555
-			else {
582
+			if (isset($encore2[$msg])) {
583
+							$ref = ++$encore2[$msg];
584
+			} else {
556 585
 				$encore2[$msg] = $ref = 1;
557 586
 			}
558 587
 			$err .= "<tr  style='background-color: "
@@ -578,8 +607,7 @@  discard block
 block discarded – undo
578 607
 			. $err
579 608
 			. " </table><a id='fin_err'></a>";
580 609
 		return array(ancre_texte($texte, $fautifs), $err);
581
-	}
582
-	else {
610
+	} else {
583 611
 		list($msg, $fermant, $ouvrant) = $errs[0];
584 612
 		$rf = reference_boucle_debug($fermant, $fonc, $self);
585 613
 		$ro = reference_boucle_debug($ouvrant, $fonc, $self);
@@ -594,10 +622,11 @@  discard block
 block discarded – undo
594 622
 function count_occ($regs){
595 623
 	$encore = array();
596 624
 	foreach ($regs as $r){
597
-		if (isset($encore[$r[0]]))
598
-			$encore[$r[0]]++;
599
-		else
600
-			$encore[$r[0]] = 1;
625
+		if (isset($encore[$r[0]])) {
626
+					$encore[$r[0]]++;
627
+		} else {
628
+					$encore[$r[0]] = 1;
629
+		}
601 630
 	}
602 631
 	return $encore;
603 632
 }
@@ -725,18 +754,15 @@  discard block
 block discarded – undo
725 754
 			}
726 755
 		}
727 756
 
728
-	}
729
-	elseif ($affiche=='code'){
757
+	} elseif ($affiche=='code'){
730 758
 		$legend = $nom;
731 759
 		$res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">");
732
-	}
733
-	elseif ($affiche=='boucle'){
760
+	} elseif ($affiche=='boucle'){
734 761
 		$legend = _T('zbug_boucle') . ' ' . $nom;
735 762
 		// Le compilateur prefixe le nom des boucles par l'extension du fichier source.
736 763
 		$gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : '';
737 764
 		$res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle'));
738
-	}
739
-	elseif ($affiche=='squelette'){
765
+	} elseif ($affiche=='squelette'){
740 766
 		$legend = $GLOBALS['debug_objets']['sourcefile'][$objet];
741 767
 		$res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]);
742 768
 	}
Please login to merge, or discard this patch.
ecrire/public/aiguiller.php 1 patch
Braces   +38 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
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 securiser_redirect_action($redirect) {
16 18
 	if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect)))
@@ -18,11 +20,13 @@  discard block
 block discarded – undo
18 20
 		// si l'url est une url du site, on la laisse passer sans rien faire
19 21
 		// c'est encore le plus simple
20 22
 		$base = $GLOBALS['meta']['adresse_site']."/";
21
-		if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0)
22
-			return $redirect;
23
+		if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) {
24
+					return $redirect;
25
+		}
23 26
 		$base = url_de_base();
24
-		if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0)
25
-			return $redirect;
27
+		if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) {
28
+					return $redirect;
29
+		}
26 30
 		return "";
27 31
 	}
28 32
 	return $redirect;
@@ -51,16 +55,16 @@  discard block
 block discarded – undo
51 55
 			$url = parametre_url($url,'var_ajax',$v,'&');
52 56
 			$url = parametre_url($url,'var_ajax_env',$args,'&');
53 57
 			set_request('redirect',$url);
54
-		}
55
-		else if(_request('redirect')){
58
+		} else if(_request('redirect')){
56 59
 			set_request('redirect',securiser_redirect_action(_request('redirect')));
57 60
 		}
58 61
 		$var_f = charger_fonction($action, 'action');
59 62
 		$var_f();
60 63
 		if (!isset($GLOBALS['redirect'])) {
61 64
 			$GLOBALS['redirect'] = _request('redirect');
62
-			if ($_SERVER['REQUEST_METHOD'] == 'POST')
63
-				$GLOBALS['redirect'] = urldecode($GLOBALS['redirect']);
65
+			if ($_SERVER['REQUEST_METHOD'] == 'POST') {
66
+							$GLOBALS['redirect'] = urldecode($GLOBALS['redirect']);
67
+			}
64 68
 			$GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']);
65 69
 		}
66 70
 		if ($url = $GLOBALS['redirect']) {
@@ -79,8 +83,10 @@  discard block
 block discarded – undo
79 83
 			redirige_par_entete($url);
80 84
 		}
81 85
 		if (!headers_sent()
82
-			AND !ob_get_length())
83
-				http_status(204); // No Content
86
+			AND !ob_get_length()) {
87
+						http_status(204);
88
+		}
89
+		// No Content
84 90
 		return true;
85 91
 	}
86 92
 	return false;
@@ -124,8 +130,7 @@  discard block
 block discarded – undo
124 130
 				$ancre = str_replace(array('<','"',"'"),array('&lt;','&quot;',''),$ancre);
125 131
 				$texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>".$texte;
126 132
 			}
127
-		}
128
-		else {
133
+		} else {
129 134
 			include_spip('inc/headers');
130 135
 			http_status(403);
131 136
 			$texte = _L('signature ajax bloc incorrecte');
@@ -145,13 +150,19 @@  discard block
 block discarded – undo
145 150
 	static $post = array();
146 151
 	static $done = false;
147 152
 
148
-	if ($get) return $post; 
149
-	if ($done) return false;
153
+	if ($get) {
154
+	    return $post;
155
+	}
156
+	if ($done) {
157
+	    return false;
158
+	}
150 159
 	$done = true;
151 160
 
152 161
 	if (!($form = _request('formulaire_action')
153
-	AND $args = _request('formulaire_action_args')))
154
-		return false; // le hit peut continuer normalement
162
+	AND $args = _request('formulaire_action_args'))) {
163
+			return false;
164
+	}
165
+	// le hit peut continuer normalement
155 166
 
156 167
 	include_spip('inc/filtres');
157 168
 	if (($args = decoder_contexte_ajax($args,$form))===false) {
@@ -185,8 +196,9 @@  discard block
 block discarded – undo
185 196
 		$retour = "";
186 197
 		if ((count($post["erreurs_$form"])==0)){
187 198
 			$rev = "";
188
-			if ($traiter = charger_fonction("traiter","formulaires/$form/",true))
189
-				$rev = call_user_func_array($traiter,$args);
199
+			if ($traiter = charger_fonction("traiter","formulaires/$form/",true)) {
200
+							$rev = call_user_func_array($traiter,$args);
201
+			}
190 202
 
191 203
 			$rev = pipeline(
192 204
 				  'formulaire_traiter',
@@ -219,13 +231,14 @@  discard block
 block discarded – undo
219 231
 				if (isset($rev['message_erreur'])) {
220 232
 					$post["erreurs_$form"]["message_erreur"] = $rev['message_erreur'];
221 233
 					
222
-				}
223
-				else {
234
+				} else {
224 235
 					// sinon faire ce qu'il faut :
225
-					if (isset($rev['message_ok']))
226
-						$post["message_ok_$form"] = $rev['message_ok'];
227
-					if (isset($rev['editable']))
228
-						$post["editable_$form"] = $rev['editable'];
236
+					if (isset($rev['message_ok'])) {
237
+											$post["message_ok_$form"] = $rev['message_ok'];
238
+					}
239
+					if (isset($rev['editable'])) {
240
+											$post["editable_$form"] = $rev['editable'];
241
+					}
229 242
 					// si une redirection est demandee, appeler redirigae_formulaire qui choisira
230 243
 					// le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue)
231 244
 					if (isset($rev['redirect']) AND $rev['redirect']){
Please login to merge, or discard this patch.
ecrire/public/sandbox.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,7 +11,9 @@  discard block
 block discarded – undo
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
  * Composer le code d'execution d'un texte
@@ -58,14 +60,15 @@  discard block
 block discarded – undo
58 60
 		$refs = $refl->getParameters();
59 61
 		if (isset($refs[0]) AND $refs[0]->name == 'Pile') {
60 62
 			$code = "$f(\$Pile,$code$arglist)";
61
-		}
62
-		else {
63
+		} else {
63 64
 			$code = "$f($code$arglist)";
64 65
 		}
65 66
 	}
66 67
 	// le filtre n'existe pas,
67 68
 	// on le notifie
68
-	else erreur_squelette(array('zbug_erreur_filtre', array('filtre'=>  texte_script($fonc))), $p);
69
+	else {
70
+	    erreur_squelette(array('zbug_erreur_filtre', array('filtre'=>  texte_script($fonc))), $p);
71
+	}
69 72
 
70 73
 	return $code;
71 74
 }
@@ -92,9 +95,11 @@  discard block
 block discarded – undo
92 95
 function sandbox_composer_inclure_php($fichier, &$p, $_contexte){
93 96
 	$compil = texte_script(memoriser_contexte_compil($p));
94 97
 	// si inexistant, on essaiera a l'execution
95
-	if ($path = find_in_path($fichier))
96
-		$path = "\"$path\"";
97
-	else $path = "find_in_path(\"$fichier\")";
98
+	if ($path = find_in_path($fichier)) {
99
+			$path = "\"$path\"";
100
+	} else {
101
+	    $path = "find_in_path(\"$fichier\")";
102
+	}
98 103
 
99 104
 	return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil, $_contexte);
100 105
 }
@@ -110,9 +115,9 @@  discard block
 block discarded – undo
110 115
 	// Securite
111 116
 	if ($p->interdire_scripts
112 117
 	AND $p->etoile != '**') {
113
-		if (!preg_match("/^sinon[(](.*),'([^']*)'[)]$/", $code, $r))
114
-			$code = "interdire_scripts($code)";
115
-		else {
118
+		if (!preg_match("/^sinon[(](.*),'([^']*)'[)]$/", $code, $r)) {
119
+					$code = "interdire_scripts($code)";
120
+		} else {
116 121
 			$code = interdire_scripts($r[2]);
117 122
 			$code = "sinon(interdire_scripts($r[1]),'$code')";
118 123
 		}
@@ -138,17 +143,19 @@  discard block
 block discarded – undo
138 143
 	array_shift($series_filtres);// corps
139 144
 
140 145
 	// proteger les <INCLUDE> et tous les morceaux de php licites
141
-	if ($skel['process_ins'] == 'php')
142
-		$corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS','echapper_php_callback', $corps);
146
+	if ($skel['process_ins'] == 'php') {
147
+			$corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS','echapper_php_callback', $corps);
148
+	}
143 149
 
144 150
 	// recuperer les couples de remplacement
145 151
 	$replace = echapper_php_callback();
146 152
 
147 153
 	foreach($series_filtres as $filtres){
148
-		if (count($filtres))
149
-			foreach ($filtres as $filtre) {
154
+		if (count($filtres)) {
155
+					foreach ($filtres as $filtre) {
150 156
 				if ($filtre AND $f = chercher_filtre($filtre))
151 157
 					$corps = $f($corps);
158
+		}
152 159
 			}
153 160
 	}
154 161
 
Please login to merge, or discard this patch.
ecrire/public/boucles.php 1 patch
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  discard block
 block discarded – undo
15 15
 // Ce fichier definit les boucles standard de SPIP
16 16
 //
17 17
 
18
-if (!defined('_ECRIRE_INC_VERSION')) return;
18
+if (!defined('_ECRIRE_INC_VERSION')) {
19
+    return;
20
+}
19 21
 
20 22
 //
21 23
 // Boucle standard, sans condition rajoutee
@@ -60,10 +62,11 @@  discard block
 block discarded – undo
60 62
 	$boucle->where[]= array("'IN'", "'$id_table'", '"($hierarchie)"');
61 63
 
62 64
 	$order = "FIELD($id_table, \$hierarchie)";
63
-	if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC")
64
-		$boucle->default_order[] = "\"$order\"";
65
-	else
66
-		$boucle->default_order[0] = "\"$order DESC\"";
65
+	if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC") {
66
+			$boucle->default_order[] = "\"$order\"";
67
+	} else {
68
+			$boucle->default_order[0] = "\"$order DESC\"";
69
+	}
67 70
 	return calculer_boucle($id_boucle, $boucles); 
68 71
 }
69 72
 
Please login to merge, or discard this patch.
ecrire/public/criteres.php 1 patch
Braces   +313 added lines, -200 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Compilateur\Criteres
17 17
 **/
18 18
 
19
-if (!defined('_ECRIRE_INC_VERSION')) return;
19
+if (!defined('_ECRIRE_INC_VERSION')) {
20
+    return;
21
+}
20 22
 
21 23
 /**
22 24
  * Une Regexp repérant une chaine produite par le compilateur,
@@ -78,8 +80,9 @@  discard block
 block discarded – undo
78 80
 	$boucle = &$boucles[$idb];
79 81
 	$id = $boucle->primary;
80 82
 
81
-	if ($not OR !$id)
82
-		return (array('zbug_critere_inconnu', array('critere' => $not.$crit->op)));
83
+	if ($not OR !$id) {
84
+			return (array('zbug_critere_inconnu', array('critere' => $not.$crit->op)));
85
+	}
83 86
 	$arg = kwote(calculer_argument_precedent($idb, $id, $boucles));
84 87
 	$boucle->where[] = array("'!='", "'$boucle->id_table."."$id'", $arg);
85 88
 }
@@ -195,8 +198,12 @@  discard block
 block discarded – undo
195 198
  *     AST complété de la gestion du critère
196 199
 **/
197 200
 function critere_lang_select_dist($idb, &$boucles, $crit){
198
-	if (!isset($crit->param[1][0]) OR !($param = $crit->param[1][0]->texte)) $param = 'oui';
199
-	if ($crit->not) $param = ($param=='oui') ? 'non' : 'oui';
201
+	if (!isset($crit->param[1][0]) OR !($param = $crit->param[1][0]->texte)) {
202
+	    $param = 'oui';
203
+	}
204
+	if ($crit->not) {
205
+	    $param = ($param=='oui') ? 'non' : 'oui';
206
+	}
200 207
 	$boucle = &$boucles[$idb];
201 208
 	$boucle->lang_select = $param;
202 209
 }
@@ -214,8 +221,10 @@  discard block
 block discarded – undo
214 221
 		                        '"]) . ",'.
215 222
 		                        $deux.
216 223
 		                        '"';
217
-	} else calculer_critere_DEFAUT_dist($idb, $boucles, $crit);
218
-}
224
+	} else {
225
+	    calculer_critere_DEFAUT_dist($idb, $boucles, $crit);
226
+	}
227
+	}
219 228
 
220 229
 // {pagination}
221 230
 // {pagination 20}
@@ -263,9 +272,10 @@  discard block
 block discarded – undo
263 272
 	if ($boucle->primary
264 273
 	    AND !preg_match('/[,\s]/', $boucle->primary)
265 274
 	        AND !in_array($t, $boucle->select)
266
-	)
267
-		$boucle->select[] = $t;
268
-}
275
+	) {
276
+			$boucle->select[] = $t;
277
+	}
278
+	}
269 279
 
270 280
 
271 281
 // {recherche} ou {recherche susan}
@@ -280,10 +290,11 @@  discard block
 block discarded – undo
280 290
 		return;
281 291
 	}
282 292
 
283
-	if (isset($crit->param[0]))
284
-		$quoi = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent);
285
-	else
286
-		$quoi = '(isset($Pile[0]["recherche"])?$Pile[0]["recherche"]:(isset($GLOBALS["recherche"])?$GLOBALS["recherche"]:""))';
293
+	if (isset($crit->param[0])) {
294
+			$quoi = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent);
295
+	} else {
296
+			$quoi = '(isset($Pile[0]["recherche"])?$Pile[0]["recherche"]:(isset($GLOBALS["recherche"])?$GLOBALS["recherche"]:""))';
297
+	}
287 298
 
288 299
 	$_modificateur = var_export($boucle->modificateur, true);
289 300
 	$boucle->hash .= '
@@ -300,8 +311,10 @@  discard block
 block discarded – undo
300 311
 
301 312
 
302 313
 	$t = $boucle->id_table.'.'.$boucle->primary;
303
-	if (!in_array($t, $boucles[$idb]->select))
304
-		$boucle->select[] = $t; # pour postgres, neuneu ici
314
+	if (!in_array($t, $boucles[$idb]->select)) {
315
+			$boucle->select[] = $t;
316
+	}
317
+	# pour postgres, neuneu ici
305 318
 	// jointure uniquement sur le serveur principal
306 319
 	// (on ne peut joindre une table d'un serveur distant avec la table des resultats du serveur principal)
307 320
 	if (!$boucle->sql_serveur){
@@ -417,8 +430,9 @@  discard block
 block discarded – undo
417 430
 			$champ = array_shift($decompose);
418 431
 			$boucle->where[] = array("'='", _q($cle.".".reset($decompose)), '"'.sql_quote(end($decompose)).'"');
419 432
 		}
433
+	} else {
434
+	    $cle = $boucle->id_table;
420 435
 	}
421
-	else $cle = $boucle->id_table;
422 436
 
423 437
 	$c = "sql_in('$cle".".$champ', calcul_branche_in($arg)"
424 438
 	     .($not ? ", 'NOT'" : '').")";
@@ -437,13 +451,16 @@  discard block
 block discarded – undo
437 451
 	     $boucle->id_table.'.'.$boucle->primary
438 452
 	     ."', lister_objets_avec_logos('".$boucle->primary."'), '')";
439 453
 
440
-	if ($crit->cond) $c = "($arg ? $c : 1)";
454
+	if ($crit->cond) {
455
+	    $c = "($arg ? $c : 1)";
456
+	}
441 457
 
442
-	if ($not)
443
-		$boucle->where[] = array("'NOT'", $c);
444
-	else
445
-		$boucle->where[] = $c;
446
-}
458
+	if ($not) {
459
+			$boucle->where[] = array("'NOT'", $c);
460
+	} else {
461
+			$boucle->where[] = $c;
462
+	}
463
+	}
447 464
 
448 465
 // c'est la commande SQL "GROUP BY"
449 466
 // par exemple <boucle(articles){fusion lang}>
@@ -456,7 +473,9 @@  discard block
 block discarded – undo
456 473
 			if (preg_match("/^(.*)\.(.*)$/", $t, $r)){
457 474
 				$t = table_objet_sql($r[1]);
458 475
 				$t = array_search($t, $boucles[$idb]->from);
459
-				if ($t) $t .= '.'.$r[2];
476
+				if ($t) {
477
+				    $t .= '.'.$r[2];
478
+				}
460 479
 			}
461 480
 		} else {
462 481
 			$t = '".'
@@ -466,11 +485,13 @@  discard block
 block discarded – undo
466 485
 	}
467 486
 	if ($t){
468 487
 		$boucles[$idb]->group[] = $t;
469
-		if (!in_array($t, $boucles[$idb]->select))
470
-			$boucles[$idb]->select[] = $t;
471
-	} else
472
-		return (array('zbug_critere_inconnu', array('critere' => $crit->op.' ?')));
473
-}
488
+		if (!in_array($t, $boucles[$idb]->select)) {
489
+					$boucles[$idb]->select[] = $t;
490
+		}
491
+	} else {
492
+			return (array('zbug_critere_inconnu', array('critere' => $crit->op.' ?')));
493
+	}
494
+	}
474 495
 
475 496
 // c'est la commande SQL "COLLATE"
476 497
 // qui peut etre appliquee sur les order by, group by, where like ...
@@ -481,11 +502,13 @@  discard block
 block discarded – undo
481 502
 		$boucle = $boucles[$idb];
482 503
 		$boucle->modificateur['collate'] = "($_coll ?' COLLATE '.$_coll:'')";
483 504
 		$n = count($boucle->order);
484
-		if ($n && (strpos($boucle->order[$n-1], 'COLLATE')===false))
485
-			$boucle->order[$n-1] .= " . ".$boucle->modificateur['collate'];
486
-	} else
487
-		return (array('zbug_critere_inconnu', array('critere' => $crit->op." ".count($boucles[$idb]->order))));
488
-}
505
+		if ($n && (strpos($boucle->order[$n-1], 'COLLATE')===false)) {
506
+					$boucle->order[$n-1] .= " . ".$boucle->modificateur['collate'];
507
+		}
508
+	} else {
509
+			return (array('zbug_critere_inconnu', array('critere' => $crit->op." ".count($boucles[$idb]->order))));
510
+	}
511
+	}
489 512
 
490 513
 // http://doc.spip.org/@calculer_critere_arg_dynamique
491 514
 function calculer_critere_arg_dynamique($idb, &$boucles, $crit, $suffix = ''){
@@ -498,7 +521,9 @@  discard block
 block discarded – undo
498 521
 		$desc = implode(',', array_map('_q', array_keys($desc)));
499 522
 		$boucles[$idb]->in .= "\n\tstatic $var = array(".$desc.");";
500 523
 	}
501
-	if ($desc) $alt = "(in_array(\$x, $var)  ? $alt :(\$x$suffix))";
524
+	if ($desc) {
525
+	    $alt = "(in_array(\$x, $var)  ? $alt :(\$x$suffix))";
526
+	}
502 527
 	$arg = calculer_liste($crit, array(), $boucles, $boucle->id_parent);
503 528
 	return "((\$x = preg_replace(\"/\\W/\",'', $arg)) ? $alt : '')";
504 529
 }
@@ -514,7 +539,9 @@  discard block
 block discarded – undo
514 539
 function critere_parinverse($idb, &$boucles, $crit, $sens = ''){
515 540
 	global $exceptions_des_jointures;
516 541
 	$boucle = &$boucles[$idb];
517
-	if ($crit->not) $sens = $sens ? "" : " . ' DESC'";
542
+	if ($crit->not) {
543
+	    $sens = $sens ? "" : " . ' DESC'";
544
+	}
518 545
 	$collecte = (isset($boucle->modificateur['collecte'])) ? " . ".$boucle->modificateur['collecte'] : "";
519 546
 
520 547
 	foreach ($crit->param as $tri){
@@ -528,8 +555,9 @@  discard block
 block discarded – undo
528 555
 			// pour supporter 'hasard' comme tri dynamique
529 556
 			$par = "rand()";
530 557
 			$parha = $par." AS hasard";
531
-			if (!in_array($parha, $boucle->select))
532
-				$boucle->select[] = $parha;
558
+			if (!in_array($parha, $boucle->select)) {
559
+							$boucle->select[] = $parha;
560
+			}
533 561
 		} else {
534 562
 			$par = array_shift($tri);
535 563
 			$par = $par->texte;
@@ -566,8 +594,9 @@  discard block
 block discarded – undo
566 594
 				if ($cle) { $cle .= '.'; }
567 595
 				$texte = '0+'. $cle . $champ;
568 596
 				$suite = calculer_liste($tri, array(), $boucles, $boucle->id_parent);
569
-				if ($suite!=="''")
570
-					$texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')"." . \"";
597
+				if ($suite!=="''") {
598
+									$texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')"." . \"";
599
+				}
571 600
 				$as = 'num'.($boucle->order ? count($boucle->order) : "");
572 601
 				$boucle->select[] = $texte." AS $as";
573 602
 				$order = "'$as'";
@@ -589,10 +618,10 @@  discard block
 block discarded – undo
589 618
 					else if (isset($exceptions_des_jointures[$par])){
590 619
 						list($table, $champ) = $exceptions_des_jointures[$par];
591 620
 						$order = critere_par_joint($table, $champ, $boucle, $idb);
592
-						if (!$order)
593
-							return (array('zbug_critere_inconnu', array('critere' => $crit->op." $par")));
594
-					}
595
-					else if ($par=='date'
621
+						if (!$order) {
622
+													return (array('zbug_critere_inconnu', array('critere' => $crit->op." $par")));
623
+						}
624
+					} else if ($par=='date'
596 625
 					         AND $desc = $boucle->show
597 626
 					             AND $desc['date']
598 627
 					){
@@ -608,11 +637,14 @@  discard block
 block discarded – undo
608 637
 						}
609 638
 						if (!$t){
610 639
 							return (array('zbug_critere_inconnu', array('critere' => $crit->op." $par")));
611
-						} else	 $order = "'".$t.'.'.$r[2]."'";
640
+						} else {
641
+						    $order = "'".$t.'.'.$r[2]."'";
642
+						}
612 643
 					} else {
613 644
 						$desc = $boucle->show;
614
-						if ($desc['field'][$par])
615
-							$par = $boucle->id_table.".".$par;
645
+						if ($desc['field'][$par]) {
646
+													$par = $boucle->id_table.".".$par;
647
+						}
616 648
 						// sinon tant pis, ca doit etre un champ synthetise (cf points)
617 649
 						$order = "'$par'";
618 650
 					}
@@ -624,16 +656,21 @@  discard block
 block discarded – undo
624 656
 			if (strpos($t, '.') AND !in_array($t, $boucle->select)){
625 657
 				$boucle->select[] = $t;
626 658
 			}
627
-		} else $sens = '';
659
+		} else {
660
+		    $sens = '';
661
+		}
628 662
 
629 663
 		if ($fct){
630
-			if (preg_match("/^\s*'(.*)'\s*$/", $order, $r))
631
-				$order = "'$fct(".$r[1].")'";
632
-			else $order = "'$fct(' . $order . ')'";
664
+			if (preg_match("/^\s*'(.*)'\s*$/", $order, $r)) {
665
+							$order = "'$fct(".$r[1].")'";
666
+			} else {
667
+			    $order = "'$fct(' . $order . ')'";
668
+			}
633 669
 		}
634 670
 		$t = $order.$collecte.$sens;
635
-		if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r))
636
-			$t = $r[1].$r[2];
671
+		if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) {
672
+					$t = $r[1].$r[2];
673
+		}
637 674
 		$boucle->order[] = $t;
638 675
 	}
639 676
 }
@@ -641,7 +678,9 @@  discard block
 block discarded – undo
641 678
 // http://doc.spip.org/@critere_par_joint
642 679
 function critere_par_joint($table, $champ, &$boucle, $idb){
643 680
 	$t = array_search($table, $boucle->from);
644
-	if (!$t) $t = trouver_jointure_champ($champ, $boucle);
681
+	if (!$t) {
682
+	    $t = trouver_jointure_champ($champ, $boucle);
683
+	}
645 684
 	return !$t ? '' : ("'".$t.'.'.$champ."'");
646 685
 }
647 686
 
@@ -653,9 +692,9 @@  discard block
 block discarded – undo
653 692
 
654 693
 	$boucle = &$boucles[$idb];
655 694
 	// Classement par ordre inverse
656
-	if ($crit->not)
657
-		critere_parinverse($idb, $boucles, $crit);
658
-	else
695
+	if ($crit->not) {
696
+			critere_parinverse($idb, $boucles, $crit);
697
+	} else
659 698
 	{
660 699
 		$order = "' DESC'";
661 700
 		// Classement par ordre inverse fonction eventuelle de #ENV{...}
@@ -666,14 +705,16 @@  discard block
 block discarded – undo
666 705
 
667 706
 		$n = count($boucle->order);
668 707
 		if (!$n){
669
-			if (isset($boucle->default_order[0]))
670
-				$boucle->default_order[0] .= ' . " DESC"';
671
-			else
672
-				$boucle->default_order[] = ' DESC';
708
+			if (isset($boucle->default_order[0])) {
709
+							$boucle->default_order[0] .= ' . " DESC"';
710
+			} else {
711
+							$boucle->default_order[] = ' DESC';
712
+			}
673 713
 		} else {
674 714
 			$t = $boucle->order[$n-1]." . $order";
675
-			if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r))
676
-				$t = $r[1].$r[2];
715
+			if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r)) {
716
+							$t = $r[1].$r[2];
717
+			}
677 718
 			$boucle->order[$n-1] = $t;
678 719
 		}
679 720
 	}
@@ -683,8 +724,9 @@  discard block
 block discarded – undo
683 724
 function critere_agenda_dist($idb, &$boucles, $crit){
684 725
 	$params = $crit->param;
685 726
 
686
-	if (count($params)<1)
687
-		return (array('zbug_critere_inconnu', array('critere' => $crit->op." ?")));
727
+	if (count($params)<1) {
728
+			return (array('zbug_critere_inconnu', array('critere' => $crit->op." ?")));
729
+	}
688 730
 
689 731
 	$parent = $boucles[$idb]->id_parent;
690 732
 
@@ -731,26 +773,27 @@  discard block
 block discarded – undo
731 773
 	$date = $boucle->id_table.".$date";
732 774
 
733 775
 	$quote_end = ",'".$boucle->sql_serveur."','text'";
734
-	if ($type=='jour')
735
-		$boucle->where[] = array("'='", "'DATE_FORMAT($date, \'%Y%m%d\')'",
776
+	if ($type=='jour') {
777
+			$boucle->where[] = array("'='", "'DATE_FORMAT($date, \'%Y%m%d\')'",
736 778
 		                         ("sql_quote($annee . $mois . $jour$quote_end)"));
737
-	elseif ($type=='mois')
738
-		$boucle->where[] = array("'='", "'DATE_FORMAT($date, \'%Y%m\')'",
779
+	} elseif ($type=='mois') {
780
+			$boucle->where[] = array("'='", "'DATE_FORMAT($date, \'%Y%m\')'",
739 781
 		                         ("sql_quote($annee . $mois$quote_end)"));
740
-	elseif ($type=='semaine')
741
-		$boucle->where[] = array("'AND'",
782
+	} elseif ($type=='semaine') {
783
+			$boucle->where[] = array("'AND'",
742 784
 		                         array("'>='",
743 785
 		                               "'DATE_FORMAT($date, \'%Y%m%d\')'",
744 786
 		                               ("date_debut_semaine($annee, $mois, $jour)")),
745 787
 		                         array("'<='",
746 788
 		                               "'DATE_FORMAT($date, \'%Y%m%d\')'",
747 789
 		                               ("date_fin_semaine($annee, $mois, $jour)")));
748
-	elseif (count($crit->param)>2)
749
-		$boucle->where[] = array("'AND'",
790
+	} elseif (count($crit->param)>2) {
791
+			$boucle->where[] = array("'AND'",
750 792
 		                         array("'>='",
751 793
 		                               "'DATE_FORMAT($date, \'%Y%m%d\')'",
752 794
 		                               ("sql_quote($annee . $mois . $jour$quote_end)")),
753 795
 		                         array("'<='", "'DATE_FORMAT($date, \'%Y%m%d\')'", ("sql_quote($annee2 . $mois2 . $jour2$quote_end)")));
796
+	}
754 797
 	// sinon on prend tout
755 798
 }
756 799
 
@@ -766,8 +809,7 @@  discard block
 block discarded – undo
766 809
 
767 810
 	if (($op==',') && (is_numeric($a11) && (is_numeric($a21)))){
768 811
 		$boucle->limit = $a11.','.$a21;
769
-	}
770
-	else {
812
+	} else {
771 813
 		$boucle->total_parties = ($a21!='n') ? $a21 : $a22;
772 814
 		$partie = ($a11!='n') ? $a11 : $a12;
773 815
 		$mode = (($op=='/') ? '/' :
@@ -778,9 +820,9 @@  discard block
 block discarded – undo
778 820
 				(is_numeric($a11)?"'$a11'":$a11)
779 821
 				.".','."
780 822
 				.(is_numeric($a21)?"'$a21'":$a21);
823
+		} else {
824
+					calculer_parties($boucles, $idb, $partie, $mode);
781 825
 		}
782
-		else
783
-			calculer_parties($boucles, $idb, $partie, $mode);
784 826
 	}
785 827
 }
786 828
 
@@ -803,7 +845,9 @@  discard block
 block discarded – undo
803 845
 		$debut = !$pmoins1 ? 0 : "ceil(($nombre_boucle * $pmoins1)/$totpos);";
804 846
 	} else {
805 847
 		// cas {n-1,x}
806
-		if ($op1=='-') $debut = "$nombre_boucle - $debut;";
848
+		if ($op1=='-') {
849
+		    $debut = "$nombre_boucle - $debut;";
850
+		}
807 851
 
808 852
 		// cas {x,n-1}
809 853
 		if ($op2=='-'){
@@ -853,12 +897,14 @@  discard block
 block discarded – undo
853 897
 	} else {
854 898
 		preg_match(',^ *(([0-9]+)|n) *(- *([0-9]+)? *)?$,', $param[0]->texte, $m);
855 899
 		$a1 = $m[1];
856
-		if (!@$m[3])
857
-			return array($a1, 0);
858
-		elseif ($m[4])
859
-			return array($a1, $m[4]);
860
-		else return array($a1,
900
+		if (!@$m[3]) {
901
+					return array($a1, 0);
902
+		} elseif ($m[4]) {
903
+					return array($a1, $m[4]);
904
+		} else {
905
+		    return array($a1,
861 906
 		                  calculer_liste(array($param[1]), array(), $boucles[$idb]->id_parent, $boucles));
907
+		}
862 908
 	}
863 909
 }
864 910
 
@@ -893,7 +939,9 @@  discard block
 block discarded – undo
893 939
 
894 940
 	$defaut = charger_fonction('DEFAUT', 'calculer_critere');
895 941
 	// s'il y avait une erreur de syntaxe, propager cette info
896
-	if (!is_array($boucle->criteres)) return array();
942
+	if (!is_array($boucle->criteres)) {
943
+	    return array();
944
+	}
897 945
 
898 946
 	foreach ($boucle->criteres as $crit){
899 947
 		$critere = $crit->op;
@@ -938,11 +986,12 @@  discard block
 block discarded – undo
938 986
  * @return string
939 987
  */
940 988
 function kwote($lisp, $serveur='', $type=''){
941
-	if (preg_match(_CODE_QUOTE, $lisp, $r))
942
-		return $r[1]."\"".sql_quote(str_replace(array("\\'", "\\\\"), array("'", "\\"), $r[2]),$serveur,$type)."\"";
943
-	else
944
-		return "sql_quote($lisp)";
945
-}
989
+	if (preg_match(_CODE_QUOTE, $lisp, $r)) {
990
+			return $r[1]."\"".sql_quote(str_replace(array("\\'", "\\\\"), array("'", "\\"), $r[2]),$serveur,$type)."\"";
991
+	} else {
992
+			return "sql_quote($lisp)";
993
+	}
994
+	}
946 995
 
947 996
 // Si on a une liste de valeurs dans #ENV{x}, utiliser la double etoile
948 997
 // pour faire par exemple {id_article IN #ENV**{liste_articles}}
@@ -961,21 +1010,26 @@  discard block
 block discarded – undo
961 1010
 	if ($crit->cond){
962 1011
 		$pred = calculer_argument_precedent($idb, $col, $boucles);
963 1012
 		$where = array("'?'", $pred, $where, "''");
964
-		if ($where_complement) // condition annexe du type "AND (objet='article')"
1013
+		if ($where_complement) {
1014
+		    // condition annexe du type "AND (objet='article')"
965 1015
 			$where_complement = array("'?'", $pred, $where_complement, "''");
1016
+		}
966 1017
 	}
967
-	if ($crit->exclus)
968
-		if (!preg_match(",^L[0-9]+[.],", $arg))
1018
+	if ($crit->exclus) {
1019
+			if (!preg_match(",^L[0-9]+[.],", $arg))
969 1020
 			$where = array("'NOT'", $where);
970
-		else
971
-			// un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete
1021
+	} else {
1022
+					// un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete
972 1023
 			// c'est une sous requete identique a la requete principale sous la forme (SELF,$select,$where) avec $select et $where qui surchargent
973 1024
 			$where = array("'NOT'", array("'IN'", "'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'", array("'SELF'", "'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'", $where)));
1025
+		}
974 1026
 
975 1027
 	$boucles[$idb]->where[] = $where;
976
-	if ($where_complement) // condition annexe du type "AND (objet='article')"
1028
+	if ($where_complement) {
1029
+	    // condition annexe du type "AND (objet='article')"
977 1030
 		$boucles[$idb]->where[] = $where_complement;
978
-}
1031
+	}
1032
+	}
979 1033
 
980 1034
 // http://doc.spip.org/@critere_IN_cas
981 1035
 function critere_IN_cas($idb, &$boucles, $crit2, $arg, $op, $val, $col){
@@ -988,10 +1042,11 @@  discard block
 block discarded – undo
988 1042
 	foreach ($val as $k => $v){
989 1043
 		if (preg_match(",^(\n//.*\n)?'(.*)'$,", $v, $r)){
990 1044
 			// optimiser le traitement des constantes
991
-			if (is_numeric($r[2]))
992
-				$x .= "\n\t$var"."[]= $r[2];";
993
-			else
994
-				$x .= "\n\t$var"."[]= ".sql_quote($r[2]).";";
1045
+			if (is_numeric($r[2])) {
1046
+							$x .= "\n\t$var"."[]= $r[2];";
1047
+			} else {
1048
+							$x .= "\n\t$var"."[]= ".sql_quote($r[2]).";";
1049
+			}
995 1050
 		} else {
996 1051
 			// Pour permettre de passer des tableaux de valeurs
997 1052
 			// on repere l'utilisation brute de #ENV**{X},
@@ -1024,16 +1079,19 @@  discard block
 block discarded – undo
1024 1079
  */
1025 1080
 function critere_where_dist($idb, &$boucles, $crit){
1026 1081
 	$boucle = &$boucles[$idb];
1027
-	if (isset($crit->param[0]))
1028
-		$_where = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent);
1029
-	else
1030
-		$_where = '@$Pile[0]["where"]';
1082
+	if (isset($crit->param[0])) {
1083
+			$_where = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent);
1084
+	} else {
1085
+			$_where = '@$Pile[0]["where"]';
1086
+	}
1031 1087
 
1032
-	if ($crit->cond)
1033
-		$_where = "(($_where) ? ($_where) : '')";
1088
+	if ($crit->cond) {
1089
+			$_where = "(($_where) ? ($_where) : '')";
1090
+	}
1034 1091
 
1035
-	if ($crit->not)
1036
-		$_where = "array('NOT',$_where)";
1092
+	if ($crit->not) {
1093
+			$_where = "array('NOT',$_where)";
1094
+	}
1037 1095
 
1038 1096
 	$boucle->where[] = $_where;
1039 1097
 }
@@ -1122,8 +1180,9 @@  discard block
 block discarded – undo
1122 1180
 // http://doc.spip.org/@calculer_critere_DEFAUT
1123 1181
 function calculer_critere_DEFAUT_dist($idb, &$boucles, $crit){
1124 1182
 	// double cas particulier {0,1} et {1/2} repere a l'analyse lexicale
1125
-	if (($crit->op==",") OR ($crit->op=='/'))
1126
-		return calculer_critere_parties($idb, $boucles, $crit);
1183
+	if (($crit->op==",") OR ($crit->op=='/')) {
1184
+			return calculer_critere_parties($idb, $boucles, $crit);
1185
+	}
1127 1186
 
1128 1187
 	$r = calculer_critere_infixe($idb, $boucles, $crit);
1129 1188
 	if (!$r){
@@ -1131,8 +1190,10 @@  discard block
 block discarded – undo
1131 1190
 	#	if (!$crit->cond) {
1132 1191
 			return (array('zbug_critere_inconnu', array('critere' => $crit->op)));
1133 1192
 	#	}
1134
-	} else calculer_critere_DEFAUT_args($idb, $boucles, $crit, $r);
1135
-}
1193
+	} else {
1194
+	    calculer_critere_DEFAUT_args($idb, $boucles, $crit, $r);
1195
+	}
1196
+	}
1136 1197
 
1137 1198
 function calculer_critere_DEFAUT_args($idb, &$boucles, $crit, $args){
1138 1199
 	list($arg, $op, $val, $col, $where_complement) = $args;
@@ -1141,14 +1202,17 @@  discard block
 block discarded – undo
1141 1202
 
1142 1203
 	// inserer la negation (cf !...)
1143 1204
 
1144
-	if ($crit->not) $where = array("'NOT'", $where);
1145
-	if ($crit->exclus)
1146
-		if (!preg_match(",^L[0-9]+[.],", $arg))
1205
+	if ($crit->not) {
1206
+	    $where = array("'NOT'", $where);
1207
+	}
1208
+	if ($crit->exclus) {
1209
+			if (!preg_match(",^L[0-9]+[.],", $arg))
1147 1210
 			$where = array("'NOT'", $where);
1148
-		else
1149
-			// un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete
1211
+	} else {
1212
+					// un not sur un critere de jointure se traduit comme un NOT IN avec une sous requete
1150 1213
 			// c'est une sous requete identique a la requete principale sous la forme (SELF,$select,$where) avec $select et $where qui surchargent
1151 1214
 			$where = array("'NOT'", array("'IN'", "'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'", array("'SELF'", "'".$boucles[$idb]->id_table.".".$boucles[$idb]->primary."'", $where)));
1215
+		}
1152 1216
 
1153 1217
 	// inserer la condition (cf {lang?})
1154 1218
 	// traiter a part la date, elle est mise d'office par SPIP,
@@ -1160,19 +1224,24 @@  discard block
 block discarded – undo
1160 1224
 			}
1161 1225
 		}
1162 1226
 
1163
-		if ($op=='=' AND !$crit->not)
1164
-			$where = array("'?'", "(is_array($pred))",
1227
+		if ($op=='=' AND !$crit->not) {
1228
+					$where = array("'?'", "(is_array($pred))",
1165 1229
 			               critere_IN_cas($idb, $boucles, 'COND', $arg, $op, array($pred), $col),
1166 1230
 			               $where);
1231
+		}
1167 1232
 		$where = array("'?'", "!(is_array($pred)?count($pred):strlen($pred))", "''", $where);
1168
-		if ($where_complement) // condition annexe du type "AND (objet='article')"
1233
+		if ($where_complement) {
1234
+		    // condition annexe du type "AND (objet='article')"
1169 1235
 			$where_complement = array("'?'", "!(is_array($pred)?count($pred):strlen($pred))", "''", $where_complement);
1236
+		}
1170 1237
 	}
1171 1238
 
1172 1239
 	$boucles[$idb]->where[] = $where;
1173
-	if ($where_complement) // condition annexe du type "AND (objet='article')"
1240
+	if ($where_complement) {
1241
+	    // condition annexe du type "AND (objet='article')"
1174 1242
 		$boucles[$idb]->where[] = $where_complement;
1175
-}
1243
+	}
1244
+	}
1176 1245
 
1177 1246
 // http://doc.spip.org/@calculer_critere_infixe
1178 1247
 function calculer_critere_infixe($idb, &$boucles, $crit){
@@ -1193,13 +1262,15 @@  discard block
 block discarded – undo
1193 1262
 	$where_complement = false;
1194 1263
 
1195 1264
 	// Cas particulier : id_enfant => utiliser la colonne id_objet
1196
-	if ($col=='id_enfant')
1197
-		$col = $boucle->primary;
1265
+	if ($col=='id_enfant') {
1266
+			$col = $boucle->primary;
1267
+	}
1198 1268
 
1199 1269
 	// Cas particulier : id_parent => verifier les exceptions de tables
1200 1270
 	if (in_array($col,array('id_parent','id_secteur'))
1201
-	  AND isset($exceptions_des_tables[$table][$col]))
1202
-		$col = $exceptions_des_tables[$table][$col];
1271
+	  AND isset($exceptions_des_tables[$table][$col])) {
1272
+			$col = $exceptions_des_tables[$table][$col];
1273
+	}
1203 1274
 
1204 1275
 	// et possibilite de gerer un critere secteur sur des tables de plugins (ie forums)
1205 1276
 	else if (($col=='id_secteur') AND ($critere_secteur = charger_fonction("critere_secteur_$type", "public", true))){
@@ -1221,28 +1292,30 @@  discard block
 block discarded – undo
1221 1292
 	else if ($c = calculer_critere_infixe_date($idb, $boucles, $col)){
1222 1293
 		list($col,$col_vraie) = $c;
1223 1294
 		$table = '';
1224
-	}
1225
-	else if (preg_match('/^(.*)\.(.*)$/', $col, $r)){
1295
+	} else if (preg_match('/^(.*)\.(.*)$/', $col, $r)){
1226 1296
 		list(, $table, $col) = $r;
1227 1297
 		$col_alias = $col;
1228 1298
 
1229 1299
 		$trouver_table = charger_fonction('trouver_table','base');
1230 1300
 		if ($desc = $trouver_table($table, $boucle->sql_serveur)
1231 1301
 		  AND isset($desc['field'][$col])
1232
-		  AND $cle = array_search($desc['table'],$boucle->from))
1233
-			$table = $cle;
1234
-		else {
1302
+		  AND $cle = array_search($desc['table'],$boucle->from)) {
1303
+					$table = $cle;
1304
+		} else {
1235 1305
 			$table = trouver_jointure_champ($col, $boucle, array($table), ($crit->cond OR $op!='='));
1236 1306
 		}
1237 1307
 		#$table = calculer_critere_externe_init($boucle, array($table), $col, $desc, ($crit->cond OR $op!='='), true);
1238
-		if (!$table) return '';
1239
-	}
1240
-	elseif (@!array_key_exists($col, $desc['field'])
1308
+		if (!$table) {
1309
+		    return '';
1310
+		}
1311
+	} elseif (@!array_key_exists($col, $desc['field'])
1241 1312
 	         // Champ joker * des iterateurs DATA qui accepte tout
1242 1313
 	         AND @!array_key_exists('*', $desc['field'])
1243 1314
 	) {
1244 1315
 		$r = calculer_critere_infixe_externe($boucle, $crit, $op, $desc, $col, $col_alias, $table);
1245
-		if (!$r) return '';
1316
+		if (!$r) {
1317
+		    return '';
1318
+		}
1246 1319
 		list($col, $col_alias, $table, $where_complement, $desc) = $r;
1247 1320
 	}
1248 1321
 
@@ -1256,8 +1329,9 @@  discard block
 block discarded – undo
1256 1329
 
1257 1330
 		// defaire le quote des int et les passer dans sql_quote avec le bon type de champ si on le connait, int sinon
1258 1331
 		// prendre en compte le debug ou la valeur arrive avec un commentaire PHP en debut
1259
-		if (preg_match(",^\\A(\s*//.*?$\s*)?\"'(-?\d+)'\"\\z,ms", $val[0], $r))
1260
-			$val[0] = $r[1].'"'.sql_quote($r[2],$boucle->sql_serveur,(isset($desc['field'][$col_vraie])?$desc['field'][$col_vraie]:'int NOT NULL')).'"';
1332
+		if (preg_match(",^\\A(\s*//.*?$\s*)?\"'(-?\d+)'\"\\z,ms", $val[0], $r)) {
1333
+					$val[0] = $r[1].'"'.sql_quote($r[2],$boucle->sql_serveur,(isset($desc['field'][$col_vraie])?$desc['field'][$col_vraie]:'int NOT NULL')).'"';
1334
+		}
1261 1335
 
1262 1336
 		// sinon expliciter les
1263 1337
 		// sql_quote(truc) en sql_quote(truc,'',type)
@@ -1279,8 +1353,9 @@  discard block
 block discarded – undo
1279 1353
 	// Ne pas confondre champs de la table principale et des jointures
1280 1354
 	if ($table===$boucle->id_table){
1281 1355
 		$boucles[$idb]->modificateur['criteres'][$col_vraie] = true;
1282
-		if ($col_alias!=$col_vraie)
1283
-			$boucles[$idb]->modificateur['criteres'][$col_alias] = true;
1356
+		if ($col_alias!=$col_vraie) {
1357
+					$boucles[$idb]->modificateur['criteres'][$col_alias] = true;
1358
+		}
1284 1359
 	}
1285 1360
 
1286 1361
 	// ajout pour le cas special d'une condition sur le champ statut:
@@ -1288,17 +1363,25 @@  discard block
 block discarded – undo
1288 1363
 	// de mettre ses propres criteres de statut
1289 1364
 	// http://www.spip.net/@statut (a documenter)
1290 1365
 	// garde pour compatibilite avec code des plugins anterieurs, mais redondant avec la ligne precedente
1291
-	if ($col=='statut') $boucles[$idb]->statut = true;
1366
+	if ($col=='statut') {
1367
+	    $boucles[$idb]->statut = true;
1368
+	}
1292 1369
 
1293 1370
 	// inserer le nom de la table SQL devant le nom du champ
1294 1371
 	if ($table){
1295
-		if ($col[0]=="`")
1296
-			$arg = "$table.".substr($col, 1, -1);
1297
-		else $arg = "$table.$col";
1298
-	} else $arg = $col;
1372
+		if ($col[0]=="`") {
1373
+					$arg = "$table.".substr($col, 1, -1);
1374
+		} else {
1375
+		    $arg = "$table.$col";
1376
+		}
1377
+	} else {
1378
+	    $arg = $col;
1379
+	}
1299 1380
 
1300 1381
 	// inserer la fonction SQL
1301
-	if ($fct) $arg = "$fct($arg$args_sql)";
1382
+	if ($fct) {
1383
+	    $arg = "$fct($arg$args_sql)";
1384
+	}
1302 1385
 
1303 1386
 	return array($arg, $op, $val, $col_alias, $where_complement);
1304 1387
 }
@@ -1324,22 +1407,23 @@  discard block
 block discarded – undo
1324 1407
 		$index = isset($t[$col])
1325 1408
 			? $t[$col] : (isset($t['']) ? $t[''] : array());
1326 1409
 
1327
-		if (count($index)==3)
1328
-			list($t, $col, $calculer_critere_externe) = $index;
1329
-		elseif (count($index)==2) {
1410
+		if (count($index)==3) {
1411
+					list($t, $col, $calculer_critere_externe) = $index;
1412
+		} elseif (count($index)==2) {
1330 1413
 			list($t, $col) = $t[$col];
1331
-		}
1332
-		elseif (count($index)==1) {
1414
+		} elseif (count($index)==1) {
1333 1415
 			list($calculer_critere_externe) = $index;
1334 1416
 			$t = $table;
1417
+		} else {
1418
+					$t = '';
1335 1419
 		}
1336
-		else
1337
-			$t = ''; // jointure non declaree. La trouver.
1420
+		// jointure non declaree. La trouver.
1421
+	} elseif (isset($exceptions_des_jointures[$col])) {
1422
+			list($t, $col) = $exceptions_des_jointures[$col];
1423
+	} else {
1424
+			$t = '';
1338 1425
 	}
1339
-	elseif (isset($exceptions_des_jointures[$col]))
1340
-		list($t, $col) = $exceptions_des_jointures[$col];
1341
-	else
1342
-		$t = ''; // jointure non declaree. La trouver.
1426
+	// jointure non declaree. La trouver.
1343 1427
 
1344 1428
 	// ici on construit le from pour fournir $col en piochant dans les jointures
1345 1429
 
@@ -1358,7 +1442,9 @@  discard block
 block discarded – undo
1358 1442
 		$table = $calculer_critere_externe($boucle, $boucle->jointures, $col, $desc, ($crit->cond OR $op!='='), $t);
1359 1443
 	}
1360 1444
 
1361
-	if (!$table) return '';
1445
+	if (!$table) {
1446
+	    return '';
1447
+	}
1362 1448
 
1363 1449
 	// il ne reste plus qu'a trouver le champ dans les from
1364 1450
 	list($nom, $desc) = trouver_champ_exterieur($col, $boucle->from, $boucle);
@@ -1425,14 +1511,19 @@  discard block
 block discarded – undo
1425 1511
 				$joindre = false;
1426 1512
 				foreach ($cols as $col){
1427 1513
 					$c = '/\b'.$t.".$col".'\b/';
1428
-					if (trouver_champ($c, $boucle->where)) $joindre = true;
1429
-					else {
1514
+					if (trouver_champ($c, $boucle->where)) {
1515
+					    $joindre = true;
1516
+					} else {
1430 1517
 						// mais ca peut etre dans le FIELD pour le Having
1431 1518
 						$c = "/FIELD.$t".".$col,/";
1432
-						if (trouver_champ($c, $boucle->select)) $joindre = true;
1519
+						if (trouver_champ($c, $boucle->select)) {
1520
+						    $joindre = true;
1521
+						}
1433 1522
 					}
1434 1523
 				}
1435
-				if (!$joindre) return $t;
1524
+				if (!$joindre) {
1525
+				    return $t;
1526
+				}
1436 1527
 			}
1437 1528
 			if ($res = calculer_jointure($boucle, array($boucle->id_table, $desc), $arrivee, $cols, $cond, 1)) {
1438 1529
 				return $res;
@@ -1460,7 +1551,9 @@  discard block
 block discarded – undo
1460 1551
 	$intermediaire = trouver_champ_exterieur($primary_arrivee, $joints, $boucle, $checkarrivee."_liens");
1461 1552
 	$arrivee = trouver_champ_exterieur($col, $joints, $boucle, $checkarrivee);
1462 1553
 
1463
-	if (!$intermediaire OR !$arrivee) return '';
1554
+	if (!$intermediaire OR !$arrivee) {
1555
+	    return '';
1556
+	}
1464 1557
 
1465 1558
 	$res = fabrique_jointures($boucle,
1466 1559
 	                          array(
@@ -1474,11 +1567,13 @@  discard block
 block discarded – undo
1474 1567
 
1475 1568
 // http://doc.spip.org/@trouver_champ
1476 1569
 function trouver_champ($champ, $where){
1477
-	if (!is_array($where))
1478
-		return preg_match($champ, $where);
1479
-	else {
1570
+	if (!is_array($where)) {
1571
+			return preg_match($champ, $where);
1572
+	} else {
1480 1573
 		foreach ($where as $clause){
1481
-			if (trouver_champ($champ, $clause)) return true;
1574
+			if (trouver_champ($champ, $clause)) {
1575
+			    return true;
1576
+			}
1482 1577
 		}
1483 1578
 		return false;
1484 1579
 	}
@@ -1493,11 +1588,13 @@  discard block
 block discarded – undo
1493 1588
 	if (count($crit->param)==0){
1494 1589
 		$op = '=';
1495 1590
 		$col = $val = $crit->op;
1496
-		if (preg_match('/^(.*)\.(.*)$/', $col, $r)) $val = $r[2];
1591
+		if (preg_match('/^(.*)\.(.*)$/', $col, $r)) {
1592
+		    $val = $r[2];
1593
+		}
1497 1594
 		// Cas special {lang} : aller chercher $GLOBALS['spip_lang']
1498
-		if ($val=='lang')
1499
-			$val = array(kwote('$GLOBALS[\'spip_lang\']'));
1500
-		else {
1595
+		if ($val=='lang') {
1596
+					$val = array(kwote('$GLOBALS[\'spip_lang\']'));
1597
+		} else {
1501 1598
 			$defaut = null;
1502 1599
 			if ($val=='id_parent') {
1503 1600
 				// Si id_parent, comparer l'id_parent avec l'id_objet
@@ -1506,13 +1603,11 @@  discard block
 block discarded – undo
1506 1603
 				$val = $boucles[$idb]->primary;
1507 1604
 				// mais si pas de boucle superieure, prendre id_parent dans l'env
1508 1605
 				$defaut = "\$Pile[0]['id_parent']";
1509
-			}
1510
-			elseif ($val=='id_enfant'){
1606
+			} elseif ($val=='id_enfant'){
1511 1607
 				// Si id_enfant, comparer l'id_objet avec l'id_parent
1512 1608
 				// de la boucle superieure
1513 1609
 				$val = 'id_parent';
1514
-			}
1515
-			elseif ($crit->cond AND ($col=="date" OR $col=="date_redac")){
1610
+			} elseif ($crit->cond AND ($col=="date" OR $col=="date_redac")){
1516 1611
 				// un critere conditionnel sur date est traite a part
1517 1612
 				// car la date est mise d'office par SPIP,
1518 1613
 				$defaut = "(\$Pile[0]['{$col}_default']?'':\$Pile[0]['".$col."'])";
@@ -1526,7 +1621,9 @@  discard block
 block discarded – undo
1526 1621
 		// le phraseur impose que le premier param soit du texte
1527 1622
 		$params = $crit->param;
1528 1623
 		$op = $crit->op;
1529
-		if ($op=='==') $op = 'REGEXP';
1624
+		if ($op=='==') {
1625
+		    $op = 'REGEXP';
1626
+		}
1530 1627
 		$col = array_shift($params);
1531 1628
 		$col = $col[0]->texte;
1532 1629
 
@@ -1546,11 +1643,16 @@  discard block
 block discarded – undo
1546 1643
 		                         AND $params[0][1]->type=='champ'
1547 1644
 		){
1548 1645
 			$val[] = "$p\\$p#".$params[0][1]->nom_champ."\\$p$p";
1549
-		} else
1550
-			foreach ((($op!='IN') ? $params : calculer_vieux_in($params)) as $p){
1646
+		} else {
1647
+					foreach ((($op!='IN') ? $params : calculer_vieux_in($params)) as $p){
1551 1648
 				$a = calculer_liste($p, $desc, $boucles, $parent);
1552
-				if (strcasecmp($op,'IN')==0) $val[] = $a;
1553
-				else $val[] = kwote($a, $boucles[$idb]->sql_serveur, 'char'); // toujours quoter en char ici
1649
+		}
1650
+				if (strcasecmp($op,'IN')==0) {
1651
+				    $val[] = $a;
1652
+				} else {
1653
+				    $val[] = kwote($a, $boucles[$idb]->sql_serveur, 'char');
1654
+				}
1655
+				// toujours quoter en char ici
1554 1656
 			}
1555 1657
 	}
1556 1658
 
@@ -1583,8 +1685,9 @@  discard block
 block discarded – undo
1583 1685
 	$n = isset($last->texte) ? strlen($last->texte) : 0;
1584 1686
 
1585 1687
 	if (!((isset($deb->texte[0])     AND $deb->texte[0]=='(')
1586
-	   && (isset($last->texte[$n-1]) AND $last->texte[$n-1]==')')))
1587
-		return $params;
1688
+	   && (isset($last->texte[$n-1]) AND $last->texte[$n-1]==')'))) {
1689
+			return $params;
1690
+	}
1588 1691
 	$params[0][0]->texte = substr($deb->texte, 1);
1589 1692
 	// attention, on peut avoir k=0,j=0 ==> recalculer
1590 1693
 	$last = $params[$k][$j];
@@ -1592,9 +1695,9 @@  discard block
 block discarded – undo
1592 1695
 	$params[$k][$j]->texte = substr($last->texte, 0, $n-1);
1593 1696
 	$newp = array();
1594 1697
 	foreach ($params as $v){
1595
-		if ($v[0]->type!='texte')
1596
-			$newp[] = $v;
1597
-		else {
1698
+		if ($v[0]->type!='texte') {
1699
+					$newp[] = $v;
1700
+		} else {
1598 1701
 			foreach (explode(',', $v[0]->texte) as $x){
1599 1702
 				$t = new Texte;
1600 1703
 				$t->texte = $x;
@@ -1607,27 +1710,35 @@  discard block
 block discarded – undo
1607 1710
 
1608 1711
 // http://doc.spip.org/@calculer_critere_infixe_date
1609 1712
 function calculer_critere_infixe_date($idb, &$boucles, $col){
1610
-	if (!preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z]+)?$,", $col, $regs)) return '';
1713
+	if (!preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z]+)?$,", $col, $regs)) {
1714
+	    return '';
1715
+	}
1611 1716
 	$boucle = $boucles[$idb];
1612 1717
 	$table = $boucle->show;
1613 1718
 	// si c'est une colonne de la table, ne rien faire
1614
-	if(isset($table['field'][$col])) return '';
1719
+	if(isset($table['field'][$col])) {
1720
+	    return '';
1721
+	}
1615 1722
 
1616
-	if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) return '';
1723
+	if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) {
1724
+	    return '';
1725
+	}
1617 1726
 	$pred = $date_orig = isset($GLOBALS['table_date'][$table['id_table']])? $GLOBALS['table_date'][$table['id_table']] : $table['date'];
1618 1727
 	$col = $regs[1];
1619 1728
 	if (isset($regs[3]) AND $suite = $regs[3]){
1620 1729
 		# Recherche de l'existence du champ date_xxxx,
1621 1730
 		# si oui choisir ce champ, sinon choisir xxxx
1622 1731
 
1623
-		if (isset($table['field']["date$suite"]))
1624
-			$date_orig = 'date'.$suite;
1625
-		else
1626
-			$date_orig = substr($suite, 1);
1732
+		if (isset($table['field']["date$suite"])) {
1733
+					$date_orig = 'date'.$suite;
1734
+		} else {
1735
+					$date_orig = substr($suite, 1);
1736
+		}
1627 1737
 		$pred = $date_orig;
1628
-	}
1629
-	else
1630
-		if (isset($regs[2]) AND $rel = $regs[2]) $pred = 'date';
1738
+	} else
1739
+		if (isset($regs[2]) AND $rel = $regs[2]) {
1740
+		    $pred = 'date';
1741
+		}
1631 1742
 
1632 1743
 	$date_compare = "\"' . normaliser_date(".
1633 1744
 	                calculer_argument_precedent($idb, $pred, $boucles).
@@ -1684,9 +1795,9 @@  discard block
 block discarded – undo
1684 1795
 	if (preg_match(",'\" *\.(.*)\. *\"',", $date_compare, $r)){
1685 1796
 		$init = "'\" . (\$x = $r[1]) . \"'";
1686 1797
 		$date_compare = '\'$x\'';
1798
+	} else {
1799
+			$init = $date_compare;
1687 1800
 	}
1688
-	else
1689
-		$init = $date_compare;
1690 1801
 
1691 1802
 	return
1692 1803
 		"LEAST((UNIX_TIMESTAMP(".
@@ -1722,9 +1833,10 @@  discard block
 block discarded – undo
1722 1833
 	$boucle = &$boucles[$idb];
1723 1834
 
1724 1835
 	$args = array();
1725
-	foreach ($crit->param as &$param)
1726
-		array_push($args,
1836
+	foreach ($crit->param as &$param) {
1837
+			array_push($args,
1727 1838
 		           calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent));
1839
+	}
1728 1840
 
1729 1841
 	$boucle->hash .= '
1730 1842
 	$command[\'sourcemode\'] = '.array_shift($args).";\n";
@@ -1896,8 +2008,9 @@  discard block
 block discarded – undo
1896 2008
 
1897 2009
 	$in = "IN";
1898 2010
 	$where = array("'IN'", "'$boucle->id_table."."$primary'", "'('.sql_get_select('$id_parent', '$table_sql').')'");
1899
-	if ($not)
1900
-		$where = array("'NOT'", $where);
2011
+	if ($not) {
2012
+			$where = array("'NOT'", $where);
2013
+	}
1901 2014
 
1902 2015
 	$boucle->where[] = $where;
1903 2016
 }
Please login to merge, or discard this patch.
ecrire/public/phraser_html.php 1 patch
Braces   +152 added lines, -88 removed lines patch added patch discarded remove patch
@@ -11,7 +11,9 @@  discard block
 block discarded – undo
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
 # Ce fichier transforme un squelette en un tableau d'objets de classe Boucle
17 19
 # il est charge par un include calcule 
@@ -44,7 +46,9 @@  discard block
 block discarded – undo
44 46
 	while (preg_match(BALISE_INCLURE, $texte, $match)){
45 47
 		$p = strpos($texte, $match[0]);
46 48
 		$debut = substr($texte, 0, $p);
47
-		if ($p) $result = phraser_idiomes($debut, $ligne, $result);
49
+		if ($p) {
50
+		    $result = phraser_idiomes($debut, $ligne, $result);
51
+		}
48 52
 		$ligne += substr_count($debut, "\n");
49 53
 		$champ = new Inclure;
50 54
 		$champ->ligne = $ligne;
@@ -60,8 +64,9 @@  discard block
 block discarded – undo
60 64
 		// on assimile {var=val} a une liste de un argument sans fonction
61 65
 		phraser_args($texte, "/>", "", $result, $champ);
62 66
 		if (!$champ->texte OR count($champ->param)>1){
63
-			if (!function_exists('normaliser_inclure'))
64
-				include_spip('public/normaliser');
67
+			if (!function_exists('normaliser_inclure')) {
68
+							include_spip('public/normaliser');
69
+			}
65 70
 			normaliser_inclure($champ);
66 71
 		}
67 72
 		$texte = substr($champ->apres, strpos($champ->apres, '>')+1);
@@ -76,9 +81,10 @@  discard block
 block discarded – undo
76 81
 // http://doc.spip.org/@phraser_polyglotte
77 82
 function phraser_polyglotte($texte, $ligne, $result){
78 83
 
79
-	if (preg_match_all(BALISE_POLYGLOTTE, $texte, $m, PREG_SET_ORDER))
80
-		foreach ($m as $match){
84
+	if (preg_match_all(BALISE_POLYGLOTTE, $texte, $m, PREG_SET_ORDER)) {
85
+			foreach ($m as $match){
81 86
 			$p = strpos($texte, $match[0]);
87
+	}
82 88
 			$debut = substr($texte, 0, $p);
83 89
 			if ($p){
84 90
 				$champ = new Texte;
@@ -96,8 +102,9 @@  discard block
 block discarded – undo
96 102
 			$texte = substr($texte, $p+strlen($match[0]));
97 103
 			while (preg_match("/^[[:space:]]*([^[{]*)[[:space:]]*[[{]([a-z_]+)[]}](.*)$/si", $bloc, $regs)){
98 104
 				$trad = $regs[1];
99
-				if ($trad OR $lang)
100
-					$champ->traductions[$lang] = $trad;
105
+				if ($trad OR $lang) {
106
+									$champ->traductions[$lang] = $trad;
107
+				}
101 108
 				$lang = $regs[2];
102 109
 				$bloc = $regs[3];
103 110
 			}
@@ -125,10 +132,15 @@  discard block
 block discarded – undo
125 132
 		$p = strpos($texte, $match[0]);
126 133
 		$ko = (!$match[3] && ($match[5][0]!=='='));
127 134
 		$debut = substr($texte, 0, $p+($ko ? strlen($match[0]) : 0));
128
-		if ($debut) $result = phraser_champs($debut, $ligne, $result);
135
+		if ($debut) {
136
+		    $result = phraser_champs($debut, $ligne, $result);
137
+		}
129 138
 		$texte = substr($texte, $p+strlen($match[0]));
130 139
 		$ligne += substr_count($debut, "\n");
131
-		if ($ko) continue; // faux idiome
140
+		if ($ko) {
141
+		    continue;
142
+		}
143
+		// faux idiome
132 144
 		$champ = new Idiome;
133 145
 		$champ->ligne = $ligne;
134 146
 		$ligne += substr_count($match[0], "\n");
@@ -146,7 +158,9 @@  discard block
 block discarded – undo
146 158
 		phraser_args(@$match[7], ":", '', array(), $champ);
147 159
 		$result[] = $champ;
148 160
 	}
149
-	if ($texte!=="") $result = phraser_champs($texte, $ligne, $result);
161
+	if ($texte!=="") {
162
+	    $result = phraser_champs($texte, $ligne, $result);
163
+	}
150 164
 
151 165
 	return $result;
152 166
 }
@@ -158,7 +172,9 @@  discard block
 block discarded – undo
158 172
 		$suite = substr($texte, $p+strlen($match[0]));
159 173
 		if ($match[5] || (strpos($suite[0], "[0-9]")===false)){
160 174
 			$debut = substr($texte, 0, $p);
161
-			if ($p) $result = phraser_polyglotte($debut, $ligne, $result);
175
+			if ($p) {
176
+			    $result = phraser_polyglotte($debut, $ligne, $result);
177
+			}
162 178
 			$ligne += substr_count($debut, "\n");
163 179
 			$champ = new Champ;
164 180
 			$champ->ligne = $ligne;
@@ -180,7 +196,9 @@  discard block
 block discarded – undo
180 196
 						$champ->apres[0]->texte = substr($suite,0,$n);
181 197
 					}
182 198
 				*/
183
-			} else $texte = $suite;
199
+			} else {
200
+			    $texte = $suite;
201
+			}
184 202
 			phraser_vieux($champ);
185 203
 			$result[] = $champ;
186 204
 		} else {
@@ -189,7 +207,9 @@  discard block
 block discarded – undo
189 207
 			$texte = (substr($texte, $p+1));
190 208
 		}
191 209
 	}
192
-	if ($texte!=="") $result = phraser_polyglotte($texte, $ligne, $result);
210
+	if ($texte!=="") {
211
+	    $result = phraser_polyglotte($texte, $ligne, $result);
212
+	}
193 213
 
194 214
 	return $result;
195 215
 }
@@ -201,10 +221,13 @@  discard block
 block discarded – undo
201 221
 
202 222
 // http://doc.spip.org/@phraser_champs_etendus
203 223
 function phraser_champs_etendus($texte, $ligne, $result){
204
-	if ($texte==="") return $result;
224
+	if ($texte==="") {
225
+	    return $result;
226
+	}
205 227
 	$sep = '##';
206
-	while (strpos($texte, $sep)!==false)
207
-		$sep .= '#';
228
+	while (strpos($texte, $sep)!==false) {
229
+			$sep .= '#';
230
+	}
208 231
 
209 232
 	return array_merge($result, phraser_champs_interieurs($texte, $ligne, $sep, array()));
210 233
 }
@@ -234,7 +257,9 @@  discard block
 block discarded – undo
234 257
 	preg_match(",^(\|?[^}{)|]*)(.*)$,ms", $texte, $match);
235 258
 	$suite = ltrim($match[2]);
236 259
 	$fonc = trim($match[1]);
237
-	if ($fonc && $fonc[0]=="|") $fonc = ltrim(substr($fonc, 1));
260
+	if ($fonc && $fonc[0]=="|") {
261
+	    $fonc = ltrim(substr($fonc, 1));
262
+	}
238 263
 	$res = array($fonc);
239 264
 	$err_f = '';
240 265
 	// cas du filtre sans argument ou du critere /
@@ -244,9 +269,14 @@  discard block
 block discarded – undo
244 269
 			$err_f = array('zbug_erreur_filtre', array('filtre' => $texte));
245 270
 			erreur_squelette($err_f, $pointeur_champ);
246 271
 			$texte = '';
247
-		} else  $texte = $suite;
248
-		if ($err_f) $pointeur_champ->param = false;
249
-		elseif ($fonc!=='') $pointeur_champ->param[] = $res;
272
+		} else {
273
+		    $texte = $suite;
274
+		}
275
+		if ($err_f) {
276
+		    $pointeur_champ->param = false;
277
+		} elseif ($fonc!=='') {
278
+		    $pointeur_champ->param[] = $res;
279
+		}
250 280
 		// pour les balises avec faux filtres qui boudent ce dur larbeur
251 281
 		$pointeur_champ->fonctions[] = array($fonc, '');
252 282
 
@@ -255,11 +285,11 @@  discard block
 block discarded – undo
255 285
 	$args = ltrim(substr($suite, 1)); // virer le '(' initial
256 286
 	$collecte = array();
257 287
 	while ($args && $args[0]!='}'){
258
-		if ($args[0]=='"')
259
-			preg_match('/^(")([^"]*)(")(.*)$/ms', $args, $regs);
260
-		else if ($args[0]=="'")
261
-			preg_match("/^(')([^']*)(')(.*)$/ms", $args, $regs);
262
-		else {
288
+		if ($args[0]=='"') {
289
+					preg_match('/^(")([^"]*)(")(.*)$/ms', $args, $regs);
290
+		} else if ($args[0]=="'") {
291
+					preg_match("/^(')([^']*)(')(.*)$/ms", $args, $regs);
292
+		} else {
263 293
 			preg_match("/^([[:space:]]*)([^,([{}]*([(\[{][^])}]*[])}])?[^,}]*)([,}].*)$/ms", $args, $regs);
264 294
 			if (!strlen($regs[2])){
265 295
 				$err_f = array('zbug_erreur_filtre', array('filtre' => $args));
@@ -318,10 +348,14 @@  discard block
 block discarded – undo
318 348
 					$next = isset($args[0]) ? $args[0] : '';
319 349
 				}
320 350
 				// Si erreur de syntaxe dans un sous-argument, propager.
321
-				if ($champ->param===false)
322
-					$err_f = true;
323
-				else phraser_vieux($champ);
324
-				if ($par==')') $args = substr($args, 1);
351
+				if ($champ->param===false) {
352
+									$err_f = true;
353
+				} else {
354
+				    phraser_vieux($champ);
355
+				}
356
+				if ($par==')') {
357
+				    $args = substr($args, 1);
358
+				}
325 359
 				$collecte[] = $champ;
326 360
 				$result[] = $champ;
327 361
 			}
@@ -342,10 +376,11 @@  discard block
 block discarded – undo
342 376
 	$source = substr($suite, 0, strlen($suite)-strlen($texte));
343 377
 	// propager les erreurs, et ignorer les param vides
344 378
 	if ($pointeur_champ->param!==false){
345
-		if ($err_f)
346
-			$pointeur_champ->param = false;
347
-		elseif ($fonc!=='' || count($res)>1)
348
-			$pointeur_champ->param[] = $res;
379
+		if ($err_f) {
380
+					$pointeur_champ->param = false;
381
+		} elseif ($fonc!=='' || count($res)>1) {
382
+					$pointeur_champ->param[] = $res;
383
+		}
349 384
 	}
350 385
 	// pour les balises avec faux filtres qui boudent ce dur larbeur
351 386
 	$pointeur_champ->fonctions[] = array($fonc, $source);
@@ -358,12 +393,14 @@  discard block
 block discarded – undo
358 393
 function phraser_champs_exterieurs($texte, $ligne, $sep, $nested){
359 394
 	$res = array();
360 395
 	while (($p = strpos($texte, "%$sep"))!==false){
361
-		if (!preg_match(',^%' . preg_quote($sep) . '([0-9]+)@,', substr($texte, $p), $m))
362
-			break;
396
+		if (!preg_match(',^%' . preg_quote($sep) . '([0-9]+)@,', substr($texte, $p), $m)) {
397
+					break;
398
+		}
363 399
 		$debut = substr($texte, 0, $p);
364 400
 		$texte = substr($texte, $p+strlen($m[0]));
365
-		if ($p)
366
-			$res = phraser_inclure($debut, $ligne, $res);
401
+		if ($p) {
402
+					$res = phraser_inclure($debut, $ligne, $res);
403
+		}
367 404
 		$ligne += substr_count($debut, "\n");
368 405
 		$res[] = $nested[$m[1]];
369 406
 	}
@@ -417,45 +454,53 @@  discard block
 block discarded – undo
417 454
 		while ($j<$i){
418 455
 			$z = $result[$j];
419 456
 			// j'aurais besoin de connaitre le nombre de lignes...
420
-			if (is_object($z))
421
-				$x .= "%$sep$j@";
422
-			else
423
-				$x .= $z;
457
+			if (is_object($z)) {
458
+							$x .= "%$sep$j@";
459
+			} else {
460
+							$x .= $z;
461
+			}
424 462
 			$j++;
425 463
 		}
426
-		if (preg_match(CHAMP_ETENDU, $x))
427
-			$texte = $x;
428
-		else
429
-			return phraser_champs_exterieurs($x, $ligne, $sep, $result);
464
+		if (preg_match(CHAMP_ETENDU, $x)) {
465
+					$texte = $x;
466
+		} else {
467
+					return phraser_champs_exterieurs($x, $ligne, $sep, $result);
468
+		}
430 469
 	}
431 470
 }
432 471
 
433 472
 function phraser_vieux(&$champ){
434 473
 	$nom = $champ->nom_champ;
435 474
 	if ($nom=='EMBED_DOCUMENT'){
436
-		if (!function_exists('phraser_vieux_emb'))
437
-			include_spip('public/normaliser');
475
+		if (!function_exists('phraser_vieux_emb')) {
476
+					include_spip('public/normaliser');
477
+		}
438 478
 		phraser_vieux_emb($champ);
439 479
 	} elseif ($nom=='EXPOSER') {
440
-		if (!function_exists('phraser_vieux_exposer'))
441
-			include_spip('public/normaliser');
480
+		if (!function_exists('phraser_vieux_exposer')) {
481
+					include_spip('public/normaliser');
482
+		}
442 483
 		phraser_vieux_exposer($champ);
443 484
 	} elseif ($champ->param) {
444 485
 		if ($nom=='FORMULAIRE_RECHERCHE'){
445
-			if (!function_exists('phraser_vieux_recherche'))
446
-				include_spip('public/normaliser');
486
+			if (!function_exists('phraser_vieux_recherche')) {
487
+							include_spip('public/normaliser');
488
+			}
447 489
 			phraser_vieux_recherche($champ);
448 490
 		} elseif (preg_match(",^LOGO_[A-Z]+,", $nom)) {
449
-			if (!function_exists('phraser_vieux_logos'))
450
-				include_spip('public/normaliser');
491
+			if (!function_exists('phraser_vieux_logos')) {
492
+							include_spip('public/normaliser');
493
+			}
451 494
 			phraser_vieux_logos($champ);
452 495
 		} elseif ($nom=='MODELE') {
453
-			if (!function_exists('phraser_vieux_modele'))
454
-				include_spip('public/normaliser');
496
+			if (!function_exists('phraser_vieux_modele')) {
497
+							include_spip('public/normaliser');
498
+			}
455 499
 			phraser_vieux_modele($champ);
456 500
 		} elseif ($nom=='INCLURE' OR $nom=='INCLUDE') {
457
-			if (!function_exists('phraser_vieux_inclu'))
458
-				include_spip('public/normaliser');
501
+			if (!function_exists('phraser_vieux_inclu')) {
502
+							include_spip('public/normaliser');
503
+			}
459 504
 			phraser_vieux_inclu($champ);
460 505
 		}
461 506
 	}
@@ -517,13 +562,16 @@  discard block
 block discarded – undo
517 562
 					if (preg_match(',^(["\'])(.*)\1$,', $m[4])){
518 563
 						$c = null;
519 564
 						eval ('$c = ' . $m[4] . ';');
520
-						if (isset($c))
521
-							$m[4] = $c;
565
+						if (isset($c)) {
566
+													$m[4] = $c;
567
+						}
522 568
 					}
523 569
 					$texte = new Texte;
524 570
 					$texte->texte = $m[4];
525 571
 					$v[1][0] = $texte;
526
-				} else array_shift($v[1]);
572
+				} else {
573
+				    array_shift($v[1]);
574
+				}
527 575
 			}
528 576
 			array_shift($v); // $v[O] est vide
529 577
 			$crit = new Critere;
@@ -552,12 +600,13 @@  discard block
 block discarded – undo
552 600
 			} else {
553 601
 				// traiter qq lexemes particuliers pour faciliter la suite
554 602
 				// les separateurs
555
-				if ($var->apres)
556
-					$result->separateur[] = $param;
557
-				elseif (($param=='tout') OR ($param=='tous'))
558
-					$result->modificateur['tout'] = true;
559
-				elseif ($param=='plat')
560
-					$result->modificateur['plat'] = true;
603
+				if ($var->apres) {
604
+									$result->separateur[] = $param;
605
+				} elseif (($param=='tout') OR ($param=='tous')) {
606
+									$result->modificateur['tout'] = true;
607
+				} elseif ($param=='plat') {
608
+									$result->modificateur['plat'] = true;
609
+				}
561 610
 
562 611
 				// Boucle hierarchie, analyser le critere id_rubrique
563 612
 				// et les autres critères {id_x} pour forcer {tout} sur
@@ -578,17 +627,21 @@  discard block
 block discarded – undo
578 627
 						// cette variable sera inseree dans le code
579 628
 						// et son nom sert d'indicateur des maintenant
580 629
 						$result->doublons = '$doublons_index';
581
-						if ($param=='unique') $param = 'doublons';
582
-					} elseif ($param=='recherche')
583
-						// meme chose (a cause de #nom_de_boucle:URL_*)
630
+						if ($param=='unique') {
631
+						    $param = 'doublons';
632
+						}
633
+					} elseif ($param=='recherche') {
634
+											// meme chose (a cause de #nom_de_boucle:URL_*)
584 635
 						$result->hash = ' ';
636
+					}
585 637
 					if (preg_match(',^ *([0-9-]+) *(/) *(.+) *$,', $param, $m)){
586 638
 						$crit = phraser_critere_infixe($m[1], $m[3], $v, '/', '', '');
587 639
 					} elseif (preg_match(',^([!]?)(' . CHAMP_SQL_PLUS_FONC .
588 640
 						')[[:space:]]*(\??)(!?)(<=?|>=?|==?|\b(?:IN|LIKE)\b)(.*)$,is', $param, $m)) {
589 641
 						$a2 = trim($m[8]);
590
-						if ($a2 AND ($a2[0]=="'" OR $a2[0]=='"') AND ($a2[0]==substr($a2, -1)))
591
-							$a2 = substr($a2, 1, -1);
642
+						if ($a2 AND ($a2[0]=="'" OR $a2[0]=='"') AND ($a2[0]==substr($a2, -1))) {
643
+													$a2 = substr($a2, 1, -1);
644
+						}
592 645
 						$crit = phraser_critere_infixe($m[2], $a2, $v,
593 646
 							(($m[2]=='lang_select') ? $m[2] : $m[7]),
594 647
 							$m[6], $m[5]);
@@ -605,7 +658,9 @@  discard block
 block discarded – undo
605 658
 							$v[0][0]->texte = $m[6];
606 659
 						} else {
607 660
 							array_shift($v[0]);
608
-							if (!$v[0]) array_shift($v);
661
+							if (!$v[0]) {
662
+							    array_shift($v);
663
+							}
609 664
 						}
610 665
 						$crit = new Critere;
611 666
 						$crit->op = $m[2];
@@ -617,10 +672,11 @@  discard block
 block discarded – undo
617 672
 							array('critere' => $param));
618 673
 						erreur_squelette($err_ci, $result);
619 674
 					}
620
-					if ((!preg_match(',^!?doublons *,', $param)) || $crit->not)
621
-						$args[] = $crit;
622
-					else
623
-						$doublons[] = $crit;
675
+					if ((!preg_match(',^!?doublons *,', $param)) || $crit->not) {
676
+											$args[] = $crit;
677
+					} else {
678
+											$doublons[] = $crit;
679
+					}
624 680
 				}
625 681
 			}
626 682
 		}
@@ -628,10 +684,14 @@  discard block
 block discarded – undo
628 684
 	// les doublons non nies doivent etre le dernier critere
629 685
 	// pour que la variable $doublon_index ait la bonne valeur
630 686
 	// cf critere_doublon
631
-	if ($doublons) $args = array_merge($args, $doublons);
687
+	if ($doublons) {
688
+	    $args = array_merge($args, $doublons);
689
+	}
632 690
 	// Si erreur, laisser la chaine dans ce champ pour le HTTP 503
633
-	if (!$err_ci) $result->criteres = $args;
634
-}
691
+	if (!$err_ci) {
692
+	    $result->criteres = $args;
693
+	}
694
+	}
635 695
 
636 696
 // http://doc.spip.org/@phraser_critere_infixe
637 697
 function phraser_critere_infixe($arg1, $arg2, $args, $op, $not, $cond){
@@ -774,14 +834,15 @@  discard block
 block discarded – undo
774 834
 		}
775 835
 		$soustype = strtolower($type);
776 836
 
777
-		if (!isset($GLOBALS["table_des_tables"][$soustype]))
778
-			$soustype = $type;
837
+		if (!isset($GLOBALS["table_des_tables"][$soustype])) {
838
+					$soustype = $type;
839
+		}
779 840
 
780 841
 		$result->type_requete = $soustype;
781 842
 		// Lancer la 2e passe sur les criteres si la 1ere etait bonne
782
-		if (!is_array($result->param))
783
-			$err_b = true;
784
-		else {
843
+		if (!is_array($result->param)) {
844
+					$err_b = true;
845
+		} else {
785 846
 			phraser_criteres($result->param, $result);
786 847
 			if (strncasecmp($soustype, TYPE_RECURSIF, strlen(TYPE_RECURSIF))==0){
787 848
 				$result->type_requete = TYPE_RECURSIF;
@@ -798,7 +859,9 @@  discard block
 block discarded – undo
798 859
 		$result->milieu = public_phraser_html_dist($milieu, $id_boucle, $boucles, $descr, $result->ligne+$b);
799 860
 
800 861
 		// Prevenir le generateur de code que le squelette est faux
801
-		if ($err_b) $result->type_requete = false;
862
+		if ($err_b) {
863
+		    $result->type_requete = false;
864
+		}
802 865
 
803 866
 		// Verifier qu'il n'y a pas double definition
804 867
 		// apres analyse des sous-parties (pas avant).
@@ -809,8 +872,9 @@  discard block
 block discarded – undo
809 872
 			erreur_squelette($err_b_d, $result);
810 873
 			// Prevenir le generateur de code que le squelette est faux
811 874
 			$boucles[$id_boucle]->type_requete = false;
812
-		} else
813
-			$boucles[$id_boucle] = $result;
875
+		} else {
876
+					$boucles[$id_boucle] = $result;
877
+		}
814 878
 		$all_res = phraser_champs_etendus($debut, $ligne, $all_res);
815 879
 		$all_res[] = &$boucles[$id_boucle];
816 880
 		if (!empty($suite)){
Please login to merge, or discard this patch.
ecrire/public/normaliser.php 1 patch
Braces   +35 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
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
 // Les fonctions de ce fichier sont appelees en certains points 
16 18
 // de l'analyseur syntaxique afin de normaliser de vieilles syntaxes,
@@ -24,9 +26,9 @@  discard block
 block discarded – undo
24 26
 
25 27
 function phraser_vieux_logos(&$p)
26 28
 {
27
-	if ($p->param[0][0])
28
-		$args = array('');
29
-	else {
29
+	if ($p->param[0][0]) {
30
+			$args = array('');
31
+	} else {
30 32
 		$args = array_shift($p->param);
31 33
 	}
32 34
 
@@ -90,8 +92,9 @@  discard block
 block discarded – undo
90 92
 
91 93
 function phraser_vieux_emb(&$p)
92 94
 {
93
-	if (!is_array($p->param))
94
-		$p->param=array();
95
+	if (!is_array($p->param)) {
96
+			$p->param=array();
97
+	}
95 98
 
96 99
 	// Produire le premier argument {emb}
97 100
 	$texte = new Texte;
@@ -101,8 +104,10 @@  discard block
 block discarded – undo
101 104
 	// Transformer les filtres en arguments
102 105
 	for ($i=0; $i<count($p->param); $i++) {
103 106
 		if ($p->param[$i][0]) {
104
-			if (!strstr($p->param[$i][0], '='))
105
-				break;# on a rencontre un vrai filtre, c'est fini
107
+			if (!strstr($p->param[$i][0], '=')) {
108
+							break;
109
+			}
110
+			# on a rencontre un vrai filtre, c'est fini
106 111
 			$texte = new Texte;
107 112
 			$texte->texte=$p->param[$i][0];
108 113
 			$param[] = array($texte);
@@ -156,15 +161,23 @@  discard block
 block discarded – undo
156 161
 function normaliser_args_inclumodel($p)
157 162
 {
158 163
 	$params = $p->param;
159
-	if (!$params) return;
164
+	if (!$params) {
165
+	    return;
166
+	}
160 167
 	$args = $params[0];
161
-	if ($args[0]) return; // filtre immediat
168
+	if ($args[0]) {
169
+	    return;
170
+	}
171
+	// filtre immediat
162 172
 	array_shift($p->param);
163 173
 	foreach ($p->param as $l) {
164 174
 		if (!array_shift($l))  {
165 175
 			$args = array_merge($args, $l);
166 176
 			array_shift($p->param);
167
-		} else  break; // filtre
177
+		} else {
178
+		    break;
179
+		}
180
+		// filtre
168 181
 	}
169 182
 	array_unshift($p->param, $args);
170 183
 }
@@ -181,16 +194,20 @@  discard block
 block discarded – undo
181 194
 	  }
182 195
 	  foreach ($l as $k => $p) {
183 196
 		if (!$p OR $p[0]->type != 'texte' OR 
184
-		    !preg_match('/^fond\s*=\s*(.*)$/',$p[0]->texte, $r))
185
-			continue;
197
+		    !preg_match('/^fond\s*=\s*(.*)$/',$p[0]->texte, $r)) {
198
+					continue;
199
+		}
186 200
 
187
-		if ($r[1])
188
-			$p[0]->texte = $r[1];
189
-		else unset($p[0]);
201
+		if ($r[1]) {
202
+					$p[0]->texte = $r[1];
203
+		} else {
204
+		    unset($p[0]);
205
+		}
190 206
 		$champ->texte = $p;
191 207
 		unset($champ->param[0][$k]);
192
-		if (count($champ->param[0]) ==1) 
193
-			array_shift($champ->param);
208
+		if (count($champ->param[0]) ==1) {
209
+					array_shift($champ->param);
210
+		}
194 211
 		return;
195 212
 	  }
196 213
 	}
Please login to merge, or discard this patch.
ecrire/public/interfaces.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@
 block discarded – undo
16 16
  * @package SPIP\Compilateur\AST
17 17
 **/
18 18
 
19
-if (!defined('_ECRIRE_INC_VERSION')) return;
19
+if (!defined('_ECRIRE_INC_VERSION')) {
20
+    return;
21
+}
20 22
 
21 23
 
22 24
 /**
Please login to merge, or discard this patch.
ecrire/public/balises.php 1 patch
Braces   +143 added lines, -88 removed lines patch added patch discarded remove patch
@@ -17,18 +17,21 @@  discard block
 block discarded – undo
17 17
 // elle recoit en entree un objet de classe CHAMP, le modifie et le retourne.
18 18
 // Cette classe est definie dans public/interfaces
19 19
 
20
-if (!defined('_ECRIRE_INC_VERSION')) return;
20
+if (!defined('_ECRIRE_INC_VERSION')) {
21
+    return;
22
+}
21 23
 
22 24
 // http://doc.spip.org/@interprete_argument_balise
23 25
 function interprete_argument_balise($n,$p) {
24
-	if (($p->param) && (!$p->param[0][0]) && (count($p->param[0])>$n))
25
-		return calculer_liste($p->param[0][$n],
26
+	if (($p->param) && (!$p->param[0][0]) && (count($p->param[0])>$n)) {
27
+			return calculer_liste($p->param[0][$n],
26 28
 			$p->descr,
27 29
 			$p->boucles,
28 30
 			$p->id_boucle);
29
-	else
30
-		return NULL;
31
-}
31
+	} else {
32
+			return NULL;
33
+	}
34
+	}
32 35
 //
33 36
 // Definition des balises
34 37
 //
@@ -187,8 +190,9 @@  discard block
 block discarded – undo
187 190
 		champ_sql('url_site',$p) ."," .
188 191
 		champ_sql('nom_site',$p) .
189 192
 		", 'titre', \$connect, false))";
190
-	} else
191
-		$p->code = champ_sql('nom_site',$p);
193
+	} else {
194
+			$p->code = champ_sql('nom_site',$p);
195
+	}
192 196
 
193 197
 	$p->interdire_scripts = true;
194 198
 	return $p;
@@ -276,8 +280,9 @@  discard block
 block discarded – undo
276 280
 	$off= "''";
277 281
 	if (($v = interprete_argument_balise(1,$p))!==NULL){
278 282
 		$on = $v;
279
-		if (($v = interprete_argument_balise(2,$p))!==NULL)
280
-			$off = $v;
283
+		if (($v = interprete_argument_balise(2,$p))!==NULL) {
284
+					$off = $v;
285
+		}
281 286
 
282 287
 	}
283 288
 	return calculer_balise_expose($p, $on, $off);
@@ -320,7 +325,9 @@  discard block
 block discarded – undo
320 325
 		$parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b);
321 326
 	} elseif  (isset($desc['field']['id_groupe'])) {
322 327
 		$parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b);
323
-	} else $parent = "''";
328
+	} else {
329
+	    $parent = "''";
330
+	}
324 331
 
325 332
 	$p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)";
326 333
 
@@ -400,10 +407,11 @@  discard block
 block discarded – undo
400 407
 // http://doc.spip.org/@balise_LANG_dist
401 408
 function balise_LANG_dist ($p) {
402 409
 	$_lang = champ_sql('lang', $p);
403
-	if (!$p->etoile)
404
-		$p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";
405
-	else
406
-		$p->code = "spip_htmlentities($_lang)";
410
+	if (!$p->etoile) {
411
+			$p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";
412
+	} else {
413
+			$p->code = "spip_htmlentities($_lang)";
414
+	}
407 415
 	$p->interdire_scripts = false;
408 416
 	return $p;
409 417
 }
@@ -430,8 +438,7 @@  discard block
 block discarded – undo
430 438
 			$connect = '';
431 439
 			$objet = 'article';
432 440
 			$id_table_objet = 'id_article';
433
-		}
434
-		else{
441
+		} else{
435 442
 			$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
436 443
 			$connect = $p->boucles[$b]->sql_serveur;
437 444
 			$type_boucle = $p->boucles[$b]->type_requete;
@@ -593,9 +600,9 @@  discard block
 block discarded – undo
593 600
 
594 601
 	if (count($_contexte)){
595 602
 		$code_contexte = implode(',',$_contexte);
603
+	} else {
604
+			$code_contexte = '';
596 605
 	}
597
-	else
598
-		$code_contexte = '';
599 606
 
600 607
 	$connect = $p->boucles[$b]->sql_serveur;
601 608
 	$pas = $p->boucles[$b]->total_parties;
@@ -616,9 +623,12 @@  discard block
 block discarded – undo
616 623
 // qu'on mettra les liens en-dessous de la liste paginee)
617 624
 // http://doc.spip.org/@balise_ANCRE_PAGINATION_dist
618 625
 function balise_ANCRE_PAGINATION_dist($p) {
619
-	if ($f = charger_fonction('PAGINATION', 'balise', true))
620
-		return $f($p, $liste='false');
621
-	else return NULL; // ou une erreur ?
626
+	if ($f = charger_fonction('PAGINATION', 'balise', true)) {
627
+			return $f($p, $liste='false');
628
+	} else {
629
+	    return NULL;
630
+	}
631
+	// ou une erreur ?
622 632
 }
623 633
 
624 634
 // equivalent a #TOTAL_BOUCLE sauf pour les boucles paginees, ou elle
@@ -661,8 +671,9 @@  discard block
 block discarded – undo
661 671
 	if (!$arg) {
662 672
 		$msg = array('zbug_balise_sans_argument',	array('balise' => ' CHEMIN'));
663 673
 		erreur_squelette($msg, $p);
664
-	} else
665
-	  $p->code = 'find_in_path(' . $arg .')';
674
+	} else {
675
+		  $p->code = 'find_in_path(' . $arg .')';
676
+	}
666 677
 
667 678
 	#$p->interdire_scripts = true;
668 679
 	return $p;
@@ -673,7 +684,9 @@  discard block
 block discarded – undo
673 684
 	if (!$arg) {
674 685
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE'));
675 686
 		erreur_squelette($msg, $p);
676
-	} else $p->code = 'chemin_image(' . $arg .')';
687
+	} else {
688
+	    $p->code = 'chemin_image(' . $arg .')';
689
+	}
677 690
 
678 691
 	#$p->interdire_scripts = true;
679 692
 	return $p;
@@ -814,7 +827,9 @@  discard block
 block discarded – undo
814 827
 	if (!$_nom OR !$_val) {
815 828
 		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET'));
816 829
 		erreur_squelette($err_b_s_a, $p);
817
-	} else 	$p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))';
830
+	} else {
831
+	    $p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))';
832
+	}
818 833
 
819 834
 	$p->interdire_scripts = false;
820 835
 
@@ -841,10 +856,11 @@  discard block
 block discarded – undo
841 856
 		# optimisation sur les #EVAL{une expression sans #BALISE}
842 857
 		# attention au commentaire "// x signes" qui precede
843 858
 		if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms",
844
-		$php,$r))
845
-			$p->code = /* $r[1]. */'('.$r[2].')';
846
-		else
847
-			$p->code = "eval('return '.$php.';')";
859
+		$php,$r)) {
860
+					$p->code = /* $r[1]. */'('.$r[2].')';
861
+		} else {
862
+					$p->code = "eval('return '.$php.';')";
863
+		}
848 864
 	} else {
849 865
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL'));
850 866
 		erreur_squelette($msg, $p);
@@ -864,9 +880,9 @@  discard block
 block discarded – undo
864 880
 
865 881
 	if ($p->param
866 882
 	AND isset($p->param[0][1][0])
867
-	AND $champ = ($p->param[0][1][0]->texte))
868
-		$p->code = champ_sql($champ, $p);
869
-	else {
883
+	AND $champ = ($p->param[0][1][0]->texte)) {
884
+			$p->code = champ_sql($champ, $p);
885
+	} else {
870 886
 		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL'));
871 887
 		erreur_squelette($err_b_s_a, $p);
872 888
 	}
@@ -879,8 +895,9 @@  discard block
 block discarded – undo
879 895
 // http://doc.spip.org/@balise_VAL_dist
880 896
 function balise_VAL_dist($p){
881 897
 	$p->code = interprete_argument_balise(1,$p);
882
-	if (!strlen($p->code))
883
-		$p->code = "''";
898
+	if (!strlen($p->code)) {
899
+			$p->code = "''";
900
+	}
884 901
 	$p->interdire_scripts = false;
885 902
 	return $p;
886 903
 }
@@ -943,8 +960,9 @@  discard block
 block discarded – undo
943 960
 function balise_FILTRE_dist($p) {
944 961
 	if ($p->param) {
945 962
 		$args = array();
946
-		foreach ($p->param as $i => $ignore)
947
-			$args[] = interprete_argument_balise($i+1,$p);
963
+		foreach ($p->param as $i => $ignore) {
964
+					$args[] = interprete_argument_balise($i+1,$p);
965
+		}
948 966
 		$p->code = "'<' . '"
949 967
 			.'?php header("X-Spip-Filtre: \'.'
950 968
 				.join('.\'|\'.', $args)
@@ -979,12 +997,13 @@  discard block
 block discarded – undo
979 997
 
980 998
 		// Remplir le header Cache-Control
981 999
 		// cas #CACHE{0}
982
-		if ($duree == 0)
983
-			$code .= '.\'<'
1000
+		if ($duree == 0) {
1001
+					$code .= '.\'<'
984 1002
 			.'?php header("Cache-Control: no-cache, must-revalidate"); ?'
985 1003
 			.'><'
986 1004
 			.'?php header("Pragma: no-cache"); ?'
987 1005
 			.'>\'';
1006
+		}
988 1007
 
989 1008
 		// recuperer les parametres suivants
990 1009
 		$i = 1;
@@ -1001,10 +1020,13 @@  discard block
 block discarded – undo
1001 1020
 			}
1002 1021
 
1003 1022
 			if ($pa == 'statique'
1004
-			AND $duree > 0)
1005
-				$code .= '.\'<'.'?php header("X-Spip-Statique: oui"); ?'.'>\'';
1023
+			AND $duree > 0) {
1024
+							$code .= '.\'<'.'?php header("X-Spip-Statique: oui"); ?'.'>\'';
1025
+			}
1006 1026
 		}
1007
-	} else $code = "''";
1027
+	} else {
1028
+	    $code = "''";
1029
+	}
1008 1030
 	$p->code = $code;
1009 1031
 	$p->interdire_scripts = false;
1010 1032
 	return $p;
@@ -1061,11 +1083,12 @@  discard block
 block discarded – undo
1061 1083
 // (Incompatible avec les balises dynamiques)
1062 1084
 // http://doc.spip.org/@balise_INCLUDE_dist
1063 1085
 function balise_INCLUDE_dist($p) {
1064
-	if(function_exists('balise_INCLURE'))
1065
-		return balise_INCLURE($p);
1066
-	else
1067
-		return balise_INCLURE_dist($p);
1068
-}
1086
+	if(function_exists('balise_INCLURE')) {
1087
+			return balise_INCLURE($p);
1088
+	} else {
1089
+			return balise_INCLURE_dist($p);
1090
+	}
1091
+	}
1069 1092
 // http://doc.spip.org/@balise_INCLURE_dist
1070 1093
 function balise_INCLURE_dist($p) {
1071 1094
 	$id_boucle = $p->id_boucle;
@@ -1077,7 +1100,9 @@  discard block
 block discarded – undo
1077 1100
 
1078 1101
 	// erreur de syntaxe = fond absent
1079 1102
 	// (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
1080
-	if (!$_contexte) $contexte = array();
1103
+	if (!$_contexte) {
1104
+	    $contexte = array();
1105
+	}
1081 1106
 
1082 1107
 	if (isset($_contexte['fond'])) {
1083 1108
 
@@ -1086,7 +1111,9 @@  discard block
 block discarded – undo
1086 1111
 		if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) {
1087 1112
 			$f = $r[1];
1088 1113
 			unset($_contexte['fond']);
1089
-		} else spip_log("compilation de #INCLURE a revoir");
1114
+		} else {
1115
+		    spip_log("compilation de #INCLURE a revoir");
1116
+		}
1090 1117
 
1091 1118
 		// #INCLURE{doublons}
1092 1119
 		if (isset($_contexte['doublons'])) {
@@ -1099,25 +1126,33 @@  discard block
 block discarded – undo
1099 1126
 		) {
1100 1127
 			$flag_env = true;
1101 1128
 			unset($_contexte['env']);
1102
-		} else $flag_env = false;
1129
+		} else {
1130
+		    $flag_env = false;
1131
+		}
1103 1132
 
1104 1133
 		$_options = array();
1105 1134
 		if (isset($_contexte['ajax'])) {
1106 1135
 			$_options[] = preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']);
1107 1136
 			unset($_contexte['ajax']);
1108 1137
 		}
1109
-		if ($p->etoile) $_options[] = "'etoile'=>true";
1138
+		if ($p->etoile) {
1139
+		    $_options[] = "'etoile'=>true";
1140
+		}
1110 1141
 		$_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) .")";
1111 1142
 
1112 1143
 		$_l = 'array(' . join(",\n\t", $_contexte) .')';
1113
-		if ($flag_env) $_l = "array_merge(\$Pile[0],$_l)";
1144
+		if ($flag_env) {
1145
+		    $_l = "array_merge(\$Pile[0],$_l)";
1146
+		}
1114 1147
 
1115 1148
 		$p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',',$_options),"''");
1116 1149
 
1117 1150
 	} elseif (!isset($_contexte[1])) {
1118 1151
 			$msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE'));
1119 1152
 			erreur_squelette($msg, $p);
1120
-	} else 		$p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
1153
+	} else {
1154
+	    $p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
1155
+	}
1121 1156
 
1122 1157
 	$p->interdire_scripts = false; // la securite est assuree par recuperer_fond
1123 1158
 	return $p;
@@ -1131,7 +1166,9 @@  discard block
 block discarded – undo
1131 1166
 
1132 1167
 	// erreur de syntaxe = fond absent
1133 1168
 	// (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
1134
-	if (!$_contexte) $contexte = array();
1169
+	if (!$_contexte) {
1170
+	    $contexte = array();
1171
+	}
1135 1172
 
1136 1173
 	if (!isset($_contexte[1])) {
1137 1174
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE'));
@@ -1140,9 +1177,11 @@  discard block
 block discarded – undo
1140 1177
 		$nom = $_contexte[1];
1141 1178
 		unset($_contexte[1]);
1142 1179
 
1143
-		if (preg_match("/^\s*'[^']*'/s", $nom))
1144
-			$nom = "'modeles/" . substr($nom,1);
1145
-		else $nom = "'modeles/' . $nom";
1180
+		if (preg_match("/^\s*'[^']*'/s", $nom)) {
1181
+					$nom = "'modeles/" . substr($nom,1);
1182
+		} else {
1183
+		    $nom = "'modeles/' . $nom";
1184
+		}
1146 1185
 
1147 1186
 		// Incoherence dans la syntaxe du contexte. A revoir.
1148 1187
 		// Reserver la cle primaire de la boucle courante si elle existe
@@ -1156,8 +1195,9 @@  discard block
 block discarded – undo
1156 1195
 		}
1157 1196
 		$_contexte[] = "'recurs'=>(++\$recurs)";
1158 1197
 		$connect = '';
1159
-		if (isset($p->boucles[$p->id_boucle]))
1160
-			$connect = $p->boucles[$p->id_boucle]->sql_serveur;
1198
+		if (isset($p->boucles[$p->id_boucle])) {
1199
+					$connect = $p->boucles[$p->id_boucle]->sql_serveur;
1200
+		}
1161 1201
 
1162 1202
 		$_options = memoriser_contexte_compil($p);
1163 1203
 		$_options = "'compil'=>array($_options), 'trim'=>true";
@@ -1192,7 +1232,9 @@  discard block
 block discarded – undo
1192 1232
 	}
1193 1233
 	// affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4
1194 1234
 	// cf https://bugs.php.net/bug.php?id=65845
1195
-	else  $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)";
1235
+	else {
1236
+	    $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)";
1237
+	}
1196 1238
 
1197 1239
 	$p->interdire_scripts = false; // la balise ne renvoie rien
1198 1240
 	return $p;
@@ -1206,11 +1248,12 @@  discard block
 block discarded – undo
1206 1248
 // http://doc.spip.org/@balise_GET_dist
1207 1249
 function balise_GET_dist($p) {
1208 1250
 	$p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance
1209
-	if (function_exists('balise_ENV'))
1210
-		return balise_ENV($p, '$Pile["vars"]');
1211
-	else
1212
-		return balise_ENV_dist($p, '$Pile["vars"]');
1213
-}
1251
+	if (function_exists('balise_ENV')) {
1252
+			return balise_ENV($p, '$Pile["vars"]');
1253
+	} else {
1254
+			return balise_ENV_dist($p, '$Pile["vars"]');
1255
+	}
1256
+	}
1214 1257
 
1215 1258
 
1216 1259
 /**
@@ -1230,15 +1273,17 @@  discard block
 block discarded – undo
1230 1273
 **/
1231 1274
 function balise_DOUBLONS_dist($p) {
1232 1275
 	if ($type = interprete_argument_balise(1,$p)) {
1233
-		if ($famille = interprete_argument_balise(2,$p))
1234
-			$type .= '.' . $famille;
1276
+		if ($famille = interprete_argument_balise(2,$p)) {
1277
+					$type .= '.' . $famille;
1278
+		}
1235 1279
 		$p->code = '$doublons['.$type.']';
1236
-		if (!$p->etoile)
1237
-			$p->code = 'array_filter(array_map("intval",explode(",",'
1280
+		if (!$p->etoile) {
1281
+					$p->code = 'array_filter(array_map("intval",explode(",",'
1238 1282
 				. $p->code . ')))';
1283
+		}
1284
+	} else {
1285
+			$p->code = '$doublons';
1239 1286
 	}
1240
-	else
1241
-		$p->code = '$doublons';
1242 1287
 
1243 1288
 	$p->interdire_scripts = false;
1244 1289
 
@@ -1307,7 +1352,9 @@  discard block
 block discarded – undo
1307 1352
 	do {
1308 1353
 		$_key = interprete_argument_balise($n++,$p);
1309 1354
 		$_val = interprete_argument_balise($n++,$p);
1310
-		if ($_key AND $_val) $_code[] = "$_key => $_val";
1355
+		if ($_key AND $_val) {
1356
+		    $_code[] = "$_key => $_val";
1357
+		}
1311 1358
 	} while ($_key && $_val);
1312 1359
 	$p->code = 'array(' . join(', ',$_code).')';
1313 1360
 	$p->interdire_scripts = false;
@@ -1323,8 +1370,9 @@  discard block
 block discarded – undo
1323 1370
 function balise_LISTE_dist($p) {
1324 1371
 	$_code = array();
1325 1372
 	$n=1;
1326
-	while ($_val = interprete_argument_balise($n++,$p))
1327
-		$_code[] = $_val;
1373
+	while ($_val = interprete_argument_balise($n++,$p)) {
1374
+			$_code[] = $_val;
1375
+	}
1328 1376
 	$p->code = 'array(' . join(', ',$_code).')';
1329 1377
 	$p->interdire_scripts = false;
1330 1378
 	return $p;
@@ -1339,8 +1387,9 @@  discard block
 block discarded – undo
1339 1387
 	$p->descr['session'] = true; // faire un cache par session
1340 1388
 
1341 1389
 	$n=1;
1342
-	while ($_v = interprete_argument_balise($n++,$p))
1343
-		$_code[] = $_v;
1390
+	while ($_v = interprete_argument_balise($n++,$p)) {
1391
+			$_code[] = $_v;
1392
+	}
1344 1393
 
1345 1394
 	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',$_code).')?" ":"")';
1346 1395
 	$p->interdire_scripts = false;
@@ -1375,10 +1424,12 @@  discard block
 block discarded – undo
1375 1424
 // avec les hidden de l'url d'action
1376 1425
 // http://doc.spip.org/@balise_ACTION_FORMULAIRE
1377 1426
 function balise_ACTION_FORMULAIRE($p){
1378
-	if (!$_url = interprete_argument_balise(1,$p))
1379
-		$_url = "@\$Pile[0]['action']";
1380
-	if (!$_form = interprete_argument_balise(2,$p))
1381
-		$_form = "@\$Pile[0]['form']";
1427
+	if (!$_url = interprete_argument_balise(1,$p)) {
1428
+			$_url = "@\$Pile[0]['action']";
1429
+	}
1430
+	if (!$_form = interprete_argument_balise(2,$p)) {
1431
+			$_form = "@\$Pile[0]['form']";
1432
+	}
1382 1433
 
1383 1434
 	// envoyer le nom du formulaire que l'on traite
1384 1435
 	// transmettre les eventuels args de la balise formulaire
@@ -1415,12 +1466,15 @@  discard block
 block discarded – undo
1415 1466
 	$args = array();
1416 1467
 	for ($k=1;$k<=6;$k++){
1417 1468
 		$_a = interprete_argument_balise($k,$p);
1418
-		if (!$_a) $_a="''";
1469
+		if (!$_a) {
1470
+		    $_a="''";
1471
+		}
1419 1472
 	  $args[] = $_a;
1420 1473
 	}
1421 1474
 	// supprimer les args vides
1422
-	while(end($args)=="''" AND count($args)>2)
1423
-		array_pop($args);
1475
+	while(end($args)=="''" AND count($args)>2) {
1476
+			array_pop($args);
1477
+	}
1424 1478
 	$args = implode(",",$args);
1425 1479
 
1426 1480
 	$bouton_action = chercher_filtre("bouton_action");
@@ -1532,8 +1586,7 @@  discard block
 block discarded – undo
1532 1586
 	if (!$boucle) {
1533 1587
 		$msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER'));
1534 1588
 		erreur_squelette($msg, $p);
1535
-	}
1536
-	else {
1589
+	} else {
1537 1590
 		$_saut = interprete_argument_balise(1,$p);
1538 1591
 		$_compteur = "\$Numrows['$id_boucle']['compteur_boucle']";
1539 1592
 		$_total = "\$Numrows['$id_boucle']['total']";
@@ -1555,9 +1608,9 @@  discard block
 block discarded – undo
1555 1608
 	if (!$_type = interprete_argument_balise(1,$p)){
1556 1609
 		$_type = _q($p->type_requete);
1557 1610
 		$_id = champ_sql($p->boucles[$p->id_boucle]->primary,$p);
1611
+	} else {
1612
+			$_id = interprete_argument_balise(2,$p);
1558 1613
 	}
1559
-	else
1560
-		$_id = interprete_argument_balise(2,$p);
1561 1614
 
1562 1615
 	$connect = $p->boucles[$p->id_boucle]->sql_serveur;
1563 1616
 
@@ -1599,7 +1652,9 @@  discard block
 block discarded – undo
1599 1652
  */
1600 1653
 function balise_LARGEUR_ECRAN_dist($p){
1601 1654
 	$_class = interprete_argument_balise(1,$p);
1602
-	if (!$_class) $_class='null';
1655
+	if (!$_class) {
1656
+	    $_class='null';
1657
+	}
1603 1658
 	$p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))";
1604 1659
 	return $p;
1605 1660
 }
Please login to merge, or discard this patch.