Completed
Push — spip-3.0 ( 77f3d0...1797f4 )
by cam
17:20 queued 08:11
created
ecrire/public/admin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 if (!function_exists('strripos')) {
23 23
 // http://doc.spip.org/@strripos
24 24
 	function strripos($botte, $aiguille) {
25
-		if (preg_match('@^(.*)' . preg_quote($aiguille, '@') . '@is',
25
+		if (preg_match('@^(.*)'.preg_quote($aiguille, '@').'@is',
26 26
 		$botte, $regs)) { 
27 27
 			return strlen($regs[1]);
28 28
 		}
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 if (!function_exists('stripos')) {
33 33
 // http://doc.spip.org/@stripos
34 34
 	function stripos($botte, $aiguille) {
35
-		if (preg_match('@^(.*)' . preg_quote($aiguille, '@') . '@isU',
35
+		if (preg_match('@^(.*)'.preg_quote($aiguille, '@').'@isU',
36 36
 		$botte, $regs)) { 
37 37
 			return strlen($regs[1]);
38 38
 		}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	. "' type='text/css' />\n";
50 50
 	if ($f = find_in_path('spip_admin_perso.css'))
51 51
 		$css .= "<link rel='stylesheet' href='"
52
-		. url_absolue(direction_css($f)) . "' type='text/css' />\n";
52
+		. url_absolue(direction_css($f))."' type='text/css' />\n";
53 53
 
54 54
 	($pos = stripos($contenu, '</head>'))
55 55
 	    || ($pos = stripos($contenu, '<body>'))
Please login to merge, or discard this patch.
ecrire/public/debusquer.php 1 patch
Spacing   +151 added lines, -154 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
  * @return null|string
64 64
  *     - string si $message à false.
65 65
 **/
66
-function public_debusquer_dist($message = '', $lieu = '', $opt = array()){
66
+function public_debusquer_dist($message = '', $lieu = '', $opt = array()) {
67 67
 	global $visiteur_session;
68 68
 	global $debug_objets;
69 69
 	static $tableau_des_erreurs = array();
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	// Erreur ou appel final ?
83
-	if ($message){
83
+	if ($message) {
84 84
 		$message = debusquer_compose_message($message);
85 85
 		$tableau_des_erreurs[] = array($message, $lieu);
86 86
 		set_request('var_mode', 'debug');
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		if (is_object($lieu) AND (!isset($lieu->code) OR !$lieu->code))
90 90
 			$lieu->code = "''";
91 91
 		// forcer l'appel au debusqueur en cas de boucles infernales
92
-		$urgence = (_DEBUG_MAX_SQUELETTE_ERREURS AND count($tableau_des_erreurs)>_DEBUG_MAX_SQUELETTE_ERREURS);
92
+		$urgence = (_DEBUG_MAX_SQUELETTE_ERREURS AND count($tableau_des_erreurs) > _DEBUG_MAX_SQUELETTE_ERREURS);
93 93
 		if (!$urgence) return;
94 94
 	}
95 95
 	if (empty($debug_objets['principal']))
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	if (ob_get_length()
109 109
 		AND
110 110
 		!in_array('ob_gzhandler', ob_get_status())
111
-	){
111
+	) {
112 112
 		ob_end_clean();
113 113
 	}
114 114
 
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 	if ($tableau_des_erreurs) http_status(503);
127 127
 
128 128
 	http_no_cache();
129
-	if (isset($_GET['var_profile'])){
129
+	if (isset($_GET['var_profile'])) {
130 130
 		$titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', '');
131 131
 		$titre = parametre_url($titre, 'var_mode', '');
132 132
 	}
133 133
 	else {
134 134
 		if (!$fonc) $fonc = $debug_objets['principal'];
135
-		$titre = !$mode ? $fonc : ($mode . ' ' . $debug_objets['sourcefile'][$fonc]);
135
+		$titre = !$mode ? $fonc : ($mode.' '.$debug_objets['sourcefile'][$fonc]);
136 136
 	}
137
-	if ($message===false){
137
+	if ($message === false) {
138 138
 		lang_select();
139 139
 		return debusquer_entete($titre, $res);
140 140
 	}
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 	exit;
144 144
 }
145 145
 
146
-function debusquer_compose_message($msg){
147
-	if (is_array($msg)){
146
+function debusquer_compose_message($msg) {
147
+	if (is_array($msg)) {
148 148
 		// si c'est un texte, c'est une traduction a faire, mais
149 149
 		// sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments)
150
-		if (!is_numeric($msg[0]) AND count($msg)==2) {
150
+		if (!is_numeric($msg[0]) AND count($msg) == 2) {
151 151
 			// message avec argument: instancier
152 152
 			$msg = _T($msg[0], $msg[1], 'spip-debug-arg');
153 153
 		} else {
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 	}
158 158
 	// FIXME: le fond n'est pas la si on n'est pas dans un squelette
159 159
 	// cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur
160
-	$fond = isset($GLOBALS['fond']) ? $GLOBALS['fond']  : "";
160
+	$fond = isset($GLOBALS['fond']) ? $GLOBALS['fond'] : "";
161 161
 	// une erreur critique sort $message en array
162 162
 	$debug = is_array($msg) ? $msg[1] : $msg;
163
-	spip_log("Debug: " . $debug . " (" . $fond . ")");
163
+	spip_log("Debug: ".$debug." (".$fond.")");
164 164
 	return $msg;
165 165
 }
166 166
 
167
-function debusquer_bandeau($erreurs){
167
+function debusquer_bandeau($erreurs) {
168 168
 
169
-	if (!empty($erreurs)){
170
-		$n = array(count($erreurs) . ' ' . _T('zbug_erreur_squelette'));
169
+	if (!empty($erreurs)) {
170
+		$n = array(count($erreurs).' '._T('zbug_erreur_squelette'));
171 171
 		return debusquer_navigation($erreurs, $n);
172 172
 	}
173 173
 	elseif (!empty($GLOBALS['tableau_des_temps'])) {
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 		return '';
180 180
 }
181 181
 
182
-function debusquer_contexte($env){
182
+function debusquer_contexte($env) {
183 183
 
184 184
 	if (is_array($env_tab = @unserialize($env))) $env = $env_tab;
185 185
 
186 186
 	if (!$env) return '';
187 187
 	$res = "";
188
-	foreach ($env as $nom => $valeur){
188
+	foreach ($env as $nom => $valeur) {
189 189
 		if (is_array($valeur))
190
-			$valeur = '(' . count($valeur) . ' items) [' . join(',', $valeur) . ']';
191
-		$res .= "\n<tr><td><strong>" . nl2br(entites_html($nom))
192
-			. "</strong></td><td>:&nbsp;" . nl2br(entites_html($valeur))
190
+			$valeur = '('.count($valeur).' items) ['.join(',', $valeur).']';
191
+		$res .= "\n<tr><td><strong>".nl2br(entites_html($nom))
192
+			. "</strong></td><td>:&nbsp;".nl2br(entites_html($valeur))
193 193
 			. "</td></tr>\n";
194 194
 	}
195 195
 
@@ -199,32 +199,32 @@  discard block
 block discarded – undo
199 199
 // Affichage du tableau des erreurs ou des temps de calcul
200 200
 // Cliquer sur les numeros en premiere colonne permet de voir le code
201 201
 
202
-function debusquer_navigation($tableau, $caption = array(), $id = 'debug-nav'){
202
+function debusquer_navigation($tableau, $caption = array(), $id = 'debug-nav') {
203 203
 
204
-	if (_request('exec')=='valider_xml') return '';
204
+	if (_request('exec') == 'valider_xml') return '';
205 205
 	$GLOBALS['bouton_admin_debug'] = true;
206 206
 	$res = '';
207 207
 	$href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug'));
208
-	foreach ($tableau as $i => $err){
208
+	foreach ($tableau as $i => $err) {
209 209
 		$boucle = $ligne = $skel = '';
210 210
 		list($msg, $lieu) = $err;
211
-		if (is_object($lieu)){
211
+		if (is_object($lieu)) {
212 212
 			$ligne = $lieu->ligne;
213 213
 			$boucle = $lieu->id_boucle ? $lieu->id_boucle : '';
214
-			if (isset($lieu->descr['nom'])){
214
+			if (isset($lieu->descr['nom'])) {
215 215
 				$nom_code = $lieu->descr['nom'];
216 216
 				$skel = $lieu->descr['sourcefile'];
217 217
 				$h2 = parametre_url($href, 'var_mode_objet', $nom_code);
218
-				$h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne;
218
+				$h3 = parametre_url($h2, 'var_mode_affiche', 'squelette').'#L'.$ligne;
219 219
 				$skel = "<a href='$h3'><b>$skel</b></a>";
220
-				if ($boucle){
221
-					$h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle');
220
+				if ($boucle) {
221
+					$h3 = parametre_url($h2.$boucle, 'var_mode_affiche', 'boucle');
222 222
 					$boucle = "<a href='$h3'><b>$boucle</b></a>";
223 223
 				}
224 224
 			}
225 225
 		}
226 226
 
227
-		$j = ($i+1);
227
+		$j = ($i + 1);
228 228
 		$res .= "<tr id='req$j'><td style='text-align: right'>"
229 229
 			. $j
230 230
 			. "&nbsp;</td><td style='text-align: left'>"
@@ -278,22 +278,22 @@  discard block
 block discarded – undo
278 278
  * 		Retourne le texte de l'erreur a afficher
279 279
  * 		ou un tableau si l'erreur est critique
280 280
 **/
281
-function debusquer_requete($message){
281
+function debusquer_requete($message) {
282 282
 	list($errno, $msg, $query) = $message;
283 283
 
284 284
 	// FIXME: ces écritures mélangent divers syntaxe des moteurs SQL
285 285
 	// il serait plus prudent certainement d'avoir une fonction d'analyse par moteur
286
-	if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)){
286
+	if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) {
287 287
 		$errno = $regs[2];
288 288
 	}
289
-	elseif (is_numeric($errno) and ($errno==1030 OR $errno<=1026)
289
+	elseif (is_numeric($errno) and ($errno == 1030 OR $errno <= 1026)
290 290
 		AND preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs)
291 291
 	) {
292 292
 		$errno = $regs[1];
293 293
 	}
294 294
 
295 295
 	// Erreur systeme
296
-	if (is_numeric($errno) and $errno>0 AND $errno<200){
296
+	if (is_numeric($errno) and $errno > 0 AND $errno < 200) {
297 297
 		$retour = "<tt><br /><br /><blink>"
298 298
 			. _T('info_erreur_systeme', array('errsys' => $errno))
299 299
 			. "</blink><br />\n<b>"
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 
307 307
 	// Requete erronee
308
-	$err = "<b>" . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n"
308
+	$err = "<b>"._T('avis_erreur_mysql')." $errno</b><br /><tt>\n"
309 309
 		. spip_htmlspecialchars($msg)
310 310
 		. "\n<br /><span style='color: red'><b>"
311 311
 		. spip_htmlspecialchars($query)
@@ -318,17 +318,17 @@  discard block
 block discarded – undo
318 318
 
319 319
 
320 320
 // http://doc.spip.org/@trouve_boucle_debug
321
-function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = ""){
321
+function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = "") {
322 322
 	global $debug_objets;
323 323
 
324
-	$id = $nom . $boucle;
325
-	if (is_array($debug_objets['sequence'][$id])){
326
-		foreach ($debug_objets['sequence'][$id] as $v){
324
+	$id = $nom.$boucle;
325
+	if (is_array($debug_objets['sequence'][$id])) {
326
+		foreach ($debug_objets['sequence'][$id] as $v) {
327 327
 
328 328
 			if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r))
329 329
 				$y = substr_count($v[0], "\n");
330 330
 			else {
331
-				if ($v[1][0]=='#')
331
+				if ($v[1][0] == '#')
332 332
 					// balise dynamique
333 333
 					$incl = $debug_objets['resultat'][$v[2]];
334 334
 				else
@@ -338,82 +338,79 @@  discard block
 block discarded – undo
338 338
 					+substr_count($r[1], "\n")
339 339
 					+substr_count($r[3], "\n");
340 340
 			}
341
-			if ($n<=($y+$debut)){
342
-				if ($v[1][0]=='?')
341
+			if ($n <= ($y + $debut)) {
342
+				if ($v[1][0] == '?')
343 343
 					return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1));
344
-				elseif ($v[1][0]=='!') {
344
+				elseif ($v[1][0] == '!') {
345 345
 					if ($incl = trouve_squelette_inclus($v[1]))
346 346
 						return trouve_boucle_debug($n, $incl, $debut);
347 347
 				}
348
-				return array($nom, $boucle, $v[2]-1+$n-$debut);
348
+				return array($nom, $boucle, $v[2] - 1 + $n - $debut);
349 349
 			}
350 350
 			$debut += $y;
351 351
 		}
352 352
 	}
353
-	return array($nom, $boucle, $n-$debut);
353
+	return array($nom, $boucle, $n - $debut);
354 354
 }
355 355
 
356 356
 // http://doc.spip.org/@trouve_squelette_inclus
357
-function trouve_squelette_inclus($script){
357
+function trouve_squelette_inclus($script) {
358 358
 	global $debug_objets;
359 359
 	preg_match('/include\(.(.*).php3?.\);/', $script, $reg);
360 360
 	// si le script X.php n'est pas ecrire/public.php
361 361
 	// on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux)
362
-	if ($reg[1]=='ecrire/public')
362
+	if ($reg[1] == 'ecrire/public')
363 363
 		// si c'est bien ecrire/public on cherche le param 'fond'
364 364
 		if (!preg_match("/'fond' => '([^']*)'/", $script, $reg))
365 365
 			// a defaut on cherche le param 'page'
366 366
 			if (!preg_match("/'param' => '([^']*)'/", $script, $reg))
367 367
 				$reg[1] = "inconnu";
368
-	$incl = ',' . $reg[1] . '[.]\w$,';
368
+	$incl = ','.$reg[1].'[.]\w$,';
369 369
 
370
-	foreach ($debug_objets['sourcefile'] as $k => $v){
370
+	foreach ($debug_objets['sourcefile'] as $k => $v) {
371 371
 		if (preg_match($incl, $v)) return $k;
372 372
 	}
373 373
 	return "";
374 374
 }
375 375
 
376 376
 // http://doc.spip.org/@reference_boucle_debug
377
-function reference_boucle_debug($n, $nom, $self){
377
+function reference_boucle_debug($n, $nom, $self) {
378 378
 	list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom);
379 379
 
380 380
 	if (!$boucle)
381
-		return !$ligne ? "" :
382
-			(" (" .
383
-				(($nom!=$skel) ? _T('squelette_inclus_ligne') :
384
-					_T('squelette_ligne')) .
381
+		return !$ligne ? "" : (" (".
382
+				(($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')).
385 383
 				" <a href='$self&amp;var_mode_objet=$skel&amp;var_mode_affiche=squelette&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)");
386 384
 	else {
387 385
 		$self .= "&amp;var_mode_objet=$skel$boucle&amp;var_mode_affiche=boucle";
388 386
 
389
-		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" :
390
-			" (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
387
+		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : " (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
391 388
 	}
392 389
 }
393 390
 
394 391
 // affiche un texte avec numero de ligne et ancre.
395 392
 
396 393
 // http://doc.spip.org/@ancre_texte
397
-function ancre_texte($texte, $fautifs = array(), $nocpt = false){
394
+function ancre_texte($texte, $fautifs = array(), $nocpt = false) {
398 395
 
399 396
 	$var_mode_ligne = _request('var_mode_ligne');
400 397
 	if ($var_mode_ligne) $fautifs[] = array($var_mode_ligne);
401 398
 	$res = '';
402 399
 
403 400
 	$s = highlight_string($texte, true);
404
-	if (substr($s, 0, 6)=='<code>'){
401
+	if (substr($s, 0, 6) == '<code>') {
405 402
 		$s = substr($s, 6);
406 403
 		$res = '<code>';
407 404
 	}
408 405
 
409 406
 	$s = preg_replace(',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,',
410
-		'<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>',
407
+		'<\1>\2</\1><br />'."\n".'<\1>\3</\1>',
411 408
 		$s);
412 409
 
413 410
 
414 411
 	$tableau = explode("<br />", $s);
415 412
 
416
-	$format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n";
413
+	$format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: ".($nocpt ? 'hidden' : 'visible').";%s' href='#T%s' title=\"%s\">%0".strval(@strlen(count($tableau)))."d</a></span> %s<br />\n";
417 414
 
418 415
 	$format10 = str_replace('white', 'lightgrey', $format);
419 416
 	$formaterr = "color: red;";
@@ -421,14 +418,14 @@  discard block
 block discarded – undo
421 418
 	$flignes = array();
422 419
 	$loc = array(0, 0);
423 420
 	foreach ($fautifs as $lc)
424
-		if (is_array($lc)){
421
+		if (is_array($lc)) {
425 422
 			$l = array_shift($lc);
426 423
 			$flignes[$l] = $lc;
427 424
 		} else $flignes[$lc] = $loc;
428 425
 
429 426
 	$ancre = md5($texte);
430
-	foreach ($tableau as $ligne){
431
-		if (isset($flignes[$i])){
427
+	foreach ($tableau as $ligne) {
428
+		if (isset($flignes[$i])) {
432 429
 			$ligne = str_replace('&nbsp;', ' ', $ligne);
433 430
 			$indexmesg = $flignes[$i][1];
434 431
 			$err = textebrut($flignes[$i][2]);
@@ -442,7 +439,7 @@  discard block
 block discarded – undo
442 439
 			$indexmesg = $ancre;
443 440
 			$err = $bg = '';
444 441
 		}
445
-		$res .= sprintf((($i%10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne);
442
+		$res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne);
446 443
 		$i++;
447 444
 	}
448 445
 
@@ -454,31 +451,31 @@  discard block
 block discarded – undo
454 451
 		. '" style="cursor: pointer;">'
455 452
 		. ($nocpt ? '' : _T('info_numero_abbreviation'))
456 453
 		. "</div>
457
-	" . $res . "</div>\n";
454
+	" . $res."</div>\n";
458 455
 }
459 456
 
460 457
 // l'environnement graphique du debuggueur 
461 458
 
462
-function debusquer_squelette($fonc, $mode, $self){
459
+function debusquer_squelette($fonc, $mode, $self) {
463 460
 	global $debug_objets;
464 461
 
465
-	if ($mode!=='validation'){
466
-		if (isset($debug_objets['sourcefile']) and $debug_objets['sourcefile']){
462
+	if ($mode !== 'validation') {
463
+		if (isset($debug_objets['sourcefile']) and $debug_objets['sourcefile']) {
467 464
 			$res = "<div id='spip-boucles'>\n"
468 465
 				. debusquer_navigation_squelettes($self)
469 466
 				. "</div>";
470 467
 		}
471 468
 		else
472 469
 			$res = '';
473
-		if ($fonc){
470
+		if ($fonc) {
474 471
 			$id = " id='$fonc'";
475
-			if (!empty($GLOBALS['debug_objets'][$mode][$fonc])){
472
+			if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) {
476 473
 				list($legend, $texte, $res2) = debusquer_source($fonc, $mode);
477 474
 				$texte .= $res2;
478 475
 			}
479
-			elseif (!empty($debug_objets[$mode][$fonc . 'tout'])) {
480
-				$legend = _T('zbug_' . $mode);
481
-				$texte = $debug_objets[$mode][$fonc . 'tout'];
476
+			elseif (!empty($debug_objets[$mode][$fonc.'tout'])) {
477
+				$legend = _T('zbug_'.$mode);
478
+				$texte = $debug_objets[$mode][$fonc.'tout'];
482 479
 				$texte = ancre_texte($texte, array('', ''));
483 480
 			}
484 481
 		}
@@ -490,17 +487,17 @@  discard block
 block discarded – undo
490 487
 	}
491 488
 	else {
492 489
 		$valider = charger_fonction('valider', 'xml');
493
-		$val = $valider($debug_objets['validation'][$fonc . 'tout']);
490
+		$val = $valider($debug_objets['validation'][$fonc.'tout']);
494 491
 		// Si erreur, signaler leur nombre dans le formulaire admin
495 492
 		$debug_objets['validation'] = $val->err ? count($val->err) : '';
496 493
 		list($texte, $err) = emboite_texte($val, $fonc, $self);
497
-		if ($err===false)
494
+		if ($err === false)
498 495
 			$err = _T('impossible');
499
-		elseif ($err===true)
496
+		elseif ($err === true)
500 497
 			$err = _T('correcte');
501 498
 		else
502 499
 			$err = ": $err";
503
-		$legend = _T('validation') . ' ' . $err;
500
+		$legend = _T('validation').' '.$err;
504 501
 		$res = $id = '';
505 502
 	}
506 503
 	return !trim($texte) ? '' : (
@@ -516,16 +513,16 @@  discard block
 block discarded – undo
516 513
 
517 514
 
518 515
 // http://doc.spip.org/@emboite_texte
519
-function emboite_texte($res, $fonc = '', $self = ''){
516
+function emboite_texte($res, $fonc = '', $self = '') {
520 517
 	$errs = $res->err;
521
-	$texte = $res->entete . ($errs ? '' : $res->page);
518
+	$texte = $res->entete.($errs ? '' : $res->page);
522 519
 
523 520
 	if (!$texte and !$errs)
524 521
 		return array(ancre_texte('', array('', '')), false);
525 522
 	if (!$errs)
526 523
 		return array(ancre_texte($texte, array('', '')), true);
527 524
 
528
-	if (!isset($GLOBALS['debug_objets'])){
525
+	if (!isset($GLOBALS['debug_objets'])) {
529 526
 
530 527
 		$colors = array('#e0e0f0', '#f8f8ff');
531 528
 		$encore = count_occ($errs);
@@ -546,7 +543,7 @@  discard block
 block discarded – undo
546 543
 
547 544
 		$i = 0;
548 545
 		$style = "style='text-align: right; padding-right: 5px'";
549
-		foreach ($errs as $r){
546
+		foreach ($errs as $r) {
550 547
 			$i++;
551 548
 			list($msg, $ligne, $col) = $r;
552 549
 			#spip_log("$r = list($msg, $ligne, $col");
@@ -556,7 +553,7 @@  discard block
 block discarded – undo
556 553
 				$encore2[$msg] = $ref = 1;
557 554
 			}
558 555
 			$err .= "<tr  style='background-color: "
559
-				. $colors[$i%2]
556
+				. $colors[$i % 2]
560 557
 				. "'><td $style><a href='#debut_err'>"
561 558
 				. $i
562 559
 				. "</a></td><td $style>"
@@ -573,7 +570,7 @@  discard block
 block discarded – undo
573 570
 		$err = "<h2 style='text-align: center'>"
574 571
 			. $i
575 572
 			. "<a href='#fin_err'>"
576
-			. " " . _T('erreur_texte')
573
+			. " "._T('erreur_texte')
577 574
 			. "</a></h2><table id='debut_err' style='width: 100%'>"
578 575
 			. $err
579 576
 			. " </table><a id='fin_err'></a>";
@@ -583,17 +580,17 @@  discard block
 block discarded – undo
583 580
 		list($msg, $fermant, $ouvrant) = $errs[0];
584 581
 		$rf = reference_boucle_debug($fermant, $fonc, $self);
585 582
 		$ro = reference_boucle_debug($ouvrant, $fonc, $self);
586
-		$err = $msg .
587
-			"<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" .
588
-			"<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro";
583
+		$err = $msg.
584
+			"<a href='#L".$fermant."'>$fermant</a>$rf<br />".
585
+			"<a href='#L".$ouvrant."'>$ouvrant</a>$ro";
589 586
 		return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err);
590 587
 	}
591 588
 }
592 589
 
593 590
 // http://doc.spip.org/@count_occ
594
-function count_occ($regs){
591
+function count_occ($regs) {
595 592
 	$encore = array();
596
-	foreach ($regs as $r){
593
+	foreach ($regs as $r) {
597 594
 		if (isset($encore[$r[0]]))
598 595
 			$encore[$r[0]]++;
599 596
 		else
@@ -602,14 +599,14 @@  discard block
 block discarded – undo
602 599
 	return $encore;
603 600
 }
604 601
 
605
-function debusquer_navigation_squelettes($self){
602
+function debusquer_navigation_squelettes($self) {
606 603
 	global $debug_objets, $spip_lang_right;
607 604
 
608 605
 	$res = '';
609 606
 	$boucles = !empty($debug_objets['boucle']) ? $debug_objets['boucle'] : '';
610 607
 	$contexte = $debug_objets['contexte'];
611 608
 	$t_skel = _T('squelette');
612
-	foreach ($debug_objets['sourcefile'] as $nom => $sourcefile){
609
+	foreach ($debug_objets['sourcefile'] as $nom => $sourcefile) {
613 610
 		$self2 = parametre_url($self, 'var_mode_objet', $nom);
614 611
 		$nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile);
615 612
 		$temps = !isset($debug_objets['profile'][$sourcefile]) ? '' : _T('zbug_profile', array('time' => $debug_objets['profile'][$sourcefile]));
@@ -637,67 +634,67 @@  discard block
 block discarded – undo
637 634
 	return $res;
638 635
 }
639 636
 
640
-function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source){
637
+function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) {
641 638
 	$i = 0;
642 639
 	$res = '';
643 640
 	$var_mode_objet = _request('var_mode_objet');
644 641
 	$gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : '';
645 642
 
646
-	foreach ($boucles as $objet => $boucle){
647
-		if (substr($objet, 0, strlen($nom_skel))==$nom_skel){
643
+	foreach ($boucles as $objet => $boucle) {
644
+		if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) {
648 645
 			$i++;
649 646
 			$nom = $boucle->id_boucle;
650 647
 			$req = $boucle->type_requete;
651 648
 			$crit = public_decompiler($boucle, $gram, 0, 'criteres');
652
-			$self2 = $self . "&amp;var_mode_objet=" . $objet;
653
-
654
-			$res .= "\n<tr style='background-color: " .
655
-				($i%2 ? '#e0e0f0' : '#f8f8ff') .
656
-				"'><td  align='right'>$i</td><td>\n" .
657
-				"<a  class='debug_link_boucle' href='" .
658
-				$self2 .
659
-				"&amp;var_mode_affiche=boucle#f_$nom_skel'>" .
660
-				_T('zbug_boucle') .
661
-				"</a></td><td>\n<a class='debug_link_boucle' href='" .
662
-				$self2 .
663
-				"&amp;var_mode_affiche=resultat#f_$nom_skel'>" .
664
-				_T('zbug_resultat') .
665
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
666
-				$self2 .
667
-				"&amp;var_mode_affiche=code#f_$nom_skel'>" .
668
-				_T('zbug_code') .
669
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
670
-				str_replace('var_mode=', 'var_profile=', $self2) .
671
-				"'>" .
672
-				_T('zbug_calcul') .
673
-				"</a></td><td>\n" .
674
-				(($var_mode_objet==$objet) ? "<b>$nom</b>" : $nom) .
675
-				"</td><td>\n" .
676
-				$req .
677
-				"</td><td>\n" .
678
-				spip_htmlspecialchars($crit) .
649
+			$self2 = $self."&amp;var_mode_objet=".$objet;
650
+
651
+			$res .= "\n<tr style='background-color: ".
652
+				($i % 2 ? '#e0e0f0' : '#f8f8ff').
653
+				"'><td  align='right'>$i</td><td>\n".
654
+				"<a  class='debug_link_boucle' href='".
655
+				$self2.
656
+				"&amp;var_mode_affiche=boucle#f_$nom_skel'>".
657
+				_T('zbug_boucle').
658
+				"</a></td><td>\n<a class='debug_link_boucle' href='".
659
+				$self2.
660
+				"&amp;var_mode_affiche=resultat#f_$nom_skel'>".
661
+				_T('zbug_resultat').
662
+				"</a></td><td>\n<a class='debug_link_resultat' href='".
663
+				$self2.
664
+				"&amp;var_mode_affiche=code#f_$nom_skel'>".
665
+				_T('zbug_code').
666
+				"</a></td><td>\n<a class='debug_link_resultat' href='".
667
+				str_replace('var_mode=', 'var_profile=', $self2).
668
+				"'>".
669
+				_T('zbug_calcul').
670
+				"</a></td><td>\n".
671
+				(($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom).
672
+				"</td><td>\n".
673
+				$req.
674
+				"</td><td>\n".
675
+				spip_htmlspecialchars($crit).
679 676
 				"</td></tr>";
680 677
 		}
681 678
 	}
682 679
 	return $res;
683 680
 }
684 681
 
685
-function debusquer_source($objet, $affiche){
682
+function debusquer_source($objet, $affiche) {
686 683
 	$quoi = $GLOBALS['debug_objets'][$affiche][$objet];
687 684
 	$nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle;
688 685
 	$res2 = "";
689 686
 
690
-	if ($affiche=='resultat'){
687
+	if ($affiche == 'resultat') {
691 688
 		$legend = $nom;
692 689
 		$req = $GLOBALS['debug_objets']['requete'][$objet];
693
-		if (function_exists('traite_query')){
690
+		if (function_exists('traite_query')) {
694 691
 			$c = strtolower(_request('connect'));
695 692
 			$c = $GLOBALS['connexions'][$c ? $c : 0]['prefixe'];
696 693
 			$req = traite_query($req, '', $c);
697 694
 		}
698 695
 		//  permettre le copier/coller facile
699 696
 		// $res = ancre_texte($req, array(), true);
700
-		$res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n";
697
+		$res = "<div id='T".md5($req)."'>\n<pre>\n".$req."</pre>\n</div>\n";
701 698
 		//  formatage et affichage des resultats bruts de la requete
702 699
 		$ress_req = spip_query($req);
703 700
 		$brut_sql = '';
@@ -705,38 +702,38 @@  discard block
 block discarded – undo
705 702
 		//  eviter l'affichage de milliers de lignes
706 703
 		//  personnalisation possible dans mes_options
707 704
 		$max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50;
708
-		while ($retours_sql = sql_fetch($ress_req)){
709
-			if ($num<=$max_aff){
710
-				$brut_sql .= "<h3>" . ($num==1 ? $num . " sur " . sql_count($ress_req) : $num) . "</h3>";
705
+		while ($retours_sql = sql_fetch($ress_req)) {
706
+			if ($num <= $max_aff) {
707
+				$brut_sql .= "<h3>".($num == 1 ? $num." sur ".sql_count($ress_req) : $num)."</h3>";
711 708
 				$brut_sql .= "<p>";
712
-				foreach ($retours_sql as $key => $val){
713
-					$brut_sql .= "<strong>" . $key . "</strong> => " . spip_htmlspecialchars(couper($val, 150)) . "<br />\n";
709
+				foreach ($retours_sql as $key => $val) {
710
+					$brut_sql .= "<strong>".$key."</strong> => ".spip_htmlspecialchars(couper($val, 150))."<br />\n";
714 711
 				}
715 712
 				$brut_sql .= "</p>";
716 713
 			}
717 714
 			$num++;
718 715
 		}
719 716
 		$res2 = interdire_scripts($brut_sql);
720
-		foreach ($quoi as $view){
717
+		foreach ($quoi as $view) {
721 718
 			//  ne pas afficher les $contexte_inclus
722 719
 			$view = preg_replace(",<\?php.+\?[>],Uims", "", $view);
723
-			if ($view){
724
-				$res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . "</fieldset>";
720
+			if ($view) {
721
+				$res2 .= "\n<br /><fieldset>".interdire_scripts($view)."</fieldset>";
725 722
 			}
726 723
 		}
727 724
 
728 725
 	}
729
-	elseif ($affiche=='code'){
726
+	elseif ($affiche == 'code') {
730 727
 		$legend = $nom;
731
-		$res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">");
728
+		$res = ancre_texte("<"."?php\n".$quoi."\n?".">");
732 729
 	}
733
-	elseif ($affiche=='boucle'){
734
-		$legend = _T('zbug_boucle') . ' ' . $nom;
730
+	elseif ($affiche == 'boucle') {
731
+		$legend = _T('zbug_boucle').' '.$nom;
735 732
 		// Le compilateur prefixe le nom des boucles par l'extension du fichier source.
736 733
 		$gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : '';
737 734
 		$res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle'));
738 735
 	}
739
-	elseif ($affiche=='squelette'){
736
+	elseif ($affiche == 'squelette') {
740 737
 		$legend = $GLOBALS['debug_objets']['sourcefile'][$objet];
741 738
 		$res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]);
742 739
 	}
@@ -745,30 +742,30 @@  discard block
 block discarded – undo
745 742
 }
746 743
 
747 744
 // http://doc.spip.org/@debusquer_entete
748
-function debusquer_entete($titre, $corps){
745
+function debusquer_entete($titre, $corps) {
749 746
 	global $debug_objets;
750 747
 	include_spip('balise/formulaire_admin');
751 748
 	include_spip('public/assembler'); // pour inclure_balise_dynamique
752 749
 	include_spip('inc/texte'); // pour corriger_typo
753 750
 
754
-	return _DOCTYPE_ECRIRE .
755
-		html_lang_attributes() .
756
-		"<head>\n<title>" .
757
-		('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' .
758
-			_T('admin_debug') . ' ' . $titre . ' (' .
759
-			supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) .
760
-		")</title>\n" .
761
-		"<meta http-equiv='Content-Type' content='text/html" .
762
-		(($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') .
763
-		"' />\n" .
751
+	return _DOCTYPE_ECRIRE.
752
+		html_lang_attributes().
753
+		"<head>\n<title>".
754
+		('SPIP '.$GLOBALS['spip_version_affichee'].' '.
755
+			_T('admin_debug').' '.$titre.' ('.
756
+			supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))).
757
+		")</title>\n".
758
+		"<meta http-equiv='Content-Type' content='text/html".
759
+		(($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '').
760
+		"' />\n".
764 761
 		http_script('', 'jquery.js')
765
-		. "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css'))
766
-		. "' type='text/css' />" .
767
-		"</head>\n" .
768
-		"<body style='margin:0 10px;'>\n" .
769
-		"<div id='spip-debug-header'>" .
770
-		$corps .
771
-		inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $debug_objets), false) .
762
+		. "<link rel='stylesheet' href='".url_absolue(find_in_path('spip_admin.css'))
763
+		. "' type='text/css' />".
764
+		"</head>\n".
765
+		"<body style='margin:0 10px;'>\n".
766
+		"<div id='spip-debug-header'>".
767
+		$corps.
768
+		inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $debug_objets), false).
772 769
 		'</div></body></html>';
773 770
 }
774 771
 
Please login to merge, or discard this patch.
ecrire/public/aiguiller.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 if (!defined('_ECRIRE_INC_VERSION')) return;
14 14
 
15 15
 function securiser_redirect_action($redirect) {
16
-	if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect)))
16
+	if ((tester_url_absolue($redirect) or preg_match(',^\w+:,', trim($redirect)))
17 17
 		and !defined('_AUTORISER_ACTION_ABS_REDIRECT')) {
18 18
 		// si l'url est une url du site, on la laisse passer sans rien faire
19 19
 		// c'est encore le plus simple
20 20
 		$base = $GLOBALS['meta']['adresse_site']."/";
21
-		if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0)
21
+		if (strlen($base) AND strncmp($redirect, $base, strlen($base)) == 0)
22 22
 			return $redirect;
23 23
 		$base = url_de_base();
24
-		if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0)
24
+		if (strlen($base) AND strncmp($redirect, $base, strlen($base)) == 0)
25 25
 			return $redirect;
26 26
 		return "";
27 27
 	}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 }
30 30
 
31 31
 // http://doc.spip.org/@traiter_appels_actions
32
-function traiter_appels_actions(){
32
+function traiter_appels_actions() {
33 33
 	// cas de l'appel qui renvoie une redirection (302) ou rien (204)
34 34
 	if ($action = _request('action')) {
35 35
 		include_spip('base/abstract_sql'); // chargement systematique pour les actions
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 		// si l'action est provoque par un hit {ajax}
45 45
 		// il faut transmettre l'env ajax au redirect
46 46
 		// on le met avant dans la query string au cas ou l'action fait elle meme sa redirection
47
-		if (($v=_request('var_ajax'))
48
-		  AND ($v!=='form')
47
+		if (($v = _request('var_ajax'))
48
+		  AND ($v !== 'form')
49 49
 		  AND ($args = _request('var_ajax_env'))
50
-		  AND ($url = _request('redirect'))){
51
-			$url = parametre_url($url,'var_ajax',$v,'&');
52
-			$url = parametre_url($url,'var_ajax_env',$args,'&');
53
-			set_request('redirect',$url);
50
+		  AND ($url = _request('redirect'))) {
51
+			$url = parametre_url($url, 'var_ajax', $v, '&');
52
+			$url = parametre_url($url, 'var_ajax_env', $args, '&');
53
+			set_request('redirect', $url);
54 54
 		}
55
-		else if(_request('redirect')){
56
-			set_request('redirect',securiser_redirect_action(_request('redirect')));
55
+		else if (_request('redirect')) {
56
+			set_request('redirect', securiser_redirect_action(_request('redirect')));
57 57
 		}
58 58
 		$var_f = charger_fonction($action, 'action');
59 59
 		$var_f();
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
 			// si l'action est provoque par un hit {ajax}
68 68
 			// il faut transmettre l'env ajax au redirect 
69 69
 			// qui a pu etre defini par l'action
70
-			if (($v=_request('var_ajax'))
71
-			  AND ($v!=='form')
70
+			if (($v = _request('var_ajax'))
71
+			  AND ($v !== 'form')
72 72
 			  AND ($args = _request('var_ajax_env'))) {
73
-				$url = parametre_url($url,'var_ajax',$v,'&');
74
-				$url = parametre_url($url,'var_ajax_env',$args,'&');
73
+				$url = parametre_url($url, 'var_ajax', $v, '&');
74
+				$url = parametre_url($url, 'var_ajax_env', $args, '&');
75 75
 				// passer l'ancre en variable pour pouvoir la gerer cote serveur
76
-				$url = preg_replace(',#([^#&?]+)$,',"&var_ajax_ancre=\\1",$url);
76
+				$url = preg_replace(',#([^#&?]+)$,', "&var_ajax_ancre=\\1", $url);
77 77
 			}
78
-			$url = str_replace('&amp;','&',$url); // les redirections se font en &, pas en en &amp;
78
+			$url = str_replace('&amp;', '&', $url); // les redirections se font en &, pas en en &amp;
79 79
 			redirige_par_entete($url);
80 80
 		}
81 81
 		if (!headers_sent()
@@ -88,24 +88,24 @@  discard block
 block discarded – undo
88 88
 
89 89
 
90 90
 // http://doc.spip.org/@refuser_traiter_formulaire_ajax
91
-function refuser_traiter_formulaire_ajax(){
92
-	if ($v=_request('var_ajax')
93
-	  AND $v=='form'
91
+function refuser_traiter_formulaire_ajax() {
92
+	if ($v = _request('var_ajax')
93
+	  AND $v == 'form'
94 94
 		AND $form = _request('formulaire_action')
95 95
 		AND $args = _request('formulaire_action_args')
96
-		AND decoder_contexte_ajax($args,$form)!==false) {
96
+		AND decoder_contexte_ajax($args, $form) !== false) {
97 97
 		// on est bien dans le contexte de traitement d'un formulaire en ajax
98 98
 		// mais traiter ne veut pas
99 99
 		// on le dit a la page qui va resumbit
100 100
 		// sans ajax
101 101
 		include_spip('inc/actions');
102
-		ajax_retour('noajax',false);
102
+		ajax_retour('noajax', false);
103 103
 		exit;
104 104
 	}
105 105
 }
106 106
 
107 107
 // http://doc.spip.org/@traiter_appels_inclusions_ajax
108
-function traiter_appels_inclusions_ajax(){
108
+function traiter_appels_inclusions_ajax() {
109 109
 	// traiter les appels de bloc ajax (ex: pagination)
110 110
 	if ($v = _request('var_ajax')
111 111
 	AND $v !== 'form'
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 			include_spip('public/assembler');
118 118
 			$contexte = calculer_contexte();
119 119
 			$contexte = array_merge($args, $contexte);
120
-			$page = recuperer_fond($fond,$contexte,array('trim'=>false));
120
+			$page = recuperer_fond($fond, $contexte, array('trim'=>false));
121 121
 			$texte = $page;
122
-			if ($ancre = _request('var_ajax_ancre')){
122
+			if ($ancre = _request('var_ajax_ancre')) {
123 123
 				// pas n'importe quoi quand meme dans la variable !
124
-				$ancre = str_replace(array('<','"',"'"),array('&lt;','&quot;',''),$ancre);
124
+				$ancre = str_replace(array('<', '"', "'"), array('&lt;', '&quot;', ''), $ancre);
125 125
 				$texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>".$texte;
126 126
 			}
127 127
 		}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 // Le 1er renvoie True si il faut faire exit a la sortie
142 142
 
143 143
 // http://doc.spip.org/@traiter_formulaires_dynamiques
144
-function traiter_formulaires_dynamiques($get=false){
144
+function traiter_formulaires_dynamiques($get = false) {
145 145
 	static $post = array();
146 146
 	static $done = false;
147 147
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		return false; // le hit peut continuer normalement
155 155
 
156 156
 	include_spip('inc/filtres');
157
-	if (($args = decoder_contexte_ajax($args,$form))===false) {
157
+	if (($args = decoder_contexte_ajax($args, $form)) === false) {
158 158
 		spip_log("signature ajax form incorrecte : $form");
159 159
 		return false; // continuons le hit comme si de rien etait
160 160
 	} else {
@@ -168,30 +168,30 @@  discard block
 block discarded – undo
168 168
 
169 169
 		// inclure mes_fonctions et autres filtres avant verifier/traiter
170 170
 		include_spip('public/parametrer');
171
-		$verifier = charger_fonction("verifier","formulaires/$form/",true);
171
+		$verifier = charger_fonction("verifier", "formulaires/$form/", true);
172 172
 		$post["erreurs_$form"] = pipeline(
173 173
 				  'formulaire_verifier',
174 174
 					array(
175
-						'args'=>array('form'=>$form,'args'=>$args),
176
-						'data'=>$verifier?call_user_func_array($verifier,$args):array())
175
+						'args'=>array('form'=>$form, 'args'=>$args),
176
+						'data'=>$verifier ? call_user_func_array($verifier, $args) : array())
177 177
 					);
178 178
 		// si on ne demandait qu'une verif json
179
-		if (_request('formulaire_action_verifier_json')){
179
+		if (_request('formulaire_action_verifier_json')) {
180 180
 			include_spip('inc/json');
181 181
 			include_spip('inc/actions');
182
-			ajax_retour(json_encode($post["erreurs_$form"]),'text/plain');
182
+			ajax_retour(json_encode($post["erreurs_$form"]), 'text/plain');
183 183
 			return true; // on a fini le hit
184 184
 		}
185 185
 		$retour = "";
186
-		if ((count($post["erreurs_$form"])==0)){
186
+		if ((count($post["erreurs_$form"]) == 0)) {
187 187
 			$rev = "";
188
-			if ($traiter = charger_fonction("traiter","formulaires/$form/",true))
189
-				$rev = call_user_func_array($traiter,$args);
188
+			if ($traiter = charger_fonction("traiter", "formulaires/$form/", true))
189
+				$rev = call_user_func_array($traiter, $args);
190 190
 
191 191
 			$rev = pipeline(
192 192
 				  'formulaire_traiter',
193 193
 					array(
194
-						'args'=>array('form'=>$form,'args'=>$args),
194
+						'args'=>array('form'=>$form, 'args'=>$args),
195 195
 						'data'=>$rev)
196 196
 					);
197 197
 			// le retour de traiter peut avoir 3 formats
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 			// en y passant l'id de l'objet cree/modifie
203 203
 			// si message_erreur est present, on considere que le traitement a echoue
204 204
 			// cas du message texte simple
205
-			if (!is_array($rev)){
205
+			if (!is_array($rev)) {
206 206
 				$post["message_ok_$form"] = $rev;
207 207
 			}
208 208
 			// cas du tableau deux valeurs simple (ancien format, deconseille)
209
-			elseif (count($rev)==2 
210
-			  AND !array_key_exists('message_ok',$rev)
211
-			  AND !array_key_exists('message_erreur',$rev)
212
-			  AND !array_key_exists('redirect',$rev)) {
209
+			elseif (count($rev) == 2 
210
+			  AND !array_key_exists('message_ok', $rev)
211
+			  AND !array_key_exists('message_erreur', $rev)
212
+			  AND !array_key_exists('redirect', $rev)) {
213 213
 				$post["editable_$form"] = reset($rev);
214 214
 				$post["message_ok_$form"] = end($rev);
215 215
 			}
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 						$post["editable_$form"] = $rev['editable'];
229 229
 					// si une redirection est demandee, appeler redirigae_formulaire qui choisira
230 230
 					// le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue)
231
-					if (isset($rev['redirect']) AND $rev['redirect']){
231
+					if (isset($rev['redirect']) AND $rev['redirect']) {
232 232
 						include_spip('inc/headers');
233
-						list($masque,$message) = redirige_formulaire($rev['redirect'], '','ajaxform');
233
+						list($masque, $message) = redirige_formulaire($rev['redirect'], '', 'ajaxform');
234 234
 						$post["message_ok_$form"] .= $message;
235 235
 						$retour .= $masque;
236 236
 					}
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
 			}
239 239
 		}
240 240
 		// si le formulaire a ete soumis en ajax, on le renvoie direct !
241
-		if (_request('var_ajax')){
242
-			if (find_in_path('formulaire_.php','balise/',true)) {
241
+		if (_request('var_ajax')) {
242
+			if (find_in_path('formulaire_.php', 'balise/', true)) {
243 243
 				include_spip('inc/actions');
244 244
 				include_spip('public/assembler');
245
-				array_unshift($args,$form);
246
-				$retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn',$args),false);
245
+				array_unshift($args, $form);
246
+				$retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn', $args), false);
247 247
 				// on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7
248 248
 				// sans cela le formulaire n'est pas actif apres le hit ajax
249 249
 				$retour = "<br class='bugajaxie' style='display:none;'/>".$retour;
250
-				ajax_retour($retour,false);
250
+				ajax_retour($retour, false);
251 251
 				return true; // on a fini le hit
252 252
 			}
253 253
 		}
Please login to merge, or discard this patch.
ecrire/public/sandbox.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
  * @param Object $p
26 26
  * @return string
27 27
  */
28
-function sandbox_composer_texte($texte, &$p){
29
-	$code = "'".str_replace(array("\\","'"),array("\\\\","\\'"), $texte)."'";
28
+function sandbox_composer_texte($texte, &$p) {
29
+	$code = "'".str_replace(array("\\", "'"), array("\\\\", "\\'"), $texte)."'";
30 30
 	return $code;
31 31
 }
32 32
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
  * @param Object $p
41 41
  * @return string
42 42
  */
43
-function sandbox_composer_filtre($fonc, $code, $arglist, &$p){
43
+function sandbox_composer_filtre($fonc, $code, $arglist, &$p) {
44 44
 	if (isset($GLOBALS['spip_matrice'][$fonc])) {
45 45
 		$code = "filtrer('$fonc',$code$arglist)";
46 46
 	}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
  * @param array $_contexte
90 90
  * @return string
91 91
  */
92
-function sandbox_composer_inclure_php($fichier, &$p, $_contexte){
92
+function sandbox_composer_inclure_php($fichier, &$p, $_contexte) {
93 93
 	$compil = texte_script(memoriser_contexte_compil($p));
94 94
 	// si inexistant, on essaiera a l'execution
95 95
 	if ($path = find_in_path($fichier))
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  * @param Object $p
107 107
  * @return string
108 108
  */
109
-function sandbox_composer_interdire_scripts($code, &$p){
109
+function sandbox_composer_interdire_scripts($code, &$p) {
110 110
 	// Securite
111 111
 	if ($p->interdire_scripts
112 112
 	AND $p->etoile != '**') {
@@ -132,19 +132,19 @@  discard block
 block discarded – undo
132 132
  * @param array ...
133 133
  * @return mixed|string
134 134
  */
135
-function sandbox_filtrer_squelette($skel, $corps, $filtres){
135
+function sandbox_filtrer_squelette($skel, $corps, $filtres) {
136 136
 	$series_filtres = func_get_args();
137
-	array_shift($series_filtres);// skel
138
-	array_shift($series_filtres);// corps
137
+	array_shift($series_filtres); // skel
138
+	array_shift($series_filtres); // corps
139 139
 
140 140
 	// proteger les <INCLUDE> et tous les morceaux de php licites
141 141
 	if ($skel['process_ins'] == 'php')
142
-		$corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS','echapper_php_callback', $corps);
142
+		$corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps);
143 143
 
144 144
 	// recuperer les couples de remplacement
145 145
 	$replace = echapper_php_callback();
146 146
 
147
-	foreach($series_filtres as $filtres){
147
+	foreach ($series_filtres as $filtres) {
148 148
 		if (count($filtres))
149 149
 			foreach ($filtres as $filtre) {
150 150
 				if ($filtre AND $f = chercher_filtre($filtre))
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	}
154 154
 
155 155
 	// restaurer les echappements
156
-	return str_replace($replace[0],$replace[1],$corps);
156
+	return str_replace($replace[0], $replace[1], $corps);
157 157
 }
158 158
 
159 159
 
160 160
 // http://doc.spip.org/@echapper_php_callback
161
-function echapper_php_callback($r=null) {
161
+function echapper_php_callback($r = null) {
162 162
 	static $src = array();
163 163
 	static $dst = array();
164 164
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 	// si on recoit pas un tableau, on renvoit les couples de substitution
173 173
 	// et on RAZ les remplacements
174
-	$r = array($src,$dst);
174
+	$r = array($src, $dst);
175 175
 	$src = $dst = array();
176 176
 	return $r;
177 177
 }
Please login to merge, or discard this patch.
ecrire/public/boucles.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 // http://doc.spip.org/@boucle_HIERARCHIE_dist
43 43
 function boucle_HIERARCHIE_dist($id_boucle, &$boucles) {
44 44
 	$boucle = &$boucles[$id_boucle];
45
-	$id_table = $boucle->id_table . ".id_rubrique";
45
+	$id_table = $boucle->id_table.".id_rubrique";
46 46
 
47 47
 	// Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille
48 48
 	// sauf en presence du critere {tout} (vu par phraser_html)
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 	. ")))\n\t\treturn '';\n\t"
54 54
 	. "include_spip('inc/rubriques');\n\t"
55 55
 	. '$hierarchie = calcul_hierarchie_in($id_rubrique,'
56
-	. (isset($boucle->modificateur['tout']) ? 'true':'false')
56
+	. (isset($boucle->modificateur['tout']) ? 'true' : 'false')
57 57
 	. ");\n\t"
58 58
 	. 'if (!$hierarchie) return "";'."\n\t";
59 59
 
60
-	$boucle->where[]= array("'IN'", "'$id_table'", '"($hierarchie)"');
60
+	$boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"');
61 61
 
62 62
 	$order = "FIELD($id_table, \$hierarchie)";
63 63
 	if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC")
Please login to merge, or discard this patch.
ecrire/public/criteres.php 1 patch
Spacing   +223 added lines, -231 removed lines patch added patch discarded remove patch
@@ -44,13 +44,12 @@  discard block
 block discarded – undo
44 44
  * @return
45 45
  *     AST complété de la gestion du critère
46 46
 **/
47
-function critere_racine_dist($idb, &$boucles, $crit){
47
+function critere_racine_dist($idb, &$boucles, $crit) {
48 48
 	global $exceptions_des_tables;
49 49
 	$not = $crit->not;
50 50
 	$boucle = &$boucles[$idb];
51 51
 	$id_parent = isset($exceptions_des_tables[$boucle->id_table]['id_parent']) ?
52
-		$exceptions_des_tables[$boucle->id_table]['id_parent'] :
53
-		'id_parent';
52
+		$exceptions_des_tables[$boucle->id_table]['id_parent'] : 'id_parent';
54 53
 
55 54
 	$c = array("'='", "'$boucle->id_table."."$id_parent'", 0);
56 55
 	$boucle->where[] = ($crit->not ? array("'NOT'", $c) : $c);
@@ -73,7 +72,7 @@  discard block
 block discarded – undo
73 72
  * @return
74 73
  *     AST complété de la gestion du critère
75 74
 **/
76
-function critere_exclus_dist($idb, &$boucles, $crit){
75
+function critere_exclus_dist($idb, &$boucles, $crit) {
77 76
 	$not = $crit->not;
78 77
 	$boucle = &$boucles[$idb];
79 78
 	$id = $boucle->primary;
@@ -104,24 +103,24 @@  discard block
 block discarded – undo
104 103
  * @return
105 104
  * 		AST complété de la gestion du critère
106 105
 **/
107
-function critere_doublons_dist($idb, &$boucles, $crit){
106
+function critere_doublons_dist($idb, &$boucles, $crit) {
108 107
 	$boucle = &$boucles[$idb];
109 108
 	$primary = $boucle->primary;
110 109
 
111 110
 	// la table nécessite une clé primaire, non composée
112
-	if (!$primary OR strpos($primary, ',')){
111
+	if (!$primary OR strpos($primary, ',')) {
113 112
 		return (array('zbug_doublon_sur_table_sans_cle_primaire'));
114 113
 	}
115 114
 
116 115
 	$not = ($crit->not ? '' : 'NOT');
117 116
 
118 117
 	// le doublon s'applique sur un type de boucle (article)
119
-	$nom = "'" . $boucle->type_requete. "'";
118
+	$nom = "'".$boucle->type_requete."'";
120 119
 
121 120
 	// compléter le nom avec un nom précisé {doublons nom}
122 121
 	// on obtient $nom = "'article' . 'nom'"
123 122
 	if (isset($crit->param[0])) {
124
-		$nom .= "." . calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent);
123
+		$nom .= ".".calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent);
125 124
 	}
126 125
 
127 126
 	// code qui déclarera l'index du stockage de nos doublons (pour éviter une notice PHP)
@@ -136,10 +135,10 @@  discard block
 block discarded – undo
136 135
 	$debut_in = "sql_in('".$boucle->id_table.'.'.$primary."', ";
137 136
 	// lecture des données du doublon "$doublons[$doublon_index[] = "
138 137
 	// Attention : boucle->doublons désigne une variable qu'on affecte
139
-	$debut_doub = '$doublons[' . (!$not ? '' : ($boucle->doublons."[]= "));
138
+	$debut_doub = '$doublons['.(!$not ? '' : ($boucle->doublons."[]= "));
140 139
 
141 140
 	// le debut complet du code des doublons
142
-	$debut_doub = $debut_in . $debut_doub;
141
+	$debut_doub = $debut_in.$debut_doub;
143 142
 
144 143
 	// nom du doublon "('article' . 'nom')]"
145 144
 	$fin_doub = "($nom)]";
@@ -147,23 +146,23 @@  discard block
 block discarded – undo
147 146
 	// si on trouve un autre critère doublon,
148 147
 	// on fusionne pour avoir un seul IN, et on s'en va !
149 148
 	foreach ($boucle->where as $k => $w) {
150
-		if (strpos($w[0], $debut_doub)===0) {
149
+		if (strpos($w[0], $debut_doub) === 0) {
151 150
 			// fusionner le sql_in (du where)
152
-			$boucle->where[$k][0] = $debut_doub . $fin_doub.' . '.substr($w[0], strlen($debut_in));
151
+			$boucle->where[$k][0] = $debut_doub.$fin_doub.' . '.substr($w[0], strlen($debut_in));
153 152
 			// fusionner l'initialisation (du hash) pour faire plus joli
154 153
 			$x = strpos($boucle->hash, $init_comment);
155 154
 			$len = strlen($init_comment);
156 155
 			$boucle->hash =
157
-				substr($boucle->hash, 0, $x + $len) . $init_code . substr($boucle->hash, $x + $len);
156
+				substr($boucle->hash, 0, $x + $len).$init_code.substr($boucle->hash, $x + $len);
158 157
 			return;
159 158
 		}
160 159
 	}
161 160
 
162 161
 	// mettre l'ensemble dans un tableau pour que ce ne soit pas vu comme une constante
163
-	$boucle->where[] = array($debut_doub . $fin_doub.", '".$not."')");
162
+	$boucle->where[] = array($debut_doub.$fin_doub.", '".$not."')");
164 163
 
165 164
 	// déclarer le doublon s'il n'existe pas encore
166
-	$boucle->hash .= $init_comment . $init_code;
165
+	$boucle->hash .= $init_comment.$init_code;
167 166
 
168 167
 
169 168
 	# la ligne suivante avait l'intention d'eviter une collecte deja faite
@@ -194,9 +193,9 @@  discard block
 block discarded – undo
194 193
  * @return
195 194
  *     AST complété de la gestion du critère
196 195
 **/
197
-function critere_lang_select_dist($idb, &$boucles, $crit){
196
+function critere_lang_select_dist($idb, &$boucles, $crit) {
198 197
 	if (!isset($crit->param[1][0]) OR !($param = $crit->param[1][0]->texte)) $param = 'oui';
199
-	if ($crit->not) $param = ($param=='oui') ? 'non' : 'oui';
198
+	if ($crit->not) $param = ($param == 'oui') ? 'non' : 'oui';
200 199
 	$boucle = &$boucles[$idb];
201 200
 	$boucle->lang_select = $param;
202 201
 }
@@ -204,11 +203,11 @@  discard block
 block discarded – undo
204 203
 // {debut_xxx}
205 204
 // http://www.spip.net/@debut_
206 205
 // http://doc.spip.org/@critere_debut_dist
207
-function critere_debut_dist($idb, &$boucles, $crit){
206
+function critere_debut_dist($idb, &$boucles, $crit) {
208 207
 	list($un, $deux) = $crit->param;
209 208
 	$un = $un[0]->texte;
210 209
 	$deux = $deux[0]->texte;
211
-	if ($deux){
210
+	if ($deux) {
212 211
 		$boucles[$idb]->limit = 'intval($Pile[0]["debut'.
213 212
 		                        $un.
214 213
 		                        '"]) . ",'.
@@ -223,14 +222,14 @@  discard block
 block discarded – undo
223 222
 // {pagination 20 #ENV{truc,chose}} pour utiliser la variable debut_#ENV{truc,chose}
224 223
 // http://www.spip.net/@pagination
225 224
 // http://doc.spip.org/@critere_pagination_dist
226
-function critere_pagination_dist($idb, &$boucles, $crit){
225
+function critere_pagination_dist($idb, &$boucles, $crit) {
227 226
 
228 227
 	$boucle = &$boucles[$idb];
229 228
 	// definition de la taille de la page
230 229
 	$pas = !isset($crit->param[0][0]) ? "''"
231 230
 		: calculer_liste(array($crit->param[0][0]), array(), $boucles, $boucle->id_parent);
232 231
 
233
-	if (!preg_match(_CODE_QUOTE, $pas, $r)){
232
+	if (!preg_match(_CODE_QUOTE, $pas, $r)) {
234 233
 		$pas = "((\$a = intval($pas)) ? \$a : 10)";
235 234
 	} else {
236 235
 		$r = intval($r[2]);
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
 	}
239 238
 	$type = !isset($crit->param[0][1]) ? "'$idb'"
240 239
 		: calculer_liste(array($crit->param[0][1]), array(), $boucles, $boucle->id_parent);
241
-	$debut = ($type[0]!=="'") ? "'debut'.$type"
240
+	$debut = ($type[0] !== "'") ? "'debut'.$type"
242 241
 		: ("'debut".substr($type, 1));
243 242
 
244 243
 	$boucle->modificateur['debut_nom'] = $type;
@@ -252,7 +251,7 @@  discard block
 block discarded – undo
252 251
 		."\t".'$debut_boucle = intval($debut_boucle)';
253 252
 
254 253
 	$boucle->hash .= '
255
-	$command[\'pagination\'] = array((isset($Pile[0]['.$debut.']) ? $Pile[0]['.$debut.'] : null), ' . $pas . ');';
254
+	$command[\'pagination\'] = array((isset($Pile[0]['.$debut.']) ? $Pile[0]['.$debut.'] : null), '.$pas.');';
256 255
 
257 256
 	$boucle->total_parties = $pas;
258 257
 	calculer_parties($boucles, $idb, $partie, 'p+');
@@ -271,12 +270,12 @@  discard block
 block discarded – undo
271 270
 // {recherche} ou {recherche susan}
272 271
 // http://www.spip.net/@recherche
273 272
 // http://doc.spip.org/@critere_recherche_dist
274
-function critere_recherche_dist($idb, &$boucles, $crit){
273
+function critere_recherche_dist($idb, &$boucles, $crit) {
275 274
 
276 275
 	$boucle = &$boucles[$idb];
277 276
 
278
-	if (!$boucle->primary OR strpos($boucle->primary, ',')){
279
-		erreur_squelette(_T('zbug_critere_sur_table_sans_cle_primaire',array('critere'=>'recherche')), $boucle);
277
+	if (!$boucle->primary OR strpos($boucle->primary, ',')) {
278
+		erreur_squelette(_T('zbug_critere_sur_table_sans_cle_primaire', array('critere'=>'recherche')), $boucle);
280 279
 		return;
281 280
 	}
282 281
 
@@ -304,7 +303,7 @@  discard block
 block discarded – undo
304 303
 		$boucle->select[] = $t; # pour postgres, neuneu ici
305 304
 	// jointure uniquement sur le serveur principal
306 305
 	// (on ne peut joindre une table d'un serveur distant avec la table des resultats du serveur principal)
307
-	if (!$boucle->sql_serveur){
306
+	if (!$boucle->sql_serveur) {
308 307
 		$boucle->join['resultats'] = array("'".$boucle->id_table."'", "'id'", "'".$boucle->primary."'");
309 308
 		$boucle->from['resultats'] = 'spip_resultats';
310 309
 	}
@@ -320,7 +319,7 @@  discard block
 block discarded – undo
320 319
 //   (id_trad>0 AND id_trad=id_trad(precedent))
321 320
 //    OR id_article=id_article(precedent)
322 321
 // http://doc.spip.org/@critere_traduction_dist
323
-function critere_traduction_dist($idb, &$boucles, $crit){
322
+function critere_traduction_dist($idb, &$boucles, $crit) {
324 323
 	$boucle = &$boucles[$idb];
325 324
 	$prim = $boucle->primary;
326 325
 	$table = $boucle->id_table;
@@ -343,7 +342,7 @@  discard block
 block discarded – undo
343 342
 //   (id_trad>0 AND id_article=id_trad) OR (id_trad=0)
344 343
 // http://www.spip.net/@origine_traduction
345 344
 // http://doc.spip.org/@critere_origine_traduction_dist
346
-function critere_origine_traduction_dist($idb, &$boucles, $crit){
345
+function critere_origine_traduction_dist($idb, &$boucles, $crit) {
347 346
 	$boucle = &$boucles[$idb];
348 347
 	$prim = $boucle->primary;
349 348
 	$table = $boucle->id_table;
@@ -359,16 +358,15 @@  discard block
 block discarded – undo
359 358
 // {meme_parent}
360 359
 // http://www.spip.net/@meme_parent
361 360
 // http://doc.spip.org/@critere_meme_parent_dist
362
-function critere_meme_parent_dist($idb, &$boucles, $crit){
361
+function critere_meme_parent_dist($idb, &$boucles, $crit) {
363 362
 	global $exceptions_des_tables;
364 363
 	$boucle = &$boucles[$idb];
365 364
 	$arg = kwote(calculer_argument_precedent($idb, 'id_parent', $boucles));
366 365
 	$id_parent = isset($exceptions_des_tables[$boucle->id_table]['id_parent']) ?
367
-		$exceptions_des_tables[$boucle->id_table]['id_parent'] :
368
-		'id_parent';
366
+		$exceptions_des_tables[$boucle->id_table]['id_parent'] : 'id_parent';
369 367
 	$mparent = $boucle->id_table.'.'.$id_parent;
370 368
 
371
-	if ($boucle->type_requete=='rubriques' OR isset($exceptions_des_tables[$boucle->id_table]['id_parent'])){
369
+	if ($boucle->type_requete == 'rubriques' OR isset($exceptions_des_tables[$boucle->id_table]['id_parent'])) {
372 370
 		$boucle->where[] = array("'='", "'$mparent'", $arg);
373 371
 
374 372
 	}
@@ -398,7 +396,7 @@  discard block
 block discarded – undo
398 396
  * 		AST complété de la condition where au niveau de la boucle,
399 397
  * 		restreignant celle ci aux rubriques de la branche
400 398
 **/
401
-function critere_branche_dist($idb, &$boucles, $crit){
399
+function critere_branche_dist($idb, &$boucles, $crit) {
402 400
 
403 401
 	$not = $crit->not;
404 402
 	$boucle = &$boucles[$idb];
@@ -408,11 +406,11 @@  discard block
 block discarded – undo
408 406
 	$champ = "id_rubrique";
409 407
 	$desc = $boucle->show;
410 408
 	//Seulement si necessaire
411
-	if (!array_key_exists($champ, $desc['field'])){
409
+	if (!array_key_exists($champ, $desc['field'])) {
412 410
 		$cle = trouver_jointure_champ($champ, $boucle);
413 411
 		$trouver_table = charger_fonction("trouver_table", "base");
414 412
 		$desc = $trouver_table($boucle->from[$cle]);
415
-		if (count(trouver_champs_decomposes($champ, $desc))>1){
413
+		if (count(trouver_champs_decomposes($champ, $desc)) > 1) {
416 414
 			$decompose = decompose_champ_id_objet($champ);
417 415
 			$champ = array_shift($decompose);
418 416
 			$boucle->where[] = array("'='", _q($cle.".".reset($decompose)), '"'.sql_quote(end($decompose)).'"');
@@ -422,13 +420,12 @@  discard block
 block discarded – undo
422 420
 
423 421
 	$c = "sql_in('$cle".".$champ', calcul_branche_in($arg)"
424 422
 	     .($not ? ", 'NOT'" : '').")";
425
-	$boucle->where[] = !$crit->cond ? $c :
426
-		("($arg ? $c : ".($not ? "'0=1'" : "'1=1'").')');
423
+	$boucle->where[] = !$crit->cond ? $c : ("($arg ? $c : ".($not ? "'0=1'" : "'1=1'").')');
427 424
 }
428 425
 
429 426
 // {logo} liste les objets qui ont un logo
430 427
 // http://doc.spip.org/@critere_logo_dist
431
-function critere_logo_dist($idb, &$boucles, $crit){
428
+function critere_logo_dist($idb, &$boucles, $crit) {
432 429
 
433 430
 	$not = $crit->not;
434 431
 	$boucle = &$boucles[$idb];
@@ -448,12 +445,12 @@  discard block
 block discarded – undo
448 445
 // c'est la commande SQL "GROUP BY"
449 446
 // par exemple <boucle(articles){fusion lang}>
450 447
 // http://doc.spip.org/@critere_fusion_dist
451
-function critere_fusion_dist($idb, &$boucles, $crit){
452
-	if ($t = isset($crit->param[0])){
448
+function critere_fusion_dist($idb, &$boucles, $crit) {
449
+	if ($t = isset($crit->param[0])) {
453 450
 		$t = $crit->param[0];
454
-		if ($t[0]->type=='texte'){
451
+		if ($t[0]->type == 'texte') {
455 452
 			$t = $t[0]->texte;
456
-			if (preg_match("/^(.*)\.(.*)$/", $t, $r)){
453
+			if (preg_match("/^(.*)\.(.*)$/", $t, $r)) {
457 454
 				$t = table_objet_sql($r[1]);
458 455
 				$t = array_search($t, $boucles[$idb]->from);
459 456
 				if ($t) $t .= '.'.$r[2];
@@ -464,7 +461,7 @@  discard block
 block discarded – undo
464 461
 			     .'."';
465 462
 		}
466 463
 	}
467
-	if ($t){
464
+	if ($t) {
468 465
 		$boucles[$idb]->group[] = $t;
469 466
 		if (!in_array($t, $boucles[$idb]->select))
470 467
 			$boucles[$idb]->select[] = $t;
@@ -475,25 +472,25 @@  discard block
 block discarded – undo
475 472
 // c'est la commande SQL "COLLATE"
476 473
 // qui peut etre appliquee sur les order by, group by, where like ...
477 474
 // http://doc.spip.org/@critere_collecte_dist
478
-function critere_collecte_dist($idb, &$boucles, $crit){
479
-	if (isset($crit->param[0])){
475
+function critere_collecte_dist($idb, &$boucles, $crit) {
476
+	if (isset($crit->param[0])) {
480 477
 		$_coll = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent);
481 478
 		$boucle = $boucles[$idb];
482 479
 		$boucle->modificateur['collate'] = "($_coll ?' COLLATE '.$_coll:'')";
483 480
 		$n = count($boucle->order);
484
-		if ($n && (strpos($boucle->order[$n-1], 'COLLATE')===false))
485
-			$boucle->order[$n-1] .= " . ".$boucle->modificateur['collate'];
481
+		if ($n && (strpos($boucle->order[$n - 1], 'COLLATE') === false))
482
+			$boucle->order[$n - 1] .= " . ".$boucle->modificateur['collate'];
486 483
 	} else
487 484
 		return (array('zbug_critere_inconnu', array('critere' => $crit->op." ".count($boucles[$idb]->order))));
488 485
 }
489 486
 
490 487
 // http://doc.spip.org/@calculer_critere_arg_dynamique
491
-function calculer_critere_arg_dynamique($idb, &$boucles, $crit, $suffix = ''){
488
+function calculer_critere_arg_dynamique($idb, &$boucles, $crit, $suffix = '') {
492 489
 	$boucle = $boucles[$idb];
493 490
 	$alt = "('".$boucle->id_table.'.\' . $x'.$suffix.')';
494 491
 	$var = '$champs_'.$idb;
495
-	$desc = (strpos($boucle->in, "static $var =")!==false);
496
-	if (!$desc){
492
+	$desc = (strpos($boucle->in, "static $var =") !== false);
493
+	if (!$desc) {
497 494
 		$desc = $boucle->show['field'];
498 495
 		$desc = implode(',', array_map('_q', array_keys($desc)));
499 496
 		$boucles[$idb]->in .= "\n\tstatic $var = array(".$desc.");";
@@ -506,22 +503,22 @@  discard block
 block discarded – undo
506 503
 // Tri : {par xxxx}
507 504
 // http://www.spip.net/@par
508 505
 // http://doc.spip.org/@critere_par_dist
509
-function critere_par_dist($idb, &$boucles, $crit){
506
+function critere_par_dist($idb, &$boucles, $crit) {
510 507
 	return critere_parinverse($idb, $boucles, $crit);
511 508
 }
512 509
 
513 510
 // http://doc.spip.org/@critere_parinverse
514
-function critere_parinverse($idb, &$boucles, $crit, $sens = ''){
511
+function critere_parinverse($idb, &$boucles, $crit, $sens = '') {
515 512
 	global $exceptions_des_jointures;
516 513
 	$boucle = &$boucles[$idb];
517 514
 	if ($crit->not) $sens = $sens ? "" : " . ' DESC'";
518 515
 	$collecte = (isset($boucle->modificateur['collecte'])) ? " . ".$boucle->modificateur['collecte'] : "";
519 516
 
520
-	foreach ($crit->param as $tri){
517
+	foreach ($crit->param as $tri) {
521 518
 
522 519
 		$order = $fct = ""; // en cas de fonction SQL
523 520
 		// tris specifies dynamiquement
524
-		if ($tri[0]->type!='texte'){
521
+		if ($tri[0]->type != 'texte') {
525 522
 			// calculer le order dynamique qui verifie les champs
526 523
 			$order = calculer_critere_arg_dynamique($idb, $boucles, $tri, $sens);
527 524
 			// et si ce n'est fait, ajouter un champ 'hasard' 
@@ -534,13 +531,13 @@  discard block
 block discarded – undo
534 531
 			$par = array_shift($tri);
535 532
 			$par = $par->texte;
536 533
 			// par multi champ
537
-			if (preg_match(",^multi[\s]*(.*)$,", $par, $m)){
534
+			if (preg_match(",^multi[\s]*(.*)$,", $par, $m)) {
538 535
 				$champ = trim($m[1]);
539 536
 				// par multi L1.champ
540 537
 				if (strpos($champ, '.')) {
541 538
 					$cle = '';
542 539
 				// par multi champ (champ sur une autre table)
543
-				} elseif (!array_key_exists($champ, $boucle->show['field'])){
540
+				} elseif (!array_key_exists($champ, $boucle->show['field'])) {
544 541
 					$cle = trouver_jointure_champ($champ, $boucle);
545 542
 				// par multi champ (champ dans la table en cours)
546 543
 				} else {
@@ -557,45 +554,45 @@  discard block
 block discarded – undo
557 554
 				if (strpos($champ, '.')) {
558 555
 					$cle = '';
559 556
 				// par num champ (champ sur une autre table)
560
-				} elseif (!array_key_exists($champ, $boucle->show['field'])){
557
+				} elseif (!array_key_exists($champ, $boucle->show['field'])) {
561 558
 					$cle = trouver_jointure_champ($champ, $boucle);
562 559
 				// par num champ (champ dans la table en cours)
563 560
 				} else {
564 561
 					$cle = $boucle->id_table;
565 562
 				}
566 563
 				if ($cle) { $cle .= '.'; }
567
-				$texte = '0+'. $cle . $champ;
564
+				$texte = '0+'.$cle.$champ;
568 565
 				$suite = calculer_liste($tri, array(), $boucles, $boucle->id_parent);
569
-				if ($suite!=="''")
566
+				if ($suite !== "''")
570 567
 					$texte = "\" . ((\$x = $suite) ? ('$texte' . \$x) : '0')"." . \"";
571 568
 				$as = 'num'.($boucle->order ? count($boucle->order) : "");
572 569
 				$boucle->select[] = $texte." AS $as";
573 570
 				$order = "'$as'";
574 571
 			} else {
575
-				if (!preg_match(",^".CHAMP_SQL_PLUS_FONC.'$,is', $par, $match)){
572
+				if (!preg_match(",^".CHAMP_SQL_PLUS_FONC.'$,is', $par, $match)) {
576 573
 					return (array('zbug_critere_inconnu', array('critere' => $crit->op." $par")));
577 574
 				} else {
578
-					if (count($match)>2){
575
+					if (count($match) > 2) {
579 576
 						$par = substr($match[2], 1, -1);
580 577
 						$fct = $match[1];
581 578
 					}
582 579
 					// par hasard
583
-					if ($par=='hasard'){
580
+					if ($par == 'hasard') {
584 581
 						$par = "rand()";
585 582
 						$boucle->select[] = $par." AS alea";
586 583
 						$order = "'alea'";
587 584
 					}
588 585
 						// par titre_mot ou type_mot voire d'autres
589
-					else if (isset($exceptions_des_jointures[$par])){
586
+					else if (isset($exceptions_des_jointures[$par])) {
590 587
 						list($table, $champ) = $exceptions_des_jointures[$par];
591 588
 						$order = critere_par_joint($table, $champ, $boucle, $idb);
592 589
 						if (!$order)
593 590
 							return (array('zbug_critere_inconnu', array('critere' => $crit->op." $par")));
594 591
 					}
595
-					else if ($par=='date'
592
+					else if ($par == 'date'
596 593
 					         AND $desc = $boucle->show
597 594
 					             AND $desc['date']
598
-					){
595
+					) {
599 596
 						$m = $desc['date'];
600 597
 						$order = "'".$boucle->id_table.".".$m."'";
601 598
 					}
@@ -603,10 +600,10 @@  discard block
 block discarded – undo
603 600
 					elseif (preg_match("/^([^,]*)\.(.*)$/", $par, $r)) {
604 601
 						// cas du tri sur champ de jointure explicite
605 602
 						$t = array_search($r[1], $boucle->from);
606
-						if (!$t){
603
+						if (!$t) {
607 604
 							$t = trouver_jointure_champ($r[2], $boucle, array($r[1]));
608 605
 						}
609
-						if (!$t){
606
+						if (!$t) {
610 607
 							return (array('zbug_critere_inconnu', array('critere' => $crit->op." $par")));
611 608
 						} else	 $order = "'".$t.'.'.$r[2]."'";
612 609
 					} else {
@@ -619,14 +616,14 @@  discard block
 block discarded – undo
619 616
 				}
620 617
 			}
621 618
 		}
622
-		if (preg_match('/^\'([^"]*)\'$/', $order, $m)){
619
+		if (preg_match('/^\'([^"]*)\'$/', $order, $m)) {
623 620
 			$t = $m[1];
624
-			if (strpos($t, '.') AND !in_array($t, $boucle->select)){
621
+			if (strpos($t, '.') AND !in_array($t, $boucle->select)) {
625 622
 				$boucle->select[] = $t;
626 623
 			}
627 624
 		} else $sens = '';
628 625
 
629
-		if ($fct){
626
+		if ($fct) {
630 627
 			if (preg_match("/^\s*'(.*)'\s*$/", $order, $r))
631 628
 				$order = "'$fct(".$r[1].")'";
632 629
 			else $order = "'$fct(' . $order . ')'";
@@ -639,7 +636,7 @@  discard block
 block discarded – undo
639 636
 }
640 637
 
641 638
 // http://doc.spip.org/@critere_par_joint
642
-function critere_par_joint($table, $champ, &$boucle, $idb){
639
+function critere_par_joint($table, $champ, &$boucle, $idb) {
643 640
 	$t = array_search($table, $boucle->from);
644 641
 	if (!$t) $t = trouver_jointure_champ($champ, $boucle);
645 642
 	return !$t ? '' : ("'".$t.'.'.$champ."'");
@@ -649,7 +646,7 @@  discard block
 block discarded – undo
649 646
 // http://www.spip.net/@inverse
650 647
 
651 648
 // http://doc.spip.org/@critere_inverse_dist
652
-function critere_inverse_dist($idb, &$boucles, $crit){
649
+function critere_inverse_dist($idb, &$boucles, $crit) {
653 650
 
654 651
 	$boucle = &$boucles[$idb];
655 652
 	// Classement par ordre inverse
@@ -659,31 +656,31 @@  discard block
 block discarded – undo
659 656
 	{
660 657
 		$order = "' DESC'";
661 658
 		// Classement par ordre inverse fonction eventuelle de #ENV{...}
662
-		if (isset($crit->param[0])){
659
+		if (isset($crit->param[0])) {
663 660
 			$critere = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent);
664 661
 			$order = "(($critere)?' DESC':'')";
665 662
 		}
666 663
 
667 664
 		$n = count($boucle->order);
668
-		if (!$n){
665
+		if (!$n) {
669 666
 			if (isset($boucle->default_order[0]))
670 667
 				$boucle->default_order[0] .= ' . " DESC"';
671 668
 			else
672 669
 				$boucle->default_order[] = ' DESC';
673 670
 		} else {
674
-			$t = $boucle->order[$n-1]." . $order";
671
+			$t = $boucle->order[$n - 1]." . $order";
675 672
 			if (preg_match("/^(.*)'\s*\.\s*'([^']*')$/", $t, $r))
676 673
 				$t = $r[1].$r[2];
677
-			$boucle->order[$n-1] = $t;
674
+			$boucle->order[$n - 1] = $t;
678 675
 		}
679 676
 	}
680 677
 }
681 678
 
682 679
 // http://doc.spip.org/@critere_agenda_dist
683
-function critere_agenda_dist($idb, &$boucles, $crit){
680
+function critere_agenda_dist($idb, &$boucles, $crit) {
684 681
 	$params = $crit->param;
685 682
 
686
-	if (count($params)<1)
683
+	if (count($params) < 1)
687 684
 		return (array('zbug_critere_inconnu', array('critere' => $crit->op." ?")));
688 685
 
689 686
 	$parent = $boucles[$idb]->id_parent;
@@ -731,13 +728,13 @@  discard block
 block discarded – undo
731 728
 	$date = $boucle->id_table.".$date";
732 729
 
733 730
 	$quote_end = ",'".$boucle->sql_serveur."','text'";
734
-	if ($type=='jour')
731
+	if ($type == 'jour')
735 732
 		$boucle->where[] = array("'='", "'DATE_FORMAT($date, \'%Y%m%d\')'",
736 733
 		                         ("sql_quote($annee . $mois . $jour$quote_end)"));
737
-	elseif ($type=='mois')
734
+	elseif ($type == 'mois')
738 735
 		$boucle->where[] = array("'='", "'DATE_FORMAT($date, \'%Y%m\')'",
739 736
 		                         ("sql_quote($annee . $mois$quote_end)"));
740
-	elseif ($type=='semaine')
737
+	elseif ($type == 'semaine')
741 738
 		$boucle->where[] = array("'AND'",
742 739
 		                         array("'>='",
743 740
 		                               "'DATE_FORMAT($date, \'%Y%m%d\')'",
@@ -745,7 +742,7 @@  discard block
 block discarded – undo
745 742
 		                         array("'<='",
746 743
 		                               "'DATE_FORMAT($date, \'%Y%m%d\')'",
747 744
 		                               ("date_fin_semaine($annee, $mois, $jour)")));
748
-	elseif (count($crit->param)>2)
745
+	elseif (count($crit->param) > 2)
749 746
 		$boucle->where[] = array("'AND'",
750 747
 		                         array("'>='",
751 748
 		                               "'DATE_FORMAT($date, \'%Y%m%d\')'",
@@ -755,7 +752,7 @@  discard block
 block discarded – undo
755 752
 }
756 753
 
757 754
 // http://doc.spip.org/@calculer_critere_parties
758
-function calculer_critere_parties($idb, &$boucles, $crit){
755
+function calculer_critere_parties($idb, &$boucles, $crit) {
759 756
 	$boucle = &$boucles[$idb];
760 757
 	$a1 = $crit->param[0];
761 758
 	$a2 = $crit->param[1];
@@ -764,20 +761,19 @@  discard block
 block discarded – undo
764 761
 	list($a11, $a12) = calculer_critere_parties_aux($idb, $boucles, $a1);
765 762
 	list($a21, $a22) = calculer_critere_parties_aux($idb, $boucles, $a2);
766 763
 
767
-	if (($op==',') && (is_numeric($a11) && (is_numeric($a21)))){
764
+	if (($op == ',') && (is_numeric($a11) && (is_numeric($a21)))) {
768 765
 		$boucle->limit = $a11.','.$a21;
769 766
 	}
770 767
 	else {
771
-		$boucle->total_parties = ($a21!='n') ? $a21 : $a22;
772
-		$partie = ($a11!='n') ? $a11 : $a12;
773
-		$mode = (($op=='/') ? '/' :
774
-			(($a11=='n') ? '-' : '+').(($a21=='n') ? '-' : '+'));
768
+		$boucle->total_parties = ($a21 != 'n') ? $a21 : $a22;
769
+		$partie = ($a11 != 'n') ? $a11 : $a12;
770
+		$mode = (($op == '/') ? '/' : (($a11 == 'n') ? '-' : '+').(($a21 == 'n') ? '-' : '+'));
775 771
 		// cas simple {0,#ENV{truc}} compilons le en LIMIT :
776
-		if ($a11!=='n' AND $a21!=='n' AND $mode=="++" AND $op==','){
772
+		if ($a11 !== 'n' AND $a21 !== 'n' AND $mode == "++" AND $op == ',') {
777 773
 			$boucle->limit =
778
-				(is_numeric($a11)?"'$a11'":$a11)
774
+				(is_numeric($a11) ? "'$a11'" : $a11)
779 775
 				.".','."
780
-				.(is_numeric($a21)?"'$a21'":$a21);
776
+				.(is_numeric($a21) ? "'$a21'" : $a21);
781 777
 		}
782 778
 		else
783 779
 			calculer_parties($boucles, $idb, $partie, $mode);
@@ -788,38 +784,35 @@  discard block
 block discarded – undo
788 784
 // Code specifique aux criteres {pagination}, {1,n} {n/m} etc
789 785
 //
790 786
 
791
-function calculer_parties(&$boucles, $id_boucle, $debut, $mode){
787
+function calculer_parties(&$boucles, $id_boucle, $debut, $mode) {
792 788
 	$total_parties = $boucles[$id_boucle]->total_parties;
793 789
 
794 790
 	preg_match(",([+-/p])([+-/])?,", $mode, $regs);
795 791
 	list(, $op1, $op2) = array_pad($regs, 3, null);
796 792
 	$nombre_boucle = "\$Numrows['$id_boucle']['total']";
797 793
 	// {1/3}
798
-	if ($op1=='/'){
799
-		$pmoins1 = is_numeric($debut) ? ($debut-1) : "($debut-1)";
800
-		$totpos = is_numeric($total_parties) ? ($total_parties) :
801
-			"($total_parties ? $total_parties : 1)";
794
+	if ($op1 == '/') {
795
+		$pmoins1 = is_numeric($debut) ? ($debut - 1) : "($debut-1)";
796
+		$totpos = is_numeric($total_parties) ? ($total_parties) : "($total_parties ? $total_parties : 1)";
802 797
 		$fin = "ceil(($nombre_boucle * $debut )/$totpos) - 1";
803 798
 		$debut = !$pmoins1 ? 0 : "ceil(($nombre_boucle * $pmoins1)/$totpos);";
804 799
 	} else {
805 800
 		// cas {n-1,x}
806
-		if ($op1=='-') $debut = "$nombre_boucle - $debut;";
801
+		if ($op1 == '-') $debut = "$nombre_boucle - $debut;";
807 802
 
808 803
 		// cas {x,n-1}
809
-		if ($op2=='-'){
804
+		if ($op2 == '-') {
810 805
 			$fin = '$debut_boucle + '.$nombre_boucle.' - '
811
-			       .(is_numeric($total_parties) ? ($total_parties+1) :
812
-					($total_parties.' - 1'));
806
+			       .(is_numeric($total_parties) ? ($total_parties + 1) : ($total_parties.' - 1'));
813 807
 		} else {
814 808
 			// {x,1} ou {pagination}
815 809
 			$fin = '$debut_boucle'
816 810
 			       .(is_numeric($total_parties) ?
817
-					(($total_parties==1) ? "" : (' + '.($total_parties-1))) :
818
-					('+'.$total_parties.' - 1'));
811
+					(($total_parties == 1) ? "" : (' + '.($total_parties - 1))) : ('+'.$total_parties.' - 1'));
819 812
 		}
820 813
 
821 814
 		// {pagination}, gerer le debut_xx=-1 pour tout voir
822
-		if ($op1=='p'){
815
+		if ($op1 == 'p') {
823 816
 			$debut .= ";\n	\$debut_boucle = ((\$tout=(\$debut_boucle == -1))?0:(\$debut_boucle))";
824 817
 			$debut .= ";\n	\$debut_boucle = max(0,min(\$debut_boucle,floor(($nombre_boucle-1)/($total_parties))*($total_parties)))";
825 818
 			$fin = "(\$tout ? $nombre_boucle : $fin)";
@@ -845,8 +838,8 @@  discard block
 block discarded – undo
845 838
 }
846 839
 
847 840
 // http://doc.spip.org/@calculer_critere_parties_aux
848
-function calculer_critere_parties_aux($idb, &$boucles, $param){
849
-	if ($param[0]->type!='texte'){
841
+function calculer_critere_parties_aux($idb, &$boucles, $param) {
842
+	if ($param[0]->type != 'texte') {
850 843
 		$a1 = calculer_liste(array($param[0]), array('id_mere' => $idb), $boucles, $boucles[$idb]->id_parent);
851 844
 		preg_match(',^ *(-([0-9]+))? *$,', $param[1]->texte, $m);
852 845
 		return array("intval($a1)", ($m[2] ? $m[2] : 0));
@@ -885,7 +878,7 @@  discard block
 block discarded – undo
885 878
  *     string : Chaine vide sans erreur
886 879
  *     array : Erreur sur un des critères
887 880
 **/
888
-function calculer_criteres($idb, &$boucles){
881
+function calculer_criteres($idb, &$boucles) {
889 882
 	$msg = '';
890 883
 	$boucle = $boucles[$idb];
891 884
 	$table = strtoupper($boucle->type_requete);
@@ -895,7 +888,7 @@  discard block
 block discarded – undo
895 888
 	// s'il y avait une erreur de syntaxe, propager cette info
896 889
 	if (!is_array($boucle->criteres)) return array();
897 890
 
898
-	foreach ($boucle->criteres as $crit){
891
+	foreach ($boucle->criteres as $crit) {
899 892
 		$critere = $crit->op;
900 893
 		// critere personnalise ?
901 894
 		if (
@@ -910,7 +903,7 @@  discard block
 block discarded – undo
910 903
 			    AND (!function_exists($f = $f."_dist"))
911 904
 			        AND (!function_exists($f = "critere_".$critere))
912 905
 			            AND (!function_exists($f = $f."_dist"))
913
-		){
906
+		) {
914 907
 			// fonction critere standard 
915 908
 			$f = $defaut;
916 909
 		}
@@ -918,7 +911,7 @@  discard block
 block discarded – undo
918 911
 		$res = $f($idb, $boucles, $crit);
919 912
 
920 913
 		// Gestion centralisee des erreurs pour pouvoir propager
921
-		if (is_array($res)){
914
+		if (is_array($res)) {
922 915
 			$msg = $res;
923 916
 			erreur_squelette($msg, $boucle);
924 917
 		}
@@ -937,9 +930,9 @@  discard block
 block discarded – undo
937 930
  * @param string $type
938 931
  * @return string
939 932
  */
940
-function kwote($lisp, $serveur='', $type=''){
933
+function kwote($lisp, $serveur = '', $type = '') {
941 934
 	if (preg_match(_CODE_QUOTE, $lisp, $r))
942
-		return $r[1]."\"".sql_quote(str_replace(array("\\'", "\\\\"), array("'", "\\"), $r[2]),$serveur,$type)."\"";
935
+		return $r[1]."\"".sql_quote(str_replace(array("\\'", "\\\\"), array("'", "\\"), $r[2]), $serveur, $type)."\"";
943 936
 	else
944 937
 		return "sql_quote($lisp)";
945 938
 }
@@ -947,9 +940,9 @@  discard block
 block discarded – undo
947 940
 // Si on a une liste de valeurs dans #ENV{x}, utiliser la double etoile
948 941
 // pour faire par exemple {id_article IN #ENV**{liste_articles}}
949 942
 // http://doc.spip.org/@critere_IN_dist
950
-function critere_IN_dist($idb, &$boucles, $crit){
943
+function critere_IN_dist($idb, &$boucles, $crit) {
951 944
 	$r = calculer_critere_infixe($idb, $boucles, $crit);
952
-	if (!$r){
945
+	if (!$r) {
953 946
 		return (array('zbug_critere_inconnu', array('critere' => $crit->op." ?")));
954 947
 	}
955 948
 	list($arg, $op, $val, $col, $where_complement) = $r;
@@ -958,7 +951,7 @@  discard block
 block discarded – undo
958 951
 
959 952
 	//	inserer la condition; exemple: {id_mot ?IN (66, 62, 64)}
960 953
 	$where = $in;
961
-	if ($crit->cond){
954
+	if ($crit->cond) {
962 955
 		$pred = calculer_argument_precedent($idb, $col, $boucles);
963 956
 		$where = array("'?'", $pred, $where, "''");
964 957
 		if ($where_complement) // condition annexe du type "AND (objet='article')"
@@ -978,15 +971,15 @@  discard block
 block discarded – undo
978 971
 }
979 972
 
980 973
 // http://doc.spip.org/@critere_IN_cas
981
-function critere_IN_cas($idb, &$boucles, $crit2, $arg, $op, $val, $col){
974
+function critere_IN_cas($idb, &$boucles, $crit2, $arg, $op, $val, $col) {
982 975
 	static $num = array();
983 976
 	$descr = $boucles[$idb]->descr;
984 977
 	$cpt = &$num[$descr['nom']][$descr['gram']][$idb];
985 978
 
986 979
 	$var = '$in'.$cpt++;
987 980
 	$x = "\n\t$var = array();";
988
-	foreach ($val as $k => $v){
989
-		if (preg_match(",^(\n//.*\n)?'(.*)'$,", $v, $r)){
981
+	foreach ($val as $k => $v) {
982
+		if (preg_match(",^(\n//.*\n)?'(.*)'$,", $v, $r)) {
990 983
 			// optimiser le traitement des constantes
991 984
 			if (is_numeric($r[2]))
992 985
 				$x .= "\n\t$var"."[]= $r[2];";
@@ -1007,11 +1000,11 @@  discard block
 block discarded – undo
1007 1000
 	// avec une ecriture de type FIELD qui degrade les performances (du meme ordre qu'un rexgexp)
1008 1001
 	// et que l'on limite donc strictement aux cas necessaires :
1009 1002
 	// si ce n'est pas un !IN, et si il n'y a pas d'autre order dans la boucle
1010
-	if (!$crit2){
1003
+	if (!$crit2) {
1011 1004
 		$boucles[$idb]->default_order[] = "((!sql_quote($var) OR sql_quote($var)===\"''\") ? 0 : ('FIELD($arg,' . sql_quote($var) . ')'))";
1012 1005
 	}
1013 1006
 
1014
-	return "sql_in('$arg',sql_quote($var)".($crit2=='NOT' ? ",'NOT'" : "").")";
1007
+	return "sql_in('$arg',sql_quote($var)".($crit2 == 'NOT' ? ",'NOT'" : "").")";
1015 1008
 }
1016 1009
 
1017 1010
 /**
@@ -1022,7 +1015,7 @@  discard block
 block discarded – undo
1022 1015
  * @param <type> $boucles
1023 1016
  * @param <type> $crit
1024 1017
  */
1025
-function critere_where_dist($idb, &$boucles, $crit){
1018
+function critere_where_dist($idb, &$boucles, $crit) {
1026 1019
 	$boucle = &$boucles[$idb];
1027 1020
 	if (isset($crit->param[0]))
1028 1021
 		$_where = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent);
@@ -1084,7 +1077,7 @@  discard block
 block discarded – undo
1084 1077
  * @param unknown_type $boucles
1085 1078
  * @param unknown_type $crit
1086 1079
  */
1087
-function critere_tri_dist($idb, &$boucles, $crit){
1080
+function critere_tri_dist($idb, &$boucles, $crit) {
1088 1081
 	$boucle = &$boucles[$idb];
1089 1082
 
1090 1083
 	// definition du champ par defaut
@@ -1120,13 +1113,13 @@  discard block
 block discarded – undo
1120 1113
 # Criteres de comparaison
1121 1114
 
1122 1115
 // http://doc.spip.org/@calculer_critere_DEFAUT
1123
-function calculer_critere_DEFAUT_dist($idb, &$boucles, $crit){
1116
+function calculer_critere_DEFAUT_dist($idb, &$boucles, $crit) {
1124 1117
 	// double cas particulier {0,1} et {1/2} repere a l'analyse lexicale
1125
-	if (($crit->op==",") OR ($crit->op=='/'))
1118
+	if (($crit->op == ",") OR ($crit->op == '/'))
1126 1119
 		return calculer_critere_parties($idb, $boucles, $crit);
1127 1120
 
1128 1121
 	$r = calculer_critere_infixe($idb, $boucles, $crit);
1129
-	if (!$r){
1122
+	if (!$r) {
1130 1123
 	#	// on produit une erreur seulement si le critere n'a pas de '?'
1131 1124
 	#	if (!$crit->cond) {
1132 1125
 			return (array('zbug_critere_inconnu', array('critere' => $crit->op)));
@@ -1134,7 +1127,7 @@  discard block
 block discarded – undo
1134 1127
 	} else calculer_critere_DEFAUT_args($idb, $boucles, $crit, $r);
1135 1128
 }
1136 1129
 
1137
-function calculer_critere_DEFAUT_args($idb, &$boucles, $crit, $args){
1130
+function calculer_critere_DEFAUT_args($idb, &$boucles, $crit, $args) {
1138 1131
 	list($arg, $op, $val, $col, $where_complement) = $args;
1139 1132
 
1140 1133
 	$where = array("'$op'", "'$arg'", $val[0]);
@@ -1152,15 +1145,15 @@  discard block
 block discarded – undo
1152 1145
 
1153 1146
 	// inserer la condition (cf {lang?})
1154 1147
 	// traiter a part la date, elle est mise d'office par SPIP,
1155
-	if ($crit->cond){
1148
+	if ($crit->cond) {
1156 1149
 		$pred = calculer_argument_precedent($idb, $col, $boucles);
1157
-		if ($col=="date" OR $col=="date_redac"){
1158
-			if ($pred=="\$Pile[0]['".$col."']"){
1150
+		if ($col == "date" OR $col == "date_redac") {
1151
+			if ($pred == "\$Pile[0]['".$col."']") {
1159 1152
 				$pred = "(\$Pile[0]['{$col}_default']?'':$pred)";
1160 1153
 			}
1161 1154
 		}
1162 1155
 
1163
-		if ($op=='=' AND !$crit->not)
1156
+		if ($op == '=' AND !$crit->not)
1164 1157
 			$where = array("'?'", "(is_array($pred))",
1165 1158
 			               critere_IN_cas($idb, $boucles, 'COND', $arg, $op, array($pred), $col),
1166 1159
 			               $where);
@@ -1175,7 +1168,7 @@  discard block
 block discarded – undo
1175 1168
 }
1176 1169
 
1177 1170
 // http://doc.spip.org/@calculer_critere_infixe
1178
-function calculer_critere_infixe($idb, &$boucles, $crit){
1171
+function calculer_critere_infixe($idb, &$boucles, $crit) {
1179 1172
 
1180 1173
 	global $table_criteres_infixes;
1181 1174
 	global $exceptions_des_jointures, $exceptions_des_tables;
@@ -1193,16 +1186,16 @@  discard block
 block discarded – undo
1193 1186
 	$where_complement = false;
1194 1187
 
1195 1188
 	// Cas particulier : id_enfant => utiliser la colonne id_objet
1196
-	if ($col=='id_enfant')
1189
+	if ($col == 'id_enfant')
1197 1190
 		$col = $boucle->primary;
1198 1191
 
1199 1192
 	// Cas particulier : id_parent => verifier les exceptions de tables
1200
-	if (in_array($col,array('id_parent','id_secteur'))
1193
+	if (in_array($col, array('id_parent', 'id_secteur'))
1201 1194
 	  AND isset($exceptions_des_tables[$table][$col]))
1202 1195
 		$col = $exceptions_des_tables[$table][$col];
1203 1196
 
1204 1197
 	// et possibilite de gerer un critere secteur sur des tables de plugins (ie forums)
1205
-	else if (($col=='id_secteur') AND ($critere_secteur = charger_fonction("critere_secteur_$type", "public", true))){
1198
+	else if (($col == 'id_secteur') AND ($critere_secteur = charger_fonction("critere_secteur_$type", "public", true))) {
1206 1199
 		$table = $critere_secteur($idb, $boucles, $val, $crit);
1207 1200
 	}
1208 1201
 
@@ -1211,28 +1204,28 @@  discard block
 block discarded – undo
1211 1204
 	else if (
1212 1205
 		!isset($exceptions_des_jointures[table_objet_sql($table)][$col])
1213 1206
 		AND !isset($exceptions_des_jointures[$col])
1214
-		    AND count(trouver_champs_decomposes($col, $desc))>1
1215
-	){
1207
+		    AND count(trouver_champs_decomposes($col, $desc)) > 1
1208
+	) {
1216 1209
 		$e = decompose_champ_id_objet($col);
1217 1210
 		$col = array_shift($e);
1218 1211
 		$where_complement = primary_doublee($e, $table);
1219 1212
 	}
1220 1213
 		// Cas particulier : expressions de date
1221
-	else if ($c = calculer_critere_infixe_date($idb, $boucles, $col)){
1222
-		list($col,$col_vraie) = $c;
1214
+	else if ($c = calculer_critere_infixe_date($idb, $boucles, $col)) {
1215
+		list($col, $col_vraie) = $c;
1223 1216
 		$table = '';
1224 1217
 	}
1225
-	else if (preg_match('/^(.*)\.(.*)$/', $col, $r)){
1218
+	else if (preg_match('/^(.*)\.(.*)$/', $col, $r)) {
1226 1219
 		list(, $table, $col) = $r;
1227 1220
 		$col_alias = $col;
1228 1221
 
1229
-		$trouver_table = charger_fonction('trouver_table','base');
1222
+		$trouver_table = charger_fonction('trouver_table', 'base');
1230 1223
 		if ($desc = $trouver_table($table, $boucle->sql_serveur)
1231 1224
 		  AND isset($desc['field'][$col])
1232
-		  AND $cle = array_search($desc['table'],$boucle->from))
1225
+		  AND $cle = array_search($desc['table'], $boucle->from))
1233 1226
 			$table = $cle;
1234 1227
 		else {
1235
-			$table = trouver_jointure_champ($col, $boucle, array($table), ($crit->cond OR $op!='='));
1228
+			$table = trouver_jointure_champ($col, $boucle, array($table), ($crit->cond OR $op != '='));
1236 1229
 		}
1237 1230
 		#$table = calculer_critere_externe_init($boucle, array($table), $col, $desc, ($crit->cond OR $op!='='), true);
1238 1231
 		if (!$table) return '';
@@ -1246,18 +1239,18 @@  discard block
 block discarded – undo
1246 1239
 		list($col, $col_alias, $table, $where_complement, $desc) = $r;
1247 1240
 	}
1248 1241
 
1249
-	$col_vraie = ($col_vraie?$col_vraie:$col);
1242
+	$col_vraie = ($col_vraie ? $col_vraie : $col);
1250 1243
 	// Dans tous les cas,
1251 1244
 	// virer les guillemets eventuels autour d'un int (qui sont refuses par certains SQL) et passer dans sql_quote avec le type si connu
1252 1245
 	// et int sinon si la valeur est numerique
1253 1246
 	// sinon introduire le vrai type du champ si connu dans le sql_quote (ou int NOT NULL sinon)
1254 1247
 	// Ne pas utiliser intval, PHP tronquant les Bigint de SQL
1255
-	if ($op=='=' OR in_array($op, $table_criteres_infixes)){
1248
+	if ($op == '=' OR in_array($op, $table_criteres_infixes)) {
1256 1249
 
1257 1250
 		// defaire le quote des int et les passer dans sql_quote avec le bon type de champ si on le connait, int sinon
1258 1251
 		// prendre en compte le debug ou la valeur arrive avec un commentaire PHP en debut
1259 1252
 		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')).'"';
1253
+			$val[0] = $r[1].'"'.sql_quote($r[2], $boucle->sql_serveur, (isset($desc['field'][$col_vraie]) ? $desc['field'][$col_vraie] : 'int NOT NULL')).'"';
1261 1254
 
1262 1255
 		// sinon expliciter les
1263 1256
 		// sql_quote(truc) en sql_quote(truc,'',type)
@@ -1270,16 +1263,16 @@  discard block
 block discarded – undo
1270 1263
 		  AND (!isset($r[3]) OR !$r[3])) {
1271 1264
 			$r = $r[1]
1272 1265
 				.((isset($r[2]) AND $r[2]) ? $r[2] : ",''")
1273
-				.",'".(isset($desc['field'][$col_vraie])?addslashes($desc['field'][$col_vraie]):'int NOT NULL')."'";
1266
+				.",'".(isset($desc['field'][$col_vraie]) ? addslashes($desc['field'][$col_vraie]) : 'int NOT NULL')."'";
1274 1267
 			$val[0] = "sql_quote($r)";
1275 1268
 		}
1276 1269
 	}
1277 1270
 	// Indicateur pour permettre aux fonctionx boucle_X de modifier 
1278 1271
 	// leurs requetes par defaut, notamment le champ statut
1279 1272
 	// Ne pas confondre champs de la table principale et des jointures
1280
-	if ($table===$boucle->id_table){
1273
+	if ($table === $boucle->id_table) {
1281 1274
 		$boucles[$idb]->modificateur['criteres'][$col_vraie] = true;
1282
-		if ($col_alias!=$col_vraie)
1275
+		if ($col_alias != $col_vraie)
1283 1276
 			$boucles[$idb]->modificateur['criteres'][$col_alias] = true;
1284 1277
 	}
1285 1278
 
@@ -1288,11 +1281,11 @@  discard block
 block discarded – undo
1288 1281
 	// de mettre ses propres criteres de statut
1289 1282
 	// http://www.spip.net/@statut (a documenter)
1290 1283
 	// garde pour compatibilite avec code des plugins anterieurs, mais redondant avec la ligne precedente
1291
-	if ($col=='statut') $boucles[$idb]->statut = true;
1284
+	if ($col == 'statut') $boucles[$idb]->statut = true;
1292 1285
 
1293 1286
 	// inserer le nom de la table SQL devant le nom du champ
1294
-	if ($table){
1295
-		if ($col[0]=="`")
1287
+	if ($table) {
1288
+		if ($col[0] == "`")
1296 1289
 			$arg = "$table.".substr($col, 1, -1);
1297 1290
 		else $arg = "$table.$col";
1298 1291
 	} else $arg = $col;
@@ -1303,7 +1296,7 @@  discard block
 block discarded – undo
1303 1296
 	return array($arg, $op, $val, $col_alias, $where_complement);
1304 1297
 }
1305 1298
 
1306
-function calculer_critere_infixe_externe($boucle, $crit, $op, $desc, $col, $col_alias, $table){
1299
+function calculer_critere_infixe_externe($boucle, $crit, $op, $desc, $col, $col_alias, $table) {
1307 1300
 	global $exceptions_des_jointures;
1308 1301
 	$where = '';
1309 1302
 
@@ -1319,17 +1312,17 @@  discard block
 block discarded – undo
1319 1312
 			OR
1320 1313
 			isset($exceptions_des_jointures[$table_sql][''])
1321 1314
 			)
1322
-		){
1315
+		) {
1323 1316
 		$t = $exceptions_des_jointures[$table_sql];
1324 1317
 		$index = isset($t[$col])
1325 1318
 			? $t[$col] : (isset($t['']) ? $t[''] : array());
1326 1319
 
1327
-		if (count($index)==3)
1320
+		if (count($index) == 3)
1328 1321
 			list($t, $col, $calculer_critere_externe) = $index;
1329
-		elseif (count($index)==2) {
1322
+		elseif (count($index) == 2) {
1330 1323
 			list($t, $col) = $t[$col];
1331 1324
 		}
1332
-		elseif (count($index)==1) {
1325
+		elseif (count($index) == 1) {
1333 1326
 			list($calculer_critere_externe) = $index;
1334 1327
 			$t = $table;
1335 1328
 		}
@@ -1348,14 +1341,14 @@  discard block
 block discarded – undo
1348 1341
 	// <BOUCLE_(DOCUMENTS documents_liens){id_mot}>
1349 1342
 	// alors que <BOUCLE_(DOCUMENTS){id_mot}> produit la meme chose que <BOUCLE_(DOCUMENTS mots_liens){id_mot}>
1350 1343
 	$table = "";
1351
-	if ($boucle->jointures_explicites){
1344
+	if ($boucle->jointures_explicites) {
1352 1345
 		$jointures_explicites = explode(' ', $boucle->jointures_explicites);
1353
-		$table = $calculer_critere_externe($boucle, $jointures_explicites, $col, $desc, ($crit->cond OR $op!='='), $t);
1346
+		$table = $calculer_critere_externe($boucle, $jointures_explicites, $col, $desc, ($crit->cond OR $op != '='), $t);
1354 1347
 	}
1355 1348
 
1356 1349
 	// et sinon on cherche parmi toutes les jointures declarees
1357 1350
 	if (!$table) {
1358
-		$table = $calculer_critere_externe($boucle, $boucle->jointures, $col, $desc, ($crit->cond OR $op!='='), $t);
1351
+		$table = $calculer_critere_externe($boucle, $boucle->jointures, $col, $desc, ($crit->cond OR $op != '='), $t);
1359 1352
 	}
1360 1353
 
1361 1354
 	if (!$table) return '';
@@ -1363,7 +1356,7 @@  discard block
 block discarded – undo
1363 1356
 	// il ne reste plus qu'a trouver le champ dans les from
1364 1357
 	list($nom, $desc) = trouver_champ_exterieur($col, $boucle->from, $boucle);
1365 1358
 
1366
-	if (count(trouver_champs_decomposes($col, $desc))>1){
1359
+	if (count(trouver_champs_decomposes($col, $desc)) > 1) {
1367 1360
 		$col_alias = $col; // id_article devient juste le nom d'origine
1368 1361
 		$e = decompose_champ_id_objet($col);
1369 1362
 		$col = array_shift($e);
@@ -1377,7 +1370,7 @@  discard block
 block discarded – undo
1377 1370
 // car on ne connait pas le serveur SQL, donc s'il faut \' ou ''
1378 1371
 
1379 1372
 // http://doc.spip.org/@primary_doublee
1380
-function primary_doublee($decompose, $table){
1373
+function primary_doublee($decompose, $table) {
1381 1374
 	$e1 = reset($decompose);
1382 1375
 	$e2 = "sql_quote('".end($decompose)."')";
1383 1376
 	return array("'='", "'$table.".$e1."'", $e2);
@@ -1402,7 +1395,7 @@  discard block
 block discarded – undo
1402 1395
  * @param bool|string $checkarrivee
1403 1396
  * @return mixed|string
1404 1397
  */
1405
-function calculer_critere_externe_init(&$boucle, $joints, $col, $desc, $cond, $checkarrivee = false){
1398
+function calculer_critere_externe_init(&$boucle, $joints, $col, $desc, $cond, $checkarrivee = false) {
1406 1399
 	// si on demande un truc du genre spip_mots
1407 1400
 	// avec aussi spip_mots_liens dans les jointures dispo
1408 1401
 	// et qu'on est la
@@ -1411,19 +1404,19 @@  discard block
 block discarded – undo
1411 1404
 		AND is_string($checkarrivee)
1412 1405
 	    AND $a = table_objet($checkarrivee)
1413 1406
 	        AND in_array($a.'_liens', $joints)
1414
-	){
1407
+	) {
1415 1408
 		if ($res = calculer_lien_externe_init($boucle, $joints, $col, $desc, $cond, $checkarrivee)) {
1416 1409
 			return $res;
1417 1410
 		}
1418 1411
 	}
1419
-	foreach ($joints as $joint){
1420
-		if ($arrivee = trouver_champ_exterieur($col, array($joint), $boucle, $checkarrivee)){
1412
+	foreach ($joints as $joint) {
1413
+		if ($arrivee = trouver_champ_exterieur($col, array($joint), $boucle, $checkarrivee)) {
1421 1414
 			$t = array_search($arrivee[0], $boucle->from);
1422 1415
 			// transformer eventuellement id_xx en (id_objet,objet)
1423 1416
 			$cols = trouver_champs_decomposes($col, $arrivee[1]);
1424
-			if ($t){
1417
+			if ($t) {
1425 1418
 				$joindre = false;
1426
-				foreach ($cols as $col){
1419
+				foreach ($cols as $col) {
1427 1420
 					$c = '/\b'.$t.".$col".'\b/';
1428 1421
 					if (trouver_champ($c, $boucle->where)) $joindre = true;
1429 1422
 					else {
@@ -1454,7 +1447,7 @@  discard block
 block discarded – undo
1454 1447
  * @param bool $checkarrivee
1455 1448
  * @return string
1456 1449
  */
1457
-function calculer_lien_externe_init(&$boucle, $joints, $col, $desc, $cond, $checkarrivee = false){
1450
+function calculer_lien_externe_init(&$boucle, $joints, $col, $desc, $cond, $checkarrivee = false) {
1458 1451
 	$primary_arrivee = id_table_objet($checkarrivee);
1459 1452
 
1460 1453
 	$intermediaire = trouver_champ_exterieur($primary_arrivee, $joints, $boucle, $checkarrivee."_liens");
@@ -1473,11 +1466,11 @@  discard block
 block discarded – undo
1473 1466
 
1474 1467
 
1475 1468
 // http://doc.spip.org/@trouver_champ
1476
-function trouver_champ($champ, $where){
1469
+function trouver_champ($champ, $where) {
1477 1470
 	if (!is_array($where))
1478 1471
 		return preg_match($champ, $where);
1479 1472
 	else {
1480
-		foreach ($where as $clause){
1473
+		foreach ($where as $clause) {
1481 1474
 			if (trouver_champ($champ, $clause)) return true;
1482 1475
 		}
1483 1476
 		return false;
@@ -1488,18 +1481,18 @@  discard block
 block discarded – undo
1488 1481
 // determine l'operateur et les operandes
1489 1482
 
1490 1483
 // http://doc.spip.org/@calculer_critere_infixe_ops
1491
-function calculer_critere_infixe_ops($idb, &$boucles, $crit){
1484
+function calculer_critere_infixe_ops($idb, &$boucles, $crit) {
1492 1485
 	// cas d'une valeur comparee a elle-meme ou son referent
1493
-	if (count($crit->param)==0){
1486
+	if (count($crit->param) == 0) {
1494 1487
 		$op = '=';
1495 1488
 		$col = $val = $crit->op;
1496 1489
 		if (preg_match('/^(.*)\.(.*)$/', $col, $r)) $val = $r[2];
1497 1490
 		// Cas special {lang} : aller chercher $GLOBALS['spip_lang']
1498
-		if ($val=='lang')
1491
+		if ($val == 'lang')
1499 1492
 			$val = array(kwote('$GLOBALS[\'spip_lang\']'));
1500 1493
 		else {
1501 1494
 			$defaut = null;
1502
-			if ($val=='id_parent') {
1495
+			if ($val == 'id_parent') {
1503 1496
 				// Si id_parent, comparer l'id_parent avec l'id_objet
1504 1497
 				// de la boucle superieure.... faudrait verifier qu'il existe
1505 1498
 				// pour eviter l'erreur SQL
@@ -1507,12 +1500,12 @@  discard block
 block discarded – undo
1507 1500
 				// mais si pas de boucle superieure, prendre id_parent dans l'env
1508 1501
 				$defaut = "\$Pile[0]['id_parent']";
1509 1502
 			}
1510
-			elseif ($val=='id_enfant'){
1503
+			elseif ($val == 'id_enfant') {
1511 1504
 				// Si id_enfant, comparer l'id_objet avec l'id_parent
1512 1505
 				// de la boucle superieure
1513 1506
 				$val = 'id_parent';
1514 1507
 			}
1515
-			elseif ($crit->cond AND ($col=="date" OR $col=="date_redac")){
1508
+			elseif ($crit->cond AND ($col == "date" OR $col == "date_redac")) {
1516 1509
 				// un critere conditionnel sur date est traite a part
1517 1510
 				// car la date est mise d'office par SPIP,
1518 1511
 				$defaut = "(\$Pile[0]['{$col}_default']?'':\$Pile[0]['".$col."'])";
@@ -1526,7 +1519,7 @@  discard block
 block discarded – undo
1526 1519
 		// le phraseur impose que le premier param soit du texte
1527 1520
 		$params = $crit->param;
1528 1521
 		$op = $crit->op;
1529
-		if ($op=='==') $op = 'REGEXP';
1522
+		if ($op == '==') $op = 'REGEXP';
1530 1523
 		$col = array_shift($params);
1531 1524
 		$col = $col[0]->texte;
1532 1525
 
@@ -1537,30 +1530,30 @@  discard block
 block discarded – undo
1537 1530
 		// Dans le cas {x=='#DATE'} etc, defaire le travail du phraseur,
1538 1531
 		// celui ne sachant pas ce qu'est un critere infixe
1539 1532
 		// et a fortiori son 2e operande qu'entoure " ou '
1540
-		if (count($params)==1
1541
-		    AND count($params[0]==3)
1542
-		        AND $params[0][0]->type=='texte'
1543
-		            AND @$params[0][2]->type=='texte'
1544
-		                 AND ($p = $params[0][0]->texte)==$params[0][2]->texte
1545
-		                     AND (($p=="'") OR ($p=='"'))
1546
-		                         AND $params[0][1]->type=='champ'
1547
-		){
1533
+		if (count($params) == 1
1534
+		    AND count($params[0] == 3)
1535
+		        AND $params[0][0]->type == 'texte'
1536
+		            AND @$params[0][2]->type == 'texte'
1537
+		                 AND ($p = $params[0][0]->texte) == $params[0][2]->texte
1538
+		                     AND (($p == "'") OR ($p == '"'))
1539
+		                         AND $params[0][1]->type == 'champ'
1540
+		) {
1548 1541
 			$val[] = "$p\\$p#".$params[0][1]->nom_champ."\\$p$p";
1549 1542
 		} else
1550
-			foreach ((($op!='IN') ? $params : calculer_vieux_in($params)) as $p){
1543
+			foreach ((($op != 'IN') ? $params : calculer_vieux_in($params)) as $p) {
1551 1544
 				$a = calculer_liste($p, $desc, $boucles, $parent);
1552
-				if (strcasecmp($op,'IN')==0) $val[] = $a;
1545
+				if (strcasecmp($op, 'IN') == 0) $val[] = $a;
1553 1546
 				else $val[] = kwote($a, $boucles[$idb]->sql_serveur, 'char'); // toujours quoter en char ici
1554 1547
 			}
1555 1548
 	}
1556 1549
 
1557 1550
 	$fct = $args_sql = '';
1558 1551
 	// fonction SQL ?
1559
-	if (preg_match('/^(.*)'.SQL_ARGS.'$/', $col, $m)){
1552
+	if (preg_match('/^(.*)'.SQL_ARGS.'$/', $col, $m)) {
1560 1553
 		$fct = $m[1];
1561 1554
 		preg_match('/^\(([^,]*)(.*)\)$/', $m[2], $a);
1562 1555
 		$col = $a[1];
1563
-		if (preg_match('/^(\S*)(\s+AS\s+.*)$/i', $col, $m)){
1556
+		if (preg_match('/^(\S*)(\s+AS\s+.*)$/i', $col, $m)) {
1564 1557
 			$col = $m[1];
1565 1558
 			$args_sql = $m[2];
1566 1559
 		}
@@ -1574,28 +1567,28 @@  discard block
 block discarded – undo
1574 1567
 // compatibilite ancienne version
1575 1568
 
1576 1569
 // http://doc.spip.org/@calculer_vieux_in
1577
-function calculer_vieux_in($params){
1570
+function calculer_vieux_in($params) {
1578 1571
 	$deb = $params[0][0];
1579
-	$k = count($params)-1;
1572
+	$k = count($params) - 1;
1580 1573
 	$last = $params[$k];
1581
-	$j = count($last)-1;
1574
+	$j = count($last) - 1;
1582 1575
 	$last = $last[$j];
1583 1576
 	$n = isset($last->texte) ? strlen($last->texte) : 0;
1584 1577
 
1585
-	if (!((isset($deb->texte[0])     AND $deb->texte[0]=='(')
1586
-	   && (isset($last->texte[$n-1]) AND $last->texte[$n-1]==')')))
1578
+	if (!((isset($deb->texte[0]) AND $deb->texte[0] == '(')
1579
+	   && (isset($last->texte[$n - 1]) AND $last->texte[$n - 1] == ')')))
1587 1580
 		return $params;
1588 1581
 	$params[0][0]->texte = substr($deb->texte, 1);
1589 1582
 	// attention, on peut avoir k=0,j=0 ==> recalculer
1590 1583
 	$last = $params[$k][$j];
1591 1584
 	$n = strlen($last->texte);
1592
-	$params[$k][$j]->texte = substr($last->texte, 0, $n-1);
1585
+	$params[$k][$j]->texte = substr($last->texte, 0, $n - 1);
1593 1586
 	$newp = array();
1594
-	foreach ($params as $v){
1595
-		if ($v[0]->type!='texte')
1587
+	foreach ($params as $v) {
1588
+		if ($v[0]->type != 'texte')
1596 1589
 			$newp[] = $v;
1597 1590
 		else {
1598
-			foreach (explode(',', $v[0]->texte) as $x){
1591
+			foreach (explode(',', $v[0]->texte) as $x) {
1599 1592
 				$t = new Texte;
1600 1593
 				$t->texte = $x;
1601 1594
 				$newp[] = array($t);
@@ -1606,17 +1599,17 @@  discard block
 block discarded – undo
1606 1599
 }
1607 1600
 
1608 1601
 // http://doc.spip.org/@calculer_critere_infixe_date
1609
-function calculer_critere_infixe_date($idb, &$boucles, $col){
1602
+function calculer_critere_infixe_date($idb, &$boucles, $col) {
1610 1603
 	if (!preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z]+)?$,", $col, $regs)) return '';
1611 1604
 	$boucle = $boucles[$idb];
1612 1605
 	$table = $boucle->show;
1613 1606
 	// si c'est une colonne de la table, ne rien faire
1614
-	if(isset($table['field'][$col])) return '';
1607
+	if (isset($table['field'][$col])) return '';
1615 1608
 
1616 1609
 	if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) return '';
1617
-	$pred = $date_orig = isset($GLOBALS['table_date'][$table['id_table']])? $GLOBALS['table_date'][$table['id_table']] : $table['date'];
1610
+	$pred = $date_orig = isset($GLOBALS['table_date'][$table['id_table']]) ? $GLOBALS['table_date'][$table['id_table']] : $table['date'];
1618 1611
 	$col = $regs[1];
1619
-	if (isset($regs[3]) AND $suite = $regs[3]){
1612
+	if (isset($regs[3]) AND $suite = $regs[3]) {
1620 1613
 		# Recherche de l'existence du champ date_xxxx,
1621 1614
 		# si oui choisir ce champ, sinon choisir xxxx
1622 1615
 
@@ -1654,34 +1647,34 @@  discard block
 block discarded – undo
1654 1647
 			break;
1655 1648
 		case 'age':
1656 1649
 			$col = calculer_param_date("NOW()", $date_orig);
1657
-			$col_vraie = "";// comparer a un int (par defaut)
1650
+			$col_vraie = ""; // comparer a un int (par defaut)
1658 1651
 			break;
1659 1652
 		case 'age_relatif':
1660 1653
 			$col = calculer_param_date($date_compare, $date_orig);
1661
-			$col_vraie = "";// comparer a un int (par defaut)
1654
+			$col_vraie = ""; // comparer a un int (par defaut)
1662 1655
 			break;
1663 1656
 		case 'jour_relatif':
1664 1657
 			$col = "(TO_DAYS(".$date_compare.")-TO_DAYS(".$date_orig."))";
1665
-			$col_vraie = "";// comparer a un int (par defaut)
1658
+			$col_vraie = ""; // comparer a un int (par defaut)
1666 1659
 			break;
1667 1660
 		case 'mois_relatif':
1668 1661
 			$col = "MONTH(".$date_compare.")-MONTH(".
1669 1662
 			       $date_orig.")+12*(YEAR(".$date_compare.
1670 1663
 			       ")-YEAR(".$date_orig."))";
1671
-			$col_vraie = "";// comparer a un int (par defaut)
1664
+			$col_vraie = ""; // comparer a un int (par defaut)
1672 1665
 			break;
1673 1666
 		case 'annee_relatif':
1674 1667
 			$col = "YEAR(".$date_compare.")-YEAR(".
1675 1668
 			       $date_orig.")";
1676
-			$col_vraie = "";// comparer a un int (par defaut)
1669
+			$col_vraie = ""; // comparer a un int (par defaut)
1677 1670
 			break;
1678 1671
 	}
1679
-	return array($col,$col_vraie);
1672
+	return array($col, $col_vraie);
1680 1673
 }
1681 1674
 
1682 1675
 // http://doc.spip.org/@calculer_param_date
1683
-function calculer_param_date($date_compare, $date_orig){
1684
-	if (preg_match(",'\" *\.(.*)\. *\"',", $date_compare, $r)){
1676
+function calculer_param_date($date_compare, $date_orig) {
1677
+	if (preg_match(",'\" *\.(.*)\. *\"',", $date_compare, $r)) {
1685 1678
 		$init = "'\" . (\$x = $r[1]) . \"'";
1686 1679
 		$date_compare = '\'$x\'';
1687 1680
 	}
@@ -1718,7 +1711,7 @@  discard block
 block discarded – undo
1718 1711
  * @param object $boucles
1719 1712
  * @param object $crit
1720 1713
  */
1721
-function critere_DATA_source_dist($idb, &$boucles, $crit){
1714
+function critere_DATA_source_dist($idb, &$boucles, $crit) {
1722 1715
 	$boucle = &$boucles[$idb];
1723 1716
 
1724 1717
 	$args = array();
@@ -1740,7 +1733,7 @@  discard block
 block discarded – undo
1740 1733
  * @param object $boucles
1741 1734
  * @param object $crit
1742 1735
  */
1743
-function critere_DATA_datasource_dist($idb, &$boucles, $crit){
1736
+function critere_DATA_datasource_dist($idb, &$boucles, $crit) {
1744 1737
 	$boucle = &$boucles[$idb];
1745 1738
 	$boucle->hash .= '
1746 1739
 	$command[\'source\'] = array('.calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent).');
@@ -1754,7 +1747,7 @@  discard block
 block discarded – undo
1754 1747
  * @param object $boucles
1755 1748
  * @param object $crit
1756 1749
  */
1757
-function critere_DATA_datacache_dist($idb, &$boucles, $crit){
1750
+function critere_DATA_datacache_dist($idb, &$boucles, $crit) {
1758 1751
 	$boucle = &$boucles[$idb];
1759 1752
 	$boucle->hash .= '
1760 1753
 	$command[\'datacache\'] = '.calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent).';';
@@ -1769,10 +1762,10 @@  discard block
 block discarded – undo
1769 1762
  * @param object $boucles
1770 1763
  * @param object $crit
1771 1764
  */
1772
-function critere_php_args_dist($idb, &$boucles, $crit){
1765
+function critere_php_args_dist($idb, &$boucles, $crit) {
1773 1766
 	$boucle = &$boucles[$idb];
1774 1767
 	$boucle->hash .= '$command[\'args\']=array();';
1775
-	foreach ($crit->param as $param){
1768
+	foreach ($crit->param as $param) {
1776 1769
 		$boucle->hash .= '
1777 1770
 			$command[\'args\'][] = '.calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent).';';
1778 1771
 	}
@@ -1786,10 +1779,10 @@  discard block
 block discarded – undo
1786 1779
  * @param object $boucles
1787 1780
  * @param object $crit
1788 1781
  */
1789
-function critere_DATA_liste_dist($idb, &$boucles, $crit){
1782
+function critere_DATA_liste_dist($idb, &$boucles, $crit) {
1790 1783
 	$boucle = &$boucles[$idb];
1791 1784
 	$boucle->hash .= "\n\t".'$command[\'liste\'] = array();'."\n";
1792
-	foreach ($crit->param as $param){
1785
+	foreach ($crit->param as $param) {
1793 1786
 		$boucle->hash .= "\t".'$command[\'liste\'][] = '.calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent).";\n";
1794 1787
 	}
1795 1788
 }
@@ -1802,10 +1795,10 @@  discard block
 block discarded – undo
1802 1795
  * @param object $boucles
1803 1796
  * @param object $crit
1804 1797
  */
1805
-function critere_DATA_enum_dist($idb, &$boucles, $crit){
1798
+function critere_DATA_enum_dist($idb, &$boucles, $crit) {
1806 1799
 	$boucle = &$boucles[$idb];
1807 1800
 	$boucle->hash .= "\n\t".'$command[\'enum\'] = array();'."\n";
1808
-	foreach ($crit->param as $param){
1801
+	foreach ($crit->param as $param) {
1809 1802
 		$boucle->hash .= "\t".'$command[\'enum\'][] = '.calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent).";\n";
1810 1803
 	}
1811 1804
 }
@@ -1818,9 +1811,9 @@  discard block
 block discarded – undo
1818 1811
  * @param object $boucles
1819 1812
  * @param object $crit
1820 1813
  */
1821
-function critere_DATA_datapath_dist($idb, &$boucles, $crit){
1814
+function critere_DATA_datapath_dist($idb, &$boucles, $crit) {
1822 1815
 	$boucle = &$boucles[$idb];
1823
-	foreach ($crit->param as $param){
1816
+	foreach ($crit->param as $param) {
1824 1817
 		$boucle->hash .= '
1825 1818
 			$command[\'datapath\'][] = '.calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent).';';
1826 1819
 	}
@@ -1834,16 +1827,16 @@  discard block
 block discarded – undo
1834 1827
  * @param object $boucles
1835 1828
  * @param object $crit
1836 1829
  */
1837
-function critere_si_dist($idb, &$boucles, $crit){
1830
+function critere_si_dist($idb, &$boucles, $crit) {
1838 1831
 	$boucle = &$boucles[$idb];
1839 1832
 	// il faut initialiser 1 fois le tableau a chaque appel de la boucle
1840 1833
 	// (par exemple lorsque notre boucle est appelee dans une autre boucle)
1841 1834
 	// mais ne pas l'initialiser n fois si il y a n criteres {si } dans la boucle !
1842 1835
 	$boucle->hash .= "\n\tif (!isset(\$si_init)) { \$command['si'] = array(); \$si_init = true; }\n";
1843
-	if ($crit->param){
1844
-		foreach ($crit->param as $param){
1836
+	if ($crit->param) {
1837
+		foreach ($crit->param as $param) {
1845 1838
 			$boucle->hash .= "\t\$command['si'][] = "
1846
-					. calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent) . ";\n";
1839
+					. calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent).";\n";
1847 1840
 		}
1848 1841
 		// interdire {si 0} aussi !
1849 1842
 	} else {
@@ -1859,7 +1852,7 @@  discard block
 block discarded – undo
1859 1852
  * @param object $boucles
1860 1853
  * @param object $crit
1861 1854
  */
1862
-function critere_POUR_tableau_dist($idb, &$boucles, $crit){
1855
+function critere_POUR_tableau_dist($idb, &$boucles, $crit) {
1863 1856
 	$boucle = &$boucles[$idb];
1864 1857
 	$boucle->hash .= '
1865 1858
 	$command[\'source\'] = array('.calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent).');
@@ -1877,13 +1870,13 @@  discard block
 block discarded – undo
1877 1870
  * @param array $boucles
1878 1871
  * @param Object $crit
1879 1872
  */
1880
-function critere_noeud_dist($idb, &$boucles, $crit){
1873
+function critere_noeud_dist($idb, &$boucles, $crit) {
1881 1874
 	global $exceptions_des_tables;
1882 1875
 	$not = $crit->not;
1883 1876
 	$boucle = &$boucles[$idb];
1884 1877
 	$primary = $boucle->primary;
1885 1878
 
1886
-	if (!$primary OR strpos($primary, ',')){
1879
+	if (!$primary OR strpos($primary, ',')) {
1887 1880
 		erreur_squelette(_T('zbug_doublon_sur_table_sans_cle_primaire'), $boucle);
1888 1881
 		return;
1889 1882
 	}
@@ -1891,8 +1884,7 @@  discard block
 block discarded – undo
1891 1884
 	$table_sql = table_objet_sql(objet_type($table));
1892 1885
 
1893 1886
 	$id_parent = isset($exceptions_des_tables[$boucle->id_table]['id_parent']) ?
1894
-		$exceptions_des_tables[$boucle->id_table]['id_parent'] :
1895
-		'id_parent';
1887
+		$exceptions_des_tables[$boucle->id_table]['id_parent'] : 'id_parent';
1896 1888
 
1897 1889
 	$in = "IN";
1898 1890
 	$where = array("'IN'", "'$boucle->id_table."."$primary'", "'('.sql_get_select('$id_parent', '$table_sql').')'");
@@ -1912,7 +1904,7 @@  discard block
 block discarded – undo
1912 1904
  * @param array $boucles
1913 1905
  * @param Object $crit
1914 1906
  */
1915
-function critere_feuille_dist($idb, &$boucles, $crit){
1907
+function critere_feuille_dist($idb, &$boucles, $crit) {
1916 1908
 	$not = $crit->not;
1917 1909
 	$crit->not = $not ? false : true;
1918 1910
 	critere_noeud_dist($idb, $boucles, $crit);
Please login to merge, or discard this patch.
ecrire/public/phraser_html.php 1 patch
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
 define('SPEC_BOUCLE', '/\s*\(\s*([^\s?)]+)(\s*[^)?]*)([?]?)\)/');
28 28
 define('NOM_DE_BOUCLE', "[0-9]+|[-_][-_.a-zA-Z0-9]*");
29 29
 # ecriture alambiquee pour rester compatible avec les hexadecimaux des vieux squelettes
30
-define('NOM_DE_CHAMP', "#((" . NOM_DE_BOUCLE . "):)?(([A-F]*[G-Z_][A-Z_0-9]*)|[A-Z_]+)(\*{0,2})");
31
-define('CHAMP_ETENDU', '/\[([^]\[]*)\(' . NOM_DE_CHAMP . '([^[)]*\)[^]\[]*)\]/S');
30
+define('NOM_DE_CHAMP', "#((".NOM_DE_BOUCLE."):)?(([A-F]*[G-Z_][A-Z_0-9]*)|[A-Z_]+)(\*{0,2})");
31
+define('CHAMP_ETENDU', '/\[([^]\[]*)\('.NOM_DE_CHAMP.'([^[)]*\)[^]\[]*)\]/S');
32 32
 
33 33
 define('BALISE_INCLURE', '/<INCLU[DR]E[[:space:]]*(\(([^)]*)\))?/S');
34 34
 define('BALISE_POLYGLOTTE', ',<multi>(.*)</multi>,Uims');
35 35
 define('BALISE_IDIOMES', ',<:(([a-z0-9_]+):)?([a-z0-9_]*)({([^\|=>]*=[^\|>]*)})?((\|[^>]*)?:>),iS');
36
-define('BALISE_IDIOMES_ARGS', '@^\s*([^= ]*)\s*=\s*((' . NOM_DE_CHAMP . '[{][^}]*})?[^,]*)\s*,?\s*@s');
36
+define('BALISE_IDIOMES_ARGS', '@^\s*([^= ]*)\s*=\s*(('.NOM_DE_CHAMP.'[{][^}]*})?[^,]*)\s*,?\s*@s');
37 37
 
38 38
 define('SQL_ARGS', '(\([^)]*\))');
39
-define('CHAMP_SQL_PLUS_FONC', '`?([A-Z_\/][A-Z_\/0-9.]*)' . SQL_ARGS . '?`?');
39
+define('CHAMP_SQL_PLUS_FONC', '`?([A-Z_\/][A-Z_\/0-9.]*)'.SQL_ARGS.'?`?');
40 40
 
41 41
 // http://doc.spip.org/@phraser_inclure
42
-function phraser_inclure($texte, $ligne, $result){
42
+function phraser_inclure($texte, $ligne, $result) {
43 43
 
44
-	while (preg_match(BALISE_INCLURE, $texte, $match)){
44
+	while (preg_match(BALISE_INCLURE, $texte, $match)) {
45 45
 		$p = strpos($texte, $match[0]);
46 46
 		$debut = substr($texte, 0, $p);
47 47
 		if ($p) $result = phraser_idiomes($debut, $ligne, $result);
@@ -52,35 +52,35 @@  discard block
 block discarded – undo
52 52
 		$fichier = @$match[2];
53 53
 		# assurer ici la migration .php3 => .php
54 54
 		# et de l'ancienne syntaxe INCLURE(page.php3) devenue surperflue
55
-		if (preg_match(',^(.*[.]php)3$,', $fichier, $r)){
55
+		if (preg_match(',^(.*[.]php)3$,', $fichier, $r)) {
56 56
 			$fichier = $r[1];
57 57
 		}
58
-		$champ->texte = ($fichier!=='page.php') ? $fichier : '';
59
-		$texte = substr($texte, $p+strlen($match[0]));
58
+		$champ->texte = ($fichier !== 'page.php') ? $fichier : '';
59
+		$texte = substr($texte, $p + strlen($match[0]));
60 60
 		// on assimile {var=val} a une liste de un argument sans fonction
61 61
 		phraser_args($texte, "/>", "", $result, $champ);
62
-		if (!$champ->texte OR count($champ->param)>1){
62
+		if (!$champ->texte OR count($champ->param) > 1) {
63 63
 			if (!function_exists('normaliser_inclure'))
64 64
 				include_spip('public/normaliser');
65 65
 			normaliser_inclure($champ);
66 66
 		}
67
-		$texte = substr($champ->apres, strpos($champ->apres, '>')+1);
67
+		$texte = substr($champ->apres, strpos($champ->apres, '>') + 1);
68 68
 		$champ->apres = "";
69 69
 		$texte = preg_replace(',^</INCLU[DR]E>,', '', $texte);
70 70
 		$result[] = $champ;
71 71
 	}
72 72
 
73
-	return (($texte==="") ? $result : phraser_idiomes($texte, $ligne, $result));
73
+	return (($texte === "") ? $result : phraser_idiomes($texte, $ligne, $result));
74 74
 }
75 75
 
76 76
 // http://doc.spip.org/@phraser_polyglotte
77
-function phraser_polyglotte($texte, $ligne, $result){
77
+function phraser_polyglotte($texte, $ligne, $result) {
78 78
 
79 79
 	if (preg_match_all(BALISE_POLYGLOTTE, $texte, $m, PREG_SET_ORDER))
80
-		foreach ($m as $match){
80
+		foreach ($m as $match) {
81 81
 			$p = strpos($texte, $match[0]);
82 82
 			$debut = substr($texte, 0, $p);
83
-			if ($p){
83
+			if ($p) {
84 84
 				$champ = new Texte;
85 85
 				$champ->texte = $debut;
86 86
 				$champ->ligne = $ligne;
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 			$ligne += substr_count($match[0], "\n");
94 94
 			$lang = '';
95 95
 			$bloc = $match[1];
96
-			$texte = substr($texte, $p+strlen($match[0]));
97
-			while (preg_match("/^[[:space:]]*([^[{]*)[[:space:]]*[[{]([a-z_]+)[]}](.*)$/si", $bloc, $regs)){
96
+			$texte = substr($texte, $p + strlen($match[0]));
97
+			while (preg_match("/^[[:space:]]*([^[{]*)[[:space:]]*[[{]([a-z_]+)[]}](.*)$/si", $bloc, $regs)) {
98 98
 				$trad = $regs[1];
99 99
 				if ($trad OR $lang)
100 100
 					$champ->traductions[$lang] = $trad;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			$champ->traductions[$lang] = $bloc;
105 105
 			$result[] = $champ;
106 106
 		}
107
-	if ($texte!==""){
107
+	if ($texte !== "") {
108 108
 		$champ = new Texte;
109 109
 		$champ->texte = $texte;
110 110
 		$champ->ligne = $ligne;
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 // chaine peut etre vide si =texte1 est present et arg1 est vide
121 121
 // sinon ce n'est pas un idiome
122 122
 // http://doc.spip.org/@phraser_idiomes
123
-function phraser_idiomes($texte, $ligne, $result){
124
-	while (preg_match(BALISE_IDIOMES, $texte, $match)){
123
+function phraser_idiomes($texte, $ligne, $result) {
124
+	while (preg_match(BALISE_IDIOMES, $texte, $match)) {
125 125
 		$p = strpos($texte, $match[0]);
126
-		$ko = (!$match[3] && ($match[5][0]!=='='));
127
-		$debut = substr($texte, 0, $p+($ko ? strlen($match[0]) : 0));
126
+		$ko = (!$match[3] && ($match[5][0] !== '='));
127
+		$debut = substr($texte, 0, $p + ($ko ? strlen($match[0]) : 0));
128 128
 		if ($debut) $result = phraser_champs($debut, $ligne, $result);
129
-		$texte = substr($texte, $p+strlen($match[0]));
129
+		$texte = substr($texte, $p + strlen($match[0]));
130 130
 		$ligne += substr_count($debut, "\n");
131 131
 		if ($ko) continue; // faux idiome
132 132
 		$champ = new Idiome;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		// Stocker les arguments de la balise de traduction
136 136
 		$args = array();
137 137
 		$largs = $match[5];
138
-		while (preg_match(BALISE_IDIOMES_ARGS, $largs, $r)){
138
+		while (preg_match(BALISE_IDIOMES_ARGS, $largs, $r)) {
139 139
 			$args[$r[1]] = phraser_champs($r[2], 0, array());
140 140
 			$largs = substr($largs, strlen($r[0]));
141 141
 		}
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 		phraser_args(@$match[7], ":", '', array(), $champ);
147 147
 		$result[] = $champ;
148 148
 	}
149
-	if ($texte!=="") $result = phraser_champs($texte, $ligne, $result);
149
+	if ($texte !== "") $result = phraser_champs($texte, $ligne, $result);
150 150
 
151 151
 	return $result;
152 152
 }
153 153
 
154 154
 // http://doc.spip.org/@phraser_champs
155
-function phraser_champs($texte, $ligne, $result){
156
-	while (preg_match("/" . NOM_DE_CHAMP . "/S", $texte, $match)){
155
+function phraser_champs($texte, $ligne, $result) {
156
+	while (preg_match("/".NOM_DE_CHAMP."/S", $texte, $match)) {
157 157
 		$p = strpos($texte, $match[0]);
158
-		$suite = substr($texte, $p+strlen($match[0]));
159
-		if ($match[5] || (strpos($suite[0], "[0-9]")===false)){
158
+		$suite = substr($texte, $p + strlen($match[0]));
159
+		if ($match[5] || (strpos($suite[0], "[0-9]") === false)) {
160 160
 			$debut = substr($texte, 0, $p);
161 161
 			if ($p) $result = phraser_polyglotte($debut, $ligne, $result);
162 162
 			$ligne += substr_count($debut, "\n");
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 			$champ->nom_champ = $match[3];
168 168
 			$champ->etoile = $match[5];
169 169
 
170
-			if ($suite[0]=='{'){
170
+			if ($suite[0] == '{') {
171 171
 				phraser_arg($suite, '', array(), $champ);
172 172
 				// ce ltrim est une ereur de conception
173 173
 				// mais on le conserve par souci de compatibilite
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 			$result[] = $champ;
186 186
 		} else {
187 187
 			// faux champ
188
-			$result = phraser_polyglotte(substr($texte, 0, $p+1), $ligne, $result);
189
-			$texte = (substr($texte, $p+1));
188
+			$result = phraser_polyglotte(substr($texte, 0, $p + 1), $ligne, $result);
189
+			$texte = (substr($texte, $p + 1));
190 190
 		}
191 191
 	}
192
-	if ($texte!=="") $result = phraser_polyglotte($texte, $ligne, $result);
192
+	if ($texte !== "") $result = phraser_polyglotte($texte, $ligne, $result);
193 193
 
194 194
 	return $result;
195 195
 }
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 // on recommence tant qu'il y a des [...] en substituant a l'appel suivant
201 201
 
202 202
 // http://doc.spip.org/@phraser_champs_etendus
203
-function phraser_champs_etendus($texte, $ligne, $result){
204
-	if ($texte==="") return $result;
203
+function phraser_champs_etendus($texte, $ligne, $result) {
204
+	if ($texte === "") return $result;
205 205
 	$sep = '##';
206
-	while (strpos($texte, $sep)!==false)
206
+	while (strpos($texte, $sep) !== false)
207 207
 		$sep .= '#';
208 208
 
209 209
 	return array_merge($result, phraser_champs_interieurs($texte, $ligne, $sep, array()));
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 // Tres chevelu
217 217
 
218 218
 // http://doc.spip.org/@phraser_args
219
-function phraser_args($texte, $fin, $sep, $result, &$pointeur_champ){
219
+function phraser_args($texte, $fin, $sep, $result, &$pointeur_champ) {
220 220
 	$texte = ltrim($texte);
221
-	while (($texte!=="") && strpos($fin, $texte[0])===false){
221
+	while (($texte !== "") && strpos($fin, $texte[0]) === false) {
222 222
 		$result = phraser_arg($texte, $sep, $result, $pointeur_champ);
223 223
 		$texte = ltrim($texte);
224 224
 	}
@@ -230,23 +230,23 @@  discard block
 block discarded – undo
230 230
 }
231 231
 
232 232
 // http://doc.spip.org/@phraser_arg
233
-function phraser_arg(&$texte, $sep, $result, &$pointeur_champ){
233
+function phraser_arg(&$texte, $sep, $result, &$pointeur_champ) {
234 234
 	preg_match(",^(\|?[^}{)|]*)(.*)$,ms", $texte, $match);
235 235
 	$suite = ltrim($match[2]);
236 236
 	$fonc = trim($match[1]);
237
-	if ($fonc && $fonc[0]=="|") $fonc = ltrim(substr($fonc, 1));
237
+	if ($fonc && $fonc[0] == "|") $fonc = ltrim(substr($fonc, 1));
238 238
 	$res = array($fonc);
239 239
 	$err_f = '';
240 240
 	// cas du filtre sans argument ou du critere /
241
-	if (($suite && ($suite[0]!='{')) || ($fonc && $fonc[0]=='/')){
241
+	if (($suite && ($suite[0] != '{')) || ($fonc && $fonc[0] == '/')) {
242 242
 		// si pas d'argument, alors il faut une fonction ou un double |
243
-		if (!$match[1]){
243
+		if (!$match[1]) {
244 244
 			$err_f = array('zbug_erreur_filtre', array('filtre' => $texte));
245 245
 			erreur_squelette($err_f, $pointeur_champ);
246 246
 			$texte = '';
247 247
 		} else  $texte = $suite;
248 248
 		if ($err_f) $pointeur_champ->param = false;
249
-		elseif ($fonc!=='') $pointeur_champ->param[] = $res;
249
+		elseif ($fonc !== '') $pointeur_champ->param[] = $res;
250 250
 		// pour les balises avec faux filtres qui boudent ce dur larbeur
251 251
 		$pointeur_champ->fonctions[] = array($fonc, '');
252 252
 
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
 	}
255 255
 	$args = ltrim(substr($suite, 1)); // virer le '(' initial
256 256
 	$collecte = array();
257
-	while ($args && $args[0]!='}'){
258
-		if ($args[0]=='"')
257
+	while ($args && $args[0] != '}') {
258
+		if ($args[0] == '"')
259 259
 			preg_match('/^(")([^"]*)(")(.*)$/ms', $args, $regs);
260
-		else if ($args[0]=="'")
260
+		else if ($args[0] == "'")
261 261
 			preg_match("/^(')([^']*)(')(.*)$/ms", $args, $regs);
262 262
 		else {
263 263
 			preg_match("/^([[:space:]]*)([^,([{}]*([(\[{][^])}]*[])}])?[^,}]*)([,}].*)$/ms", $args, $regs);
264
-			if (!strlen($regs[2])){
264
+			if (!strlen($regs[2])) {
265 265
 				$err_f = array('zbug_erreur_filtre', array('filtre' => $args));
266 266
 				erreur_squelette($err_f, $pointeur_champ);
267 267
 				$champ = new Texte;
@@ -270,81 +270,81 @@  discard block
 block discarded – undo
270 270
 			}
271 271
 		}
272 272
 		$arg = $regs[2];
273
-		if (trim($regs[1])){
273
+		if (trim($regs[1])) {
274 274
 			$champ = new Texte;
275 275
 			$champ->texte = $arg;
276 276
 			$champ->apres = $champ->avant = $regs[1];
277 277
 			$result[] = $champ;
278 278
 			$collecte[] = $champ;
279
-			$args = ltrim($regs[count($regs)-1]);
279
+			$args = ltrim($regs[count($regs) - 1]);
280 280
 		} else {
281
-			if (!preg_match("/" . NOM_DE_CHAMP . "([{|])/", $arg, $r)){
281
+			if (!preg_match("/".NOM_DE_CHAMP."([{|])/", $arg, $r)) {
282 282
 				// 0 est un aveu d'impuissance. A completer
283 283
 				$arg = phraser_champs_exterieurs($arg, 0, $sep, $result);
284 284
 
285
-				$args = ltrim($regs[count($regs)-1]);
285
+				$args = ltrim($regs[count($regs) - 1]);
286 286
 				$collecte = array_merge($collecte, $arg);
287 287
 				$result = array_merge($result, $arg);
288 288
 			} else {
289 289
 				$n = strpos($args, $r[0]);
290 290
 				$pred = substr($args, 0, $n);
291 291
 				$par = ',}';
292
-				if (preg_match('/^(.*)\($/', $pred, $m)){
292
+				if (preg_match('/^(.*)\($/', $pred, $m)) {
293 293
 					$pred = $m[1];
294 294
 					$par = ')';
295 295
 				}
296
-				if ($pred){
296
+				if ($pred) {
297 297
 					$champ = new Texte;
298 298
 					$champ->texte = $pred;
299 299
 					$champ->apres = $champ->avant = "";
300 300
 					$result[] = $champ;
301 301
 					$collecte[] = $champ;
302 302
 				}
303
-				$rec = substr($args, $n+strlen($r[0])-1);
303
+				$rec = substr($args, $n + strlen($r[0]) - 1);
304 304
 				$champ = new Champ;
305 305
 				$champ->nom_boucle = $r[2];
306 306
 				$champ->nom_champ = $r[3];
307 307
 				$champ->etoile = $r[5];
308 308
 				$next = $r[6];
309
-				while ($next=='{'){
309
+				while ($next == '{') {
310 310
 					phraser_arg($rec, $sep, array(), $champ);
311 311
 					$args = ltrim($rec);
312 312
 					$next = isset($args[0]) ? $args[0] : '';
313 313
 				}
314
-				while ($next=='|'){
314
+				while ($next == '|') {
315 315
 					phraser_args($rec, $par, $sep, array(), $champ);
316 316
 					$args = $champ->apres;
317 317
 					$champ->apres = '';
318 318
 					$next = isset($args[0]) ? $args[0] : '';
319 319
 				}
320 320
 				// Si erreur de syntaxe dans un sous-argument, propager.
321
-				if ($champ->param===false)
321
+				if ($champ->param === false)
322 322
 					$err_f = true;
323 323
 				else phraser_vieux($champ);
324
-				if ($par==')') $args = substr($args, 1);
324
+				if ($par == ')') $args = substr($args, 1);
325 325
 				$collecte[] = $champ;
326 326
 				$result[] = $champ;
327 327
 			}
328 328
 		}
329
-		if (isset($args[0]) AND $args[0]==','){
329
+		if (isset($args[0]) AND $args[0] == ',') {
330 330
 			$args = ltrim(substr($args, 1));
331
-			if ($collecte){
331
+			if ($collecte) {
332 332
 				$res[] = $collecte;
333 333
 				$collecte = array();
334 334
 			}
335 335
 		}
336 336
 	}
337
-	if ($collecte){
337
+	if ($collecte) {
338 338
 		$res[] = $collecte;
339 339
 		$collecte = array();
340 340
 	}
341 341
 	$texte = substr($args, 1);
342
-	$source = substr($suite, 0, strlen($suite)-strlen($texte));
342
+	$source = substr($suite, 0, strlen($suite) - strlen($texte));
343 343
 	// propager les erreurs, et ignorer les param vides
344
-	if ($pointeur_champ->param!==false){
344
+	if ($pointeur_champ->param !== false) {
345 345
 		if ($err_f)
346 346
 			$pointeur_champ->param = false;
347
-		elseif ($fonc!=='' || count($res)>1)
347
+		elseif ($fonc !== '' || count($res) > 1)
348 348
 			$pointeur_champ->param[] = $res;
349 349
 	}
350 350
 	// pour les balises avec faux filtres qui boudent ce dur larbeur
@@ -355,41 +355,41 @@  discard block
 block discarded – undo
355 355
 
356 356
 
357 357
 // http://doc.spip.org/@phraser_champs_exterieurs
358
-function phraser_champs_exterieurs($texte, $ligne, $sep, $nested){
358
+function phraser_champs_exterieurs($texte, $ligne, $sep, $nested) {
359 359
 	$res = array();
360
-	while (($p = strpos($texte, "%$sep"))!==false){
361
-		if (!preg_match(',^%' . preg_quote($sep) . '([0-9]+)@,', substr($texte, $p), $m))
360
+	while (($p = strpos($texte, "%$sep")) !== false) {
361
+		if (!preg_match(',^%'.preg_quote($sep).'([0-9]+)@,', substr($texte, $p), $m))
362 362
 			break;
363 363
 		$debut = substr($texte, 0, $p);
364
-		$texte = substr($texte, $p+strlen($m[0]));
364
+		$texte = substr($texte, $p + strlen($m[0]));
365 365
 		if ($p)
366 366
 			$res = phraser_inclure($debut, $ligne, $res);
367 367
 		$ligne += substr_count($debut, "\n");
368 368
 		$res[] = $nested[$m[1]];
369 369
 	}
370 370
 
371
-	return (($texte==='') ? $res : phraser_inclure($texte, $ligne, $res));
371
+	return (($texte === '') ? $res : phraser_inclure($texte, $ligne, $res));
372 372
 }
373 373
 
374 374
 // http://doc.spip.org/@phraser_champs_interieurs
375
-function phraser_champs_interieurs($texte, $ligne, $sep, $result){
375
+function phraser_champs_interieurs($texte, $ligne, $sep, $result) {
376 376
 	$i = 0; // en fait count($result)
377 377
 	$x = "";
378 378
 
379
-	while (true){
379
+	while (true) {
380 380
 		$j = $i;
381 381
 		$n = $ligne;
382
-		while (preg_match(CHAMP_ETENDU, $texte, $match)){
382
+		while (preg_match(CHAMP_ETENDU, $texte, $match)) {
383 383
 			$p = strpos($texte, $match[0]);
384 384
 			$debut = substr($texte, 0, $p);
385
-			if ($p){
385
+			if ($p) {
386 386
 				$result[$i] = $debut;
387 387
 				$i++;
388 388
 			}
389 389
 			$nom = $match[4];
390 390
 			$champ = new Champ;
391 391
 			// ca ne marche pas encore en cas de champ imbrique
392
-			$champ->ligne = $x ? 0 : ($n+substr_count($debut, "\n"));
392
+			$champ->ligne = $x ? 0 : ($n + substr_count($debut, "\n"));
393 393
 			$champ->nom_boucle = $match[3];
394 394
 			$champ->nom_champ = $nom;
395 395
 			$champ->etoile = $match[6];
@@ -399,22 +399,22 @@  discard block
 block discarded – undo
399 399
 			$champ->avant =
400 400
 				phraser_champs_exterieurs($match[1], $n, $sep, $result);
401 401
 			$debut = substr($champ->apres, 1);
402
-			if (!empty($debut)){
402
+			if (!empty($debut)) {
403 403
 				$n += substr_count(substr($texte, 0, strpos($texte, $debut)), "\n");
404 404
 			}
405 405
 			$champ->apres = phraser_champs_exterieurs($debut, $n, $sep, $result);
406 406
 
407 407
 			$result[$i] = $champ;
408 408
 			$i++;
409
-			$texte = substr($texte, $p+strlen($match[0]));
409
+			$texte = substr($texte, $p + strlen($match[0]));
410 410
 		}
411
-		if ($texte!==""){
411
+		if ($texte !== "") {
412 412
 			$result[$i] = $texte;
413 413
 			$i++;
414 414
 		}
415 415
 		$x = '';
416 416
 
417
-		while ($j<$i){
417
+		while ($j < $i) {
418 418
 			$z = $result[$j];
419 419
 			// j'aurais besoin de connaitre le nombre de lignes...
420 420
 			if (is_object($z))
@@ -430,18 +430,18 @@  discard block
 block discarded – undo
430 430
 	}
431 431
 }
432 432
 
433
-function phraser_vieux(&$champ){
433
+function phraser_vieux(&$champ) {
434 434
 	$nom = $champ->nom_champ;
435
-	if ($nom=='EMBED_DOCUMENT'){
435
+	if ($nom == 'EMBED_DOCUMENT') {
436 436
 		if (!function_exists('phraser_vieux_emb'))
437 437
 			include_spip('public/normaliser');
438 438
 		phraser_vieux_emb($champ);
439
-	} elseif ($nom=='EXPOSER') {
439
+	} elseif ($nom == 'EXPOSER') {
440 440
 		if (!function_exists('phraser_vieux_exposer'))
441 441
 			include_spip('public/normaliser');
442 442
 		phraser_vieux_exposer($champ);
443 443
 	} elseif ($champ->param) {
444
-		if ($nom=='FORMULAIRE_RECHERCHE'){
444
+		if ($nom == 'FORMULAIRE_RECHERCHE') {
445 445
 			if (!function_exists('phraser_vieux_recherche'))
446 446
 				include_spip('public/normaliser');
447 447
 			phraser_vieux_recherche($champ);
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
 			if (!function_exists('phraser_vieux_logos'))
450 450
 				include_spip('public/normaliser');
451 451
 			phraser_vieux_logos($champ);
452
-		} elseif ($nom=='MODELE') {
452
+		} elseif ($nom == 'MODELE') {
453 453
 			if (!function_exists('phraser_vieux_modele'))
454 454
 				include_spip('public/normaliser');
455 455
 			phraser_vieux_modele($champ);
456
-		} elseif ($nom=='INCLURE' OR $nom=='INCLUDE') {
456
+		} elseif ($nom == 'INCLURE' OR $nom == 'INCLUDE') {
457 457
 			if (!function_exists('phraser_vieux_inclu'))
458 458
 				include_spip('public/normaliser');
459 459
 			phraser_vieux_inclu($champ);
@@ -484,22 +484,22 @@  discard block
 block discarded – undo
484 484
  *     Elle sera complété de la liste de ses critères
485 485
  * @return void
486 486
  **/
487
-function phraser_criteres($params, &$result){
487
+function phraser_criteres($params, &$result) {
488 488
 
489 489
 	$err_ci = ''; // indiquera s'il y a eu une erreur
490 490
 	$args = array();
491 491
 	$type = $result->type_requete;
492 492
 	$doublons = array();
493
-	foreach ($params as $v){
493
+	foreach ($params as $v) {
494 494
 		$var = $v[1][0];
495
-		$param = ($var->type!='texte') ? "" : $var->texte;
496
-		if ((count($v)>2) && (!preg_match(",[^A-Za-z]IN[^A-Za-z],i", $param))){
495
+		$param = ($var->type != 'texte') ? "" : $var->texte;
496
+		if ((count($v) > 2) && (!preg_match(",[^A-Za-z]IN[^A-Za-z],i", $param))) {
497 497
 // plus d'un argument et pas le critere IN:
498 498
 // detecter comme on peut si c'est le critere implicite LIMIT debut, fin
499 499
 
500
-			if ($var->type!='texte'
500
+			if ($var->type != 'texte'
501 501
 				OR preg_match("/^(n|n-|(n-)?\d+)$/S", $param)
502
-			){
502
+			) {
503 503
 				$op = ',';
504 504
 				$not = "";
505 505
 			} else {
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 				// et mettre son reliquat eventuel
513 513
 				// Recopier pour ne pas alterer le texte source
514 514
 				// utile au debusqueur
515
-				if ($m[4]){
515
+				if ($m[4]) {
516 516
 					// une maniere tres sale de supprimer les "' autour de {critere "xxx","yyy"}
517
-					if (preg_match(',^(["\'])(.*)\1$,', $m[4])){
517
+					if (preg_match(',^(["\'])(.*)\1$,', $m[4])) {
518 518
 						$c = null;
519
-						eval ('$c = ' . $m[4] . ';');
519
+						eval ('$c = '.$m[4].';');
520 520
 						if (isset($c))
521 521
 							$m[4] = $c;
522 522
 					}
@@ -534,10 +534,10 @@  discard block
 block discarded – undo
534 534
 			$crit->param = $v;
535 535
 			$args[] = $crit;
536 536
 		} else {
537
-			if ($var->type!='texte'){
537
+			if ($var->type != 'texte') {
538 538
 				// cas 1 seul arg ne commencant pas par du texte brut:
539 539
 				// erreur ou critere infixe "/"
540
-				if (($v[1][1]->type!='texte') || (trim($v[1][1]->texte)!='/')){
540
+				if (($v[1][1]->type != 'texte') || (trim($v[1][1]->texte) != '/')) {
541 541
 					$err_ci = array('zbug_critere_inconnu',
542 542
 						array('critere' => $var->nom_champ));
543 543
 					erreur_squelette($err_ci, $result);
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
 				// les separateurs
555 555
 				if ($var->apres)
556 556
 					$result->separateur[] = $param;
557
-				elseif (($param=='tout') OR ($param=='tous'))
557
+				elseif (($param == 'tout') OR ($param == 'tous'))
558 558
 					$result->modificateur['tout'] = true;
559
-				elseif ($param=='plat')
559
+				elseif ($param == 'plat')
560 560
 					$result->modificateur['plat'] = true;
561 561
 
562 562
 				// Boucle hierarchie, analyser le critere id_rubrique
@@ -564,43 +564,43 @@  discard block
 block discarded – undo
564 564
 				// ceux-ci pour avoir la rubrique mere...
565 565
 				// Les autres critères de la boucle hierarchie doivent être
566 566
 				// traités normalement.
567
-				elseif (strcasecmp($type, 'hierarchie')==0
567
+				elseif (strcasecmp($type, 'hierarchie') == 0
568 568
 					AND !preg_match(",^id_rubrique\b,", $param)
569 569
 					AND preg_match(",^id_\w+\s*$,", $param)
570 570
 				) {
571 571
 					$result->modificateur['tout'] = true;
572
-				} elseif (strcasecmp($type, 'hierarchie')==0 AND $param=="id_rubrique") {
572
+				} elseif (strcasecmp($type, 'hierarchie') == 0 AND $param == "id_rubrique") {
573 573
 					// rien a faire sur {id_rubrique} tout seul
574 574
 				} else {
575 575
 					// pas d'emplacement statique, faut un dynamique
576 576
 					/// mais il y a 2 cas qui ont les 2 !
577
-					if (($param=='unique') || (preg_match(',^!?doublons *,', $param))){
577
+					if (($param == 'unique') || (preg_match(',^!?doublons *,', $param))) {
578 578
 						// cette variable sera inseree dans le code
579 579
 						// et son nom sert d'indicateur des maintenant
580 580
 						$result->doublons = '$doublons_index';
581
-						if ($param=='unique') $param = 'doublons';
582
-					} elseif ($param=='recherche')
581
+						if ($param == 'unique') $param = 'doublons';
582
+					} elseif ($param == 'recherche')
583 583
 						// meme chose (a cause de #nom_de_boucle:URL_*)
584 584
 						$result->hash = ' ';
585
-					if (preg_match(',^ *([0-9-]+) *(/) *(.+) *$,', $param, $m)){
585
+					if (preg_match(',^ *([0-9-]+) *(/) *(.+) *$,', $param, $m)) {
586 586
 						$crit = phraser_critere_infixe($m[1], $m[3], $v, '/', '', '');
587
-					} elseif (preg_match(',^([!]?)(' . CHAMP_SQL_PLUS_FONC .
587
+					} elseif (preg_match(',^([!]?)('.CHAMP_SQL_PLUS_FONC.
588 588
 						')[[:space:]]*(\??)(!?)(<=?|>=?|==?|\b(?:IN|LIKE)\b)(.*)$,is', $param, $m)) {
589 589
 						$a2 = trim($m[8]);
590
-						if ($a2 AND ($a2[0]=="'" OR $a2[0]=='"') AND ($a2[0]==substr($a2, -1)))
590
+						if ($a2 AND ($a2[0] == "'" OR $a2[0] == '"') AND ($a2[0] == substr($a2, -1)))
591 591
 							$a2 = substr($a2, 1, -1);
592 592
 						$crit = phraser_critere_infixe($m[2], $a2, $v,
593
-							(($m[2]=='lang_select') ? $m[2] : $m[7]),
593
+							(($m[2] == 'lang_select') ? $m[2] : $m[7]),
594 594
 							$m[6], $m[5]);
595 595
 						$crit->exclus = $m[1];
596
-					} elseif (preg_match("/^([!]?)\s*(" .
597
-						CHAMP_SQL_PLUS_FONC .
596
+					} elseif (preg_match("/^([!]?)\s*(".
597
+						CHAMP_SQL_PLUS_FONC.
598 598
 						")\s*(\??)(.*)$/is", $param, $m)) {
599 599
 						// contient aussi les comparaisons implicites !
600 600
 						// Comme ci-dessus:
601 601
 						// le premier arg contient l'operateur
602 602
 						array_shift($v);
603
-						if ($m[6]){
603
+						if ($m[6]) {
604 604
 							$v[0][0] = new Texte;
605 605
 							$v[0][0]->texte = $m[6];
606 606
 						} else {
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 }
635 635
 
636 636
 // http://doc.spip.org/@phraser_critere_infixe
637
-function phraser_critere_infixe($arg1, $arg2, $args, $op, $not, $cond){
637
+function phraser_critere_infixe($arg1, $arg2, $args, $op, $not, $cond) {
638 638
 	$args[0] = new Texte;
639 639
 	$args[0]->texte = $arg1;
640 640
 	$args[0] = array($args[0]);
@@ -649,11 +649,11 @@  discard block
 block discarded – undo
649 649
 	return $crit;
650 650
 }
651 651
 
652
-function public_phraser_html_dist($texte, $id_parent, &$boucles, $descr, $ligne = 1){
652
+function public_phraser_html_dist($texte, $id_parent, &$boucles, $descr, $ligne = 1) {
653 653
 
654 654
 	$all_res = array();
655 655
 
656
-	while (($pos_boucle = strpos($texte, BALISE_BOUCLE))!==false){
656
+	while (($pos_boucle = strpos($texte, BALISE_BOUCLE)) !== false) {
657 657
 
658 658
 		$err_b = ''; // indiquera s'il y a eu une erreur
659 659
 		$result = new Boucle;
@@ -661,16 +661,16 @@  discard block
 block discarded – undo
661 661
 		$result->descr = $descr;
662 662
 # attention: reperer la premiere des 2 balises: pre_boucle ou boucle
663 663
 
664
-		if (!preg_match("," . BALISE_PRE_BOUCLE . '[0-9_],', $texte, $r)
665
-			OR ($n = strpos($texte, $r[0]))===false
666
-			OR ($n>$pos_boucle)
667
-		){
664
+		if (!preg_match(",".BALISE_PRE_BOUCLE.'[0-9_],', $texte, $r)
665
+			OR ($n = strpos($texte, $r[0])) === false
666
+			OR ($n > $pos_boucle)
667
+		) {
668 668
 			$debut = substr($texte, 0, $pos_boucle);
669 669
 			$milieu = substr($texte, $pos_boucle);
670 670
 			$k = strpos($milieu, '(');
671 671
 			$id_boucle = trim(substr($milieu,
672 672
 				strlen(BALISE_BOUCLE),
673
-				$k-strlen(BALISE_BOUCLE)));
673
+				$k - strlen(BALISE_BOUCLE)));
674 674
 			$milieu = substr($milieu, $k);
675 675
 
676 676
 		} else {
@@ -679,18 +679,18 @@  discard block
 block discarded – undo
679 679
 			$k = strpos($milieu, '>');
680 680
 			$id_boucle = substr($milieu,
681 681
 				strlen(BALISE_PRE_BOUCLE),
682
-				$k-strlen(BALISE_PRE_BOUCLE));
682
+				$k - strlen(BALISE_PRE_BOUCLE));
683 683
 
684
-			if (!preg_match("," . BALISE_BOUCLE . $id_boucle . "[[:space:]]*\(,", $milieu, $r)){
684
+			if (!preg_match(",".BALISE_BOUCLE.$id_boucle."[[:space:]]*\(,", $milieu, $r)) {
685 685
 				$err_b = array('zbug_erreur_boucle_syntaxe', array('id' => $id_boucle));
686 686
 				erreur_squelette($err_b, $result);
687
-				$texte = substr($texte, $n+1);
687
+				$texte = substr($texte, $n + 1);
688 688
 				continue;
689 689
 			} else {
690 690
 				$pos_boucle = $n;
691 691
 				$n = strpos($milieu, $r[0]);
692
-				$result->avant = substr($milieu, $k+1, $n-$k-1);
693
-				$milieu = substr($milieu, $n+strlen($id_boucle)+strlen(BALISE_BOUCLE));
692
+				$result->avant = substr($milieu, $k + 1, $n - $k - 1);
693
+				$milieu = substr($milieu, $n + strlen($id_boucle) + strlen(BALISE_BOUCLE));
694 694
 			}
695 695
 		}
696 696
 		$result->id_boucle = $id_boucle;
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
 		$type = $match[1];
702 702
 		$jointures = trim($match[2]);
703 703
 		$table_optionnelle = ($match[3]);
704
-		if ($jointures){
704
+		if ($jointures) {
705 705
 			// on affecte pas ici les jointures explicites, mais dans la compilation
706 706
 			// ou elles seront completees des jointures declarees
707 707
 			$result->jointures_explicites = $jointures;
708 708
 		}
709 709
 
710
-		if ($table_optionnelle){
710
+		if ($table_optionnelle) {
711 711
 			$result->table_optionnelle = $type;
712 712
 		}
713 713
 
@@ -725,20 +725,20 @@  discard block
 block discarded – undo
725 725
 		//
726 726
 		// Recuperer la fin :
727 727
 		//
728
-		if ($milieu[0]==='/'){
728
+		if ($milieu[0] === '/') {
729 729
 			$suite = substr($milieu, 2);
730 730
 			$milieu = '';
731 731
 		} else {
732 732
 			$milieu = substr($milieu, 1);
733
-			$s = BALISE_FIN_BOUCLE . $id_boucle . ">";
733
+			$s = BALISE_FIN_BOUCLE.$id_boucle.">";
734 734
 			$p = strpos($milieu, $s);
735
-			if ($p===false){
735
+			if ($p === false) {
736 736
 				$err_b = array('zbug_erreur_boucle_fermant',
737 737
 					array('id' => $id_boucle));
738 738
 				erreur_squelette($err_b, $result);
739 739
 			}
740 740
 
741
-			$suite = substr($milieu, $p+strlen($s));
741
+			$suite = substr($milieu, $p + strlen($s));
742 742
 			$milieu = substr($milieu, 0, $p);
743 743
 		}
744 744
 
@@ -747,30 +747,30 @@  discard block
 block discarded – undo
747 747
 		//
748 748
 		// 1. Recuperer la partie conditionnelle apres
749 749
 		//
750
-		$s = BALISE_POST_BOUCLE . $id_boucle . ">";
750
+		$s = BALISE_POST_BOUCLE.$id_boucle.">";
751 751
 		$p = strpos($suite, $s);
752
-		if ($p!==false){
752
+		if ($p !== false) {
753 753
 			$result->apres = substr($suite, 0, $p);
754
-			$suite = substr($suite, $p+strlen($s));
754
+			$suite = substr($suite, $p + strlen($s));
755 755
 		}
756 756
 
757 757
 		//
758 758
 		// 2. Recuperer la partie alternative
759 759
 		//
760
-		$s = BALISE_ALT_BOUCLE . $id_boucle . ">";
760
+		$s = BALISE_ALT_BOUCLE.$id_boucle.">";
761 761
 		$p = strpos($suite, $s);
762
-		if ($p!==false){
762
+		if ($p !== false) {
763 763
 			$result->altern = substr($suite, 0, $p);
764
-			$suite = substr($suite, $p+strlen($s));
764
+			$suite = substr($suite, $p + strlen($s));
765 765
 		}
766
-		$result->ligne = $ligne+substr_count($debut, "\n");
766
+		$result->ligne = $ligne + substr_count($debut, "\n");
767 767
 		$m = substr_count($milieu, "\n");
768 768
 		$b = substr_count($result->avant, "\n");
769 769
 		$a = substr_count($result->apres, "\n");
770 770
 
771
-		if ($p = strpos($type, ':')){
771
+		if ($p = strpos($type, ':')) {
772 772
 			$result->sql_serveur = substr($type, 0, $p);
773
-			$type = substr($type, $p+1);
773
+			$type = substr($type, $p + 1);
774 774
 		}
775 775
 		$soustype = strtolower($type);
776 776
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 			$err_b = true;
784 784
 		else {
785 785
 			phraser_criteres($result->param, $result);
786
-			if (strncasecmp($soustype, TYPE_RECURSIF, strlen(TYPE_RECURSIF))==0){
786
+			if (strncasecmp($soustype, TYPE_RECURSIF, strlen(TYPE_RECURSIF)) == 0) {
787 787
 				$result->type_requete = TYPE_RECURSIF;
788 788
 				$args = $result->param;
789 789
 				array_unshift($args,
@@ -793,9 +793,9 @@  discard block
 block discarded – undo
793 793
 		}
794 794
 
795 795
 		$result->avant = public_phraser_html_dist($result->avant, $id_parent, $boucles, $descr, $result->ligne);
796
-		$result->apres = public_phraser_html_dist($result->apres, $id_parent, $boucles, $descr, $result->ligne+$b+$m);
797
-		$result->altern = public_phraser_html_dist($result->altern, $id_parent, $boucles, $descr, $result->ligne+$a+$m+$b);
798
-		$result->milieu = public_phraser_html_dist($milieu, $id_boucle, $boucles, $descr, $result->ligne+$b);
796
+		$result->apres = public_phraser_html_dist($result->apres, $id_parent, $boucles, $descr, $result->ligne + $b + $m);
797
+		$result->altern = public_phraser_html_dist($result->altern, $id_parent, $boucles, $descr, $result->ligne + $a + $m + $b);
798
+		$result->milieu = public_phraser_html_dist($milieu, $id_boucle, $boucles, $descr, $result->ligne + $b);
799 799
 
800 800
 		// Prevenir le generateur de code que le squelette est faux
801 801
 		if ($err_b) $result->type_requete = false;
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 		// Verifier qu'il n'y a pas double definition
804 804
 		// apres analyse des sous-parties (pas avant).
805 805
 
806
-		if (isset($boucles[$id_boucle])){
806
+		if (isset($boucles[$id_boucle])) {
807 807
 			$err_b_d = array('zbug_erreur_boucle_double',
808 808
 				array('id' => $id_boucle));
809 809
 			erreur_squelette($err_b_d, $result);
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 			$boucles[$id_boucle] = $result;
814 814
 		$all_res = phraser_champs_etendus($debut, $ligne, $all_res);
815 815
 		$all_res[] = &$boucles[$id_boucle];
816
-		if (!empty($suite)){
816
+		if (!empty($suite)) {
817 817
 			$ligne += substr_count(substr($texte, 0, strpos($texte, $suite)), "\n");
818 818
 		}
819 819
 		$texte = $suite;
Please login to merge, or discard this patch.
ecrire/public/assembler.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 //
21 21
 
22 22
 // http://doc.spip.org/@assembler
23
-function assembler($fond, $connect='') {
23
+function assembler($fond, $connect = '') {
24 24
 
25 25
 	// flag_preserver est modifie ici, et utilise en globale
26 26
 	// use_cache sert a informer le bouton d'admin pr savoir s'il met un *
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
 	$contexte = calculer_contexte();
31 31
 	$page = array('contexte_implicite'=>calculer_contexte_implicite());
32
-	$page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']));
32
+	$page['contexte_implicite']['cache'] = $fond.preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']));
33 33
 	// Cette fonction est utilisee deux fois
34 34
 	$cacher = charger_fonction('cacher', 'public', true);
35 35
 	// Les quatre derniers parametres sont modifies par la fonction:
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	else
40 40
 		$use_cache = -1;
41 41
 	// Si un resultat est retourne, c'est un message d'impossibilite
42
-	if ($res) {return array('texte' => $res);}
42
+	if ($res) {return array('texte' => $res); }
43 43
 
44 44
 	if (!$chemin_cache || !$lastmodified) $lastmodified = time();
45 45
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	AND $chemin_cache
55 55
 	AND isset($page['entetes'])
56 56
 	AND isset($page['entetes']['Cache-Control'])
57
-	AND strstr($page['entetes']['Cache-Control'],'max-age=')
58
-	AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/')
57
+	AND strstr($page['entetes']['Cache-Control'], 'max-age=')
58
+	AND !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
59 59
 	) {
60 60
 		$since = preg_replace('/;.*/', '',
61 61
 			$_SERVER['HTTP_IF_MODIFIED_SINCE']);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		$page['texte'] = "";
74 74
 	} else {
75 75
 		// si la page est prise dans le cache
76
-		if (!$use_cache)  {
76
+		if (!$use_cache) {
77 77
 			// Informer les boutons d'admin du contexte
78 78
 			// (fourni par urls_decoder_url ci-dessous lors de la mise en cache)
79 79
 			$contexte = $page['contexte'];
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 			// et calculer la page
92 92
 			if (!test_espace_prive()) {
93 93
 				include_spip('inc/urls');
94
-				list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true);
94
+				list($fond, $contexte, $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $contexte, true);
95 95
 			}
96 96
 			// squelette par defaut
97 97
 			if (!strlen($fond))
98 98
 				$fond = 'sommaire';
99 99
 
100 100
 			// produire la page : peut mettre a jour $lastmodified
101
-			$produire_page = charger_fonction('produire_page','public');
101
+			$produire_page = charger_fonction('produire_page', 'public');
102 102
 			$page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, NULL, $page, $lastmodified, $connect);
103 103
 			if ($page === '') {
104 104
 				$erreur = _T('info_erreur_squelette2',
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		auto_content_type($page);
115 115
 
116
-		$flag_preserver |=  headers_sent();
116
+		$flag_preserver |= headers_sent();
117 117
 
118 118
 		// Definir les entetes si ce n'est fait 
119 119
 		if (!$flag_preserver) {
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				}
129 129
 				// pas de cache client en mode 'observation'
130 130
 				if (defined('_VAR_MODE') AND _VAR_MODE) {
131
-					$page['entetes']["Cache-Control"]= "no-cache,must-revalidate";
131
+					$page['entetes']["Cache-Control"] = "no-cache,must-revalidate";
132 132
 					$page['entetes']["Pragma"] = "no-cache";
133 133
 				}
134 134
 			}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	if ($lastmodified
142 142
 	AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
143 143
 	AND !isset($page['entetes']["Last-Modified"]))
144
-		$page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT";
144
+		$page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified)." GMT";
145 145
 
146 146
 	// fermer la connexion apres les headers si requete HEAD
147 147
 	if ($headers_only)
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 function calculer_contexte() {
162 162
 
163 163
 	$contexte = array();
164
-	foreach($_GET as $var => $val) {
165
-		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var))
164
+	foreach ($_GET as $var => $val) {
165
+		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var))
166 166
 			$contexte[$var] = $val;
167 167
 	}
168
-	foreach($_POST as $var => $val) {
169
-		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var))
168
+	foreach ($_POST as $var => $val) {
169
+		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var))
170 170
 			$contexte[$var] = $val;
171 171
 	}
172 172
 
@@ -180,18 +180,18 @@  discard block
 block discarded – undo
180 180
  * @staticvar string $notes
181 181
  * @return array
182 182
  */
183
-function calculer_contexte_implicite(){
183
+function calculer_contexte_implicite() {
184 184
 	static $notes = null;
185 185
 	if (is_null($notes))
186
-		$notes = charger_fonction('notes','inc',true);
186
+		$notes = charger_fonction('notes', 'inc', true);
187 187
 	$contexte_implicite = array(
188 188
 		'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ?
189 189
 		'host' => $_SERVER['HTTP_HOST'],
190 190
 		'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''),
191 191
 		'espace' => test_espace_prive(),
192
-		'marqueur' => (isset($GLOBALS['marqueur']) ?  $GLOBALS['marqueur'] : ''),
193
-		'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ?  $GLOBALS['marqueur_skel'] : ''),
194
-		'notes' => $notes?$notes('','contexter_cache'):'',
192
+		'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''),
193
+		'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''),
194
+		'notes' => $notes ? $notes('', 'contexter_cache') : '',
195 195
 		'spip_version_code' => $GLOBALS['spip_version_code'],
196 196
 	);
197 197
 	return $contexte_implicite;
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
 	global $flag_preserver;
208 208
 	if (!isset($flag_preserver))
209 209
 	  {
210
-	    $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type'])));
210
+	    $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx", $page['texte']) || (isset($page['entetes']['Content-Type'])));
211 211
 	  }
212 212
 }
213 213
 
214 214
 // http://doc.spip.org/@inclure_page
215
-function inclure_page($fond, $contexte, $connect='') {
215
+function inclure_page($fond, $contexte, $connect = '') {
216 216
 	static $cacher, $produire_page;
217 217
 	global $lastmodified;
218 218
 
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	else
232 232
 		$use_cache = -1;
233 233
 	// $res = message d'erreur : on sort de la
234
-	if ($res) {return array('texte' => $res);}
234
+	if ($res) {return array('texte' => $res); }
235 235
 
236 236
 	// Si use_cache ne vaut pas 0, la page doit etre calculee
237 237
 	// produire la page : peut mettre a jour $lastinclude
238 238
 	// le contexte_cache envoye a cacher() a ete conserve et est passe a produire
239 239
 	if ($use_cache) {
240 240
 		if (is_null($produire_page))
241
-			$produire_page = charger_fonction('produire_page','public');
241
+			$produire_page = charger_fonction('produire_page', 'public');
242 242
 		$page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect);
243 243
 	}
244 244
 	// dans tous les cas, mettre a jour $lastmodified
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
  * @param string $connect
262 262
  * @return array
263 263
  */
264
-function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){
265
-	static $parametrer,$cacher;
264
+function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect = '') {
265
+	static $parametrer, $cacher;
266 266
 	if (!$parametrer)
267 267
 		$parametrer = charger_fonction('parametrer', 'public');
268 268
 	$page = $parametrer($fond, $contexte, $chemin_cache, $connect);
269 269
 	// et on l'enregistre sur le disque
270 270
 	if ($chemin_cache
271
-	AND $use_cache>-1
271
+	AND $use_cache > -1
272 272
 	AND is_array($page)
273 273
 	AND count($page)
274
-	AND $page['entetes']['X-Spip-Cache'] > 0){
274
+	AND $page['entetes']['X-Spip-Cache'] > 0) {
275 275
 		if (is_null($cacher))
276 276
 			$cacher = charger_fonction('cacher', 'public', true);
277 277
 		$lastinclude = time();
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 // $echo = faut-il faire echo ou return
308 308
 
309 309
 // http://doc.spip.org/@inclure_balise_dynamique
310
-function inclure_balise_dynamique($texte, $echo=true, $contexte_compil=array())
310
+function inclure_balise_dynamique($texte, $echo = true, $contexte_compil = array())
311 311
 {
312 312
 	if (is_array($texte)) {
313 313
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL;
318 318
 		$GLOBALS['delais'] = $delainc;
319 319
 
320
-		$page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil));
320
+		$page = recuperer_fond($fond, $contexte_inclus, array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil));
321 321
 
322 322
 		$texte = $page['texte'];
323 323
 
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 				if (!is_array($GLOBALS['page']['entetes']))
332 332
 					$GLOBALS['page']['entetes'] = array();
333 333
 				$GLOBALS['page']['entetes'] = 
334
-					array_merge($GLOBALS['page']['entetes'],$page['entetes']);
334
+					array_merge($GLOBALS['page']['entetes'], $page['entetes']);
335 335
 			}
336 336
 		}
337 337
 		// _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines
338 338
 		if (isset($page['contexte']['_pipelines'])
339 339
 		  AND is_array($page['contexte']['_pipelines'])
340 340
 			AND count($page['contexte']['_pipelines'])) {
341
-			foreach($page['contexte']['_pipelines'] as $pipe=>$args){
341
+			foreach ($page['contexte']['_pipelines'] as $pipe=>$args) {
342 342
 				$args['contexte'] = $page['contexte'];
343 343
 				unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul
344 344
 				$texte = pipeline(
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
 	if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') {
357 357
 		// compatibilite : avant on donnait le numero de ligne ou rien.
358
-		$ligne =  intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil);
358
+		$ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil);
359 359
 		$GLOBALS['debug_objets']['resultat'][$ligne] = $texte;
360 360
 	}
361 361
 	if ($echo)
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 }
367 367
 
368 368
 // http://doc.spip.org/@message_page_indisponible
369
-function message_page_indisponible ($page, $contexte) {
369
+function message_page_indisponible($page, $contexte) {
370 370
 	static $deja = false;
371 371
 	if ($deja) return "erreur";
372 372
 	$codes = array(
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	$deja = true;
384 384
 	// passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent
385 385
 	// ex restriction d'acces => 401
386
-	$contexte = pipeline('page_indisponible',$contexte);
386
+	$contexte = pipeline('page_indisponible', $contexte);
387 387
 
388 388
 	// produire la page d'erreur
389 389
 	$page = inclure_page($contexte['fond'], $contexte);
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
 function creer_contexte_de_modele($args) {
401 401
 	$contexte = array();
402 402
 	foreach ($args as $var=>$val) {
403
-		if (is_int($var)){ // argument pas formate
403
+		if (is_int($var)) { // argument pas formate
404 404
 			if (in_array($val, array('left', 'right', 'center'))) {
405 405
 				$var = 'align';
406 406
 				$contexte[$var] = $val;
407 407
 			} else {
408 408
 				$args = explode('=', $val);
409
-				if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args
410
-					$contexte[trim($args[0])] = substr($val,strlen($args[0])+1);
409
+				if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args
410
+					$contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1);
411 411
 				else // notation abregee
412 412
 					$contexte[trim($val)] = trim($val);
413 413
 			}
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
 
422 422
 // Calcule le modele et retourne la mini-page ainsi calculee
423 423
 // http://doc.spip.org/@inclure_modele
424
-function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) {
424
+function inclure_modele($type, $id, $params, $lien, $connect = '', $env = array()) {
425 425
 
426 426
 	static $compteur;
427
-	if (++$compteur>10) return ''; # ne pas boucler indefiniment
427
+	if (++$compteur > 10) return ''; # ne pas boucler indefiniment
428 428
 
429 429
 	$type = strtolower($type);
430 430
 
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 				$class = $soustype;
447 447
 			}
448 448
 			// enlever le sous type des params
449
-			$params = array_diff($params,array($soustype));
449
+			$params = array_diff($params, array($soustype));
450 450
 		}
451 451
 	}
452 452
 
453 453
 	// Si ca marche pas en precisant le sous-type, prendre le type
454
-	if (!$fond AND !trouve_modele($fond = $type)){
455
-		spip_log("Modele $type introuvable",_LOG_INFO_IMPORTANTE);
454
+	if (!$fond AND !trouve_modele($fond = $type)) {
455
+		spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE);
456 456
 		return false;
457 457
 	}
458 458
 	$fond = 'modeles/'.$fond;
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 	// Si un lien a ete passe en parametre, ex: [<modele1>->url]
475 475
 	if ($lien) {
476 476
 		# un eventuel guillemet (") sera reechappe par #ENV
477
-		$contexte['lien'] = str_replace("&quot;",'"', $lien['href']);
477
+		$contexte['lien'] = str_replace("&quot;", '"', $lien['href']);
478 478
 		$contexte['lien_class'] = $lien['class'];
479 479
 		$contexte['lien_mime'] = $lien['mime'];
480 480
 		$contexte['lien_title'] = $lien['title'];
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	// par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en>
486 486
 	$arg_list = creer_contexte_de_modele($params);
487 487
 	$contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args
488
-	$contexte = array_merge($contexte,$arg_list);
488
+	$contexte = array_merge($contexte, $arg_list);
489 489
 
490 490
 
491 491
 	// Appliquer le modele avec le contexte
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	// Regarder si le modele tient compte des liens (il *doit* alors indiquer
496 496
 	// spip_lien_ok dans les classes de son conteneur de premier niveau ;
497 497
 	// sinon, s'il y a un lien, on l'ajoute classiquement
498
-	if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ',
498
+	if (strstr(' '.($classes = extraire_attribut($retour, 'class')).' ',
499 499
 	'spip_lien_ok')) {
500 500
 		$retour = inserer_attribut($retour, 'class',
501 501
 			trim(str_replace(' spip_lien_ok ', ' ', " $classes ")));
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 
505 505
 	$compteur--;
506 506
 
507
-	return  (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax')
508
-	? encoder_contexte_ajax($contexte,'',$retour)
507
+	return  (isset($arg_list['ajax']) AND $arg_list['ajax'] == 'ajax')
508
+	? encoder_contexte_ajax($contexte, '', $retour)
509 509
 	: $retour; 
510 510
 }
511 511
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 // pour recuperer $page complet, utiliser:
515 515
 // 	recuperer_fond($fond,$contexte,array('raw'=>true))
516 516
 // http://doc.spip.org/@evaluer_fond
517
-function evaluer_fond ($fond, $contexte=array(), $connect=null) {
517
+function evaluer_fond($fond, $contexte = array(), $connect = null) {
518 518
 
519 519
 	$page = inclure_page($fond, $contexte, $connect);
520 520
 
@@ -536,36 +536,36 @@  discard block
 block discarded – undo
536 536
 
537 537
 
538 538
 // http://doc.spip.org/@page_base_href
539
-function page_base_href(&$texte){
539
+function page_base_href(&$texte) {
540 540
 	static $set_html_base = null;
541
-	if (is_null($set_html_base)){
541
+	if (is_null($set_html_base)) {
542 542
 		if (!defined('_SET_HTML_BASE'))
543 543
 			// si la profondeur est superieure a 1
544 544
 			// est que ce n'est pas une url page ni une url action
545 545
 			// activer par defaut
546 546
 			$set_html_base = ((
547
-				$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2)
547
+				$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
548 548
 				AND _request(_SPIP_PAGE) !== 'login'
549
-				AND !_request('action'))?true:false);
549
+				AND !_request('action')) ? true : false);
550 550
 		else
551 551
 			$set_html_base = _SET_HTML_BASE;
552 552
 	}
553 553
 
554 554
 	if ($set_html_base
555 555
 	  AND isset($GLOBALS['html']) AND $GLOBALS['html']
556
-	  AND $GLOBALS['profondeur_url']>0
557
-	  AND ($poshead = strpos($texte,'</head>'))!==FALSE){
558
-		$head = substr($texte,0,$poshead);
556
+	  AND $GLOBALS['profondeur_url'] > 0
557
+	  AND ($poshead = strpos($texte, '</head>')) !== FALSE) {
558
+		$head = substr($texte, 0, $poshead);
559 559
 		$insert = false;
560
-		if (strpos($head, '<base')===false) 
560
+		if (strpos($head, '<base') === false) 
561 561
 			$insert = true;
562 562
 		else {
563 563
 			// si aucun <base ...> n'a de href c'est bon quand meme !
564 564
 			$insert = true;
565 565
 			include_spip('inc/filtres');
566
-			$bases = extraire_balises($head,'base');
566
+			$bases = extraire_balises($head, 'base');
567 567
 			foreach ($bases as $base)
568
-				if (extraire_attribut($base,'href'))
568
+				if (extraire_attribut($base, 'href'))
569 569
 					$insert = false;
570 570
 		}
571 571
 		if ($insert) {
@@ -574,17 +574,17 @@  discard block
 block discarded – undo
574 574
 			$base = url_absolue('./');
575 575
 			$bbase = "\n<base href=\"$base\" />";
576 576
 			if (($pos = strpos($head, '<head>')) !== false)
577
-				$head = substr_replace($head, $bbase, $pos+6, 0);
578
-			elseif(preg_match(",<head[^>]*>,i",$head,$r)){
577
+				$head = substr_replace($head, $bbase, $pos + 6, 0);
578
+			elseif (preg_match(",<head[^>]*>,i", $head, $r)) {
579 579
 				$head = str_replace($r[0], $r[0].$bbase, $head);
580 580
 			}
581
-			$texte = $head . substr($texte,$poshead);
581
+			$texte = $head.substr($texte, $poshead);
582 582
 			// gerer les ancres
583 583
 			$base = $_SERVER['REQUEST_URI'];
584
-			if (strpos($texte,"href='#")!==false)
585
-				$texte = str_replace("href='#","href='$base#",$texte);
586
-			if (strpos($texte, "href=\"#")!==false)
587
-				$texte = str_replace("href=\"#","href=\"$base#",$texte);
584
+			if (strpos($texte, "href='#") !== false)
585
+				$texte = str_replace("href='#", "href='$base#", $texte);
586
+			if (strpos($texte, "href=\"#") !== false)
587
+				$texte = str_replace("href=\"#", "href=\"$base#", $texte);
588 588
 		}
589 589
 	}
590 590
 }
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 function envoyer_entetes($entetes) {
597 597
 	foreach ($entetes as $k => $v)
598 598
 	#	if (strncmp($k, 'X-Spip-', 7))
599
-			@header(strlen($v)?"$k: $v":$k); 
599
+			@header(strlen($v) ? "$k: $v" : $k); 
600 600
 }
601 601
 
602 602
 ?>
Please login to merge, or discard this patch.
ecrire/public/normaliser.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 		$args = array_shift($p->param);
31 31
 	}
32 32
 
33
-	foreach($p->param as $couple) {
33
+	foreach ($p->param as $couple) {
34 34
 		$nom = trim($couple[0]);
35
-		if ($nom == '')  {array_shift($p->param); break;}
35
+		if ($nom == '') {array_shift($p->param); break; }
36 36
 		$r = phraser_logo_faux_filtres($nom);
37 37
 		if ($r === 0) {
38 38
 			$c = new Texte;
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 				if ($m[6]) {
59 59
 				  $r = new Texte;
60 60
 				  $r->texte = $m[6];
61
-				  $champ[]= $r;
61
+				  $champ[] = $r;
62 62
 				}
63
-				$args[]= $champ;
63
+				$args[] = $champ;
64 64
 				array_shift($p->param);
65 65
 				spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
66 66
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
 function phraser_logo_faux_filtres($nom)
75 75
 {
76
-	switch($nom) {
76
+	switch ($nom) {
77 77
 	case 'top':
78 78
 	case 'left':
79 79
 	case 'right':
@@ -91,20 +91,20 @@  discard block
 block discarded – undo
91 91
 function phraser_vieux_emb(&$p)
92 92
 {
93 93
 	if (!is_array($p->param))
94
-		$p->param=array();
94
+		$p->param = array();
95 95
 
96 96
 	// Produire le premier argument {emb}
97 97
 	$texte = new Texte;
98
-	$texte->texte='emb';
98
+	$texte->texte = 'emb';
99 99
 	$param = array('', array($texte));
100 100
 
101 101
 	// Transformer les filtres en arguments
102
-	for ($i=0; $i<count($p->param); $i++) {
102
+	for ($i = 0; $i < count($p->param); $i++) {
103 103
 		if ($p->param[$i][0]) {
104 104
 			if (!strstr($p->param[$i][0], '='))
105
-				break;# on a rencontre un vrai filtre, c'est fini
105
+				break; # on a rencontre un vrai filtre, c'est fini
106 106
 			$texte = new Texte;
107
-			$texte->texte=$p->param[$i][0];
107
+			$texte->texte = $p->param[$i][0];
108 108
 			$param[] = array($texte);
109 109
 		}
110 110
 		array_shift($p->param);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		$p->param[0][1] = array($c);
125 125
 		$p->param[0][0] = '';
126 126
 		$p->fonctions = array();
127
-		spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte, 'vieilles_defs');
127
+		spip_log('FORMULAIRE_RECHERCHE avec filtre '.$c->texte, 'vieilles_defs');
128 128
 	}
129 129
 }
130 130
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 }
152 152
 
153
-function phraser_vieux_modele($p)  {normaliser_args_inclumodel($p);}
154
-function phraser_vieux_inclu($p) {normaliser_args_inclumodel($p);}
153
+function phraser_vieux_modele($p) {normaliser_args_inclumodel($p); }
154
+function phraser_vieux_inclu($p) {normaliser_args_inclumodel($p); }
155 155
 
156 156
 function normaliser_args_inclumodel($p)
157 157
 {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	if ($args[0]) return; // filtre immediat
162 162
 	array_shift($p->param);
163 163
 	foreach ($p->param as $l) {
164
-		if (!array_shift($l))  {
164
+		if (!array_shift($l)) {
165 165
 			$args = array_merge($args, $l);
166 166
 			array_shift($p->param);
167 167
 		} else  break; // filtre
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 	$l = $champ->param[0];
176 176
 	if (is_array($l) AND !$l[0]) {
177 177
 	  foreach ($l as $k => $p) {
178
-	    if ($p AND $p[0]->type == 'texte' AND !strpos($p[0]->texte,'=')) {
178
+	    if ($p AND $p[0]->type == 'texte' AND !strpos($p[0]->texte, '=')) {
179 179
 	      $p[0]->texte = trim($p[0]->texte);
180 180
 	      }
181 181
 	  }
182 182
 	  foreach ($l as $k => $p) {
183 183
 		if (!$p OR $p[0]->type != 'texte' OR 
184
-		    !preg_match('/^fond\s*=\s*(.*)$/',$p[0]->texte, $r))
184
+		    !preg_match('/^fond\s*=\s*(.*)$/', $p[0]->texte, $r))
185 185
 			continue;
186 186
 
187 187
 		if ($r[1])
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		else unset($p[0]);
190 190
 		$champ->texte = $p;
191 191
 		unset($champ->param[0][$k]);
192
-		if (count($champ->param[0]) ==1) 
192
+		if (count($champ->param[0]) == 1) 
193 193
 			array_shift($champ->param);
194 194
 		return;
195 195
 	  }
Please login to merge, or discard this patch.