Completed
Push — spip-3.0 ( 484b62...e817f1 )
by cam
34:33
created
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/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.
ecrire/public/interfaces.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	/**
169 169
 	 * Identifiant de la boucle parente
170 170
 	 * @var string */
171
-	public $id_parent ='';
171
+	public $id_parent = '';
172 172
 
173 173
 	/**
174 174
 	 * Partie optionnelle avant
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 * @var string|null */
255 255
 	public $doublons;
256 256
 
257
-	var $partie, $total_parties,$mode_partie='';
257
+	var $partie, $total_parties, $mode_partie = '';
258 258
 	var $externe = ''; # appel a partir d'une autre boucle (recursion)
259 259
 	// champs pour la construction de la requete SQL
260 260
 	var $select = array();
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
 	var $group = array();
268 268
 	var $order = array();
269 269
 	var $default_order = array();
270
-	var $date = 'date' ;
271
-	var $hash = "" ;
272
-	var $in = "" ;
270
+	var $date = 'date';
271
+	var $hash = "";
272
+	var $in = "";
273 273
 	var $sous_requete = false;
274 274
 	var $hierarchie = '';
275 275
 	var $statut = false; # definition/surcharge du statut des elements retournes
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	/**
376 376
 	 * Identifiant de la boucle parente si explicité
377 377
 	 * @var string|null */
378
-	public $nom_boucle= '';
378
+	public $nom_boucle = '';
379 379
 
380 380
 	/**
381 381
 	 * Partie optionnelle avant
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 
587 587
 
588 588
 global $table_criteres_infixes;
589
-$table_criteres_infixes = array('<', '>', '<=', '>=', '==', '===', '!=', '!==', '<>',  '?');
589
+$table_criteres_infixes = array('<', '>', '<=', '>=', '==', '===', '!=', '!==', '<>', '?');
590 590
 
591 591
 global $exception_des_connect;
592 592
 $exception_des_connect[] = ''; // ne pas transmettre le connect='' par les inclure
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
  *
606 606
  * @return void
607 607
  */
608
-function declarer_interfaces(){
608
+function declarer_interfaces() {
609 609
 	global $exceptions_des_tables, $table_des_tables, $table_date, $table_titre, $table_statut;
610 610
 
611
-	$table_des_tables['articles']='articles';
612
-	$table_des_tables['auteurs']='auteurs';
613
-	$table_des_tables['rubriques']='rubriques';
614
-	$table_des_tables['hierarchie']='rubriques';
611
+	$table_des_tables['articles'] = 'articles';
612
+	$table_des_tables['auteurs'] = 'auteurs';
613
+	$table_des_tables['rubriques'] = 'rubriques';
614
+	$table_des_tables['hierarchie'] = 'rubriques';
615 615
 
616 616
 	// definition des statuts de publication
617 617
 	global $tables_statut;
@@ -634,35 +634,35 @@  discard block
 block discarded – undo
634 634
 	define('_TRAITEMENT_RACCOURCIS', 'propre(%s, $connect, $Pile[0])');
635 635
 	define('_TRAITEMENT_TYPO_SANS_NUMERO', 'typo(supprimer_numero(%s), "TYPO", $connect, $Pile[0])');
636 636
 
637
-	$table_des_traitements['BIO'][]= _TRAITEMENT_RACCOURCIS;
638
-	$table_des_traitements['CHAPO'][]= _TRAITEMENT_RACCOURCIS;
639
-	$table_des_traitements['DATE'][]= 'normaliser_date(%s)';
640
-	$table_des_traitements['DATE_REDAC'][]= 'normaliser_date(%s)';
641
-	$table_des_traitements['DATE_MODIF'][]= 'normaliser_date(%s)';
642
-	$table_des_traitements['DATE_NOUVEAUTES'][]= 'normaliser_date(%s)';
643
-	$table_des_traitements['DESCRIPTIF'][]= _TRAITEMENT_RACCOURCIS;
644
-	$table_des_traitements['INTRODUCTION'][]= 'PtoBR('. _TRAITEMENT_RACCOURCIS .')';
645
-	$table_des_traitements['NOM_SITE_SPIP'][]= _TRAITEMENT_TYPO;
646
-	$table_des_traitements['NOM'][]= _TRAITEMENT_TYPO_SANS_NUMERO;
647
-	$table_des_traitements['AUTEUR'][]= _TRAITEMENT_TYPO;
648
-	$table_des_traitements['PS'][]= _TRAITEMENT_RACCOURCIS;
649
-	$table_des_traitements['SOURCE'][]= _TRAITEMENT_TYPO;
650
-	$table_des_traitements['SOUSTITRE'][]= _TRAITEMENT_TYPO;
651
-	$table_des_traitements['SURTITRE'][]= _TRAITEMENT_TYPO;
652
-	$table_des_traitements['TAGS'][]= '%s';
653
-	$table_des_traitements['TEXTE'][]= _TRAITEMENT_RACCOURCIS;
654
-	$table_des_traitements['TITRE'][]= _TRAITEMENT_TYPO_SANS_NUMERO;
655
-	$table_des_traitements['TYPE'][]= _TRAITEMENT_TYPO;
656
-	$table_des_traitements['DESCRIPTIF_SITE_SPIP'][]= _TRAITEMENT_RACCOURCIS;
657
-	$table_des_traitements['SLOGAN_SITE_SPIP'][]= _TRAITEMENT_TYPO;
658
-	$table_des_traitements['ENV'][]= 'entites_html(%s,true)';
637
+	$table_des_traitements['BIO'][] = _TRAITEMENT_RACCOURCIS;
638
+	$table_des_traitements['CHAPO'][] = _TRAITEMENT_RACCOURCIS;
639
+	$table_des_traitements['DATE'][] = 'normaliser_date(%s)';
640
+	$table_des_traitements['DATE_REDAC'][] = 'normaliser_date(%s)';
641
+	$table_des_traitements['DATE_MODIF'][] = 'normaliser_date(%s)';
642
+	$table_des_traitements['DATE_NOUVEAUTES'][] = 'normaliser_date(%s)';
643
+	$table_des_traitements['DESCRIPTIF'][] = _TRAITEMENT_RACCOURCIS;
644
+	$table_des_traitements['INTRODUCTION'][] = 'PtoBR('._TRAITEMENT_RACCOURCIS.')';
645
+	$table_des_traitements['NOM_SITE_SPIP'][] = _TRAITEMENT_TYPO;
646
+	$table_des_traitements['NOM'][] = _TRAITEMENT_TYPO_SANS_NUMERO;
647
+	$table_des_traitements['AUTEUR'][] = _TRAITEMENT_TYPO;
648
+	$table_des_traitements['PS'][] = _TRAITEMENT_RACCOURCIS;
649
+	$table_des_traitements['SOURCE'][] = _TRAITEMENT_TYPO;
650
+	$table_des_traitements['SOUSTITRE'][] = _TRAITEMENT_TYPO;
651
+	$table_des_traitements['SURTITRE'][] = _TRAITEMENT_TYPO;
652
+	$table_des_traitements['TAGS'][] = '%s';
653
+	$table_des_traitements['TEXTE'][] = _TRAITEMENT_RACCOURCIS;
654
+	$table_des_traitements['TITRE'][] = _TRAITEMENT_TYPO_SANS_NUMERO;
655
+	$table_des_traitements['TYPE'][] = _TRAITEMENT_TYPO;
656
+	$table_des_traitements['DESCRIPTIF_SITE_SPIP'][] = _TRAITEMENT_RACCOURCIS;
657
+	$table_des_traitements['SLOGAN_SITE_SPIP'][] = _TRAITEMENT_TYPO;
658
+	$table_des_traitements['ENV'][] = 'entites_html(%s,true)';
659 659
 
660 660
 	// valeur par defaut pour les balises non listees ci-dessus
661
-	$table_des_traitements['*'][]= false; // pas de traitement, mais permet au compilo de trouver la declaration suivante
661
+	$table_des_traitements['*'][] = false; // pas de traitement, mais permet au compilo de trouver la declaration suivante
662 662
 	// toujours securiser les DATA
663
-	$table_des_traitements['*']['DATA']= 'safehtml(%s)';
663
+	$table_des_traitements['*']['DATA'] = 'safehtml(%s)';
664 664
 	// expliciter pour VALEUR qui est un champ calcule et ne sera pas protege par le catch-all *
665
-	$table_des_traitements['VALEUR']['DATA']= 'safehtml(%s)';
665
+	$table_des_traitements['VALEUR']['DATA'] = 'safehtml(%s)';
666 666
 
667 667
 
668 668
 	// gerer l'affectation en 2 temps car si le pipe n'est pas encore declare, on ecrase les globales
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 			'table_des_traitements'=>$table_des_traitements,
678 678
 			'table_statut'=>$table_statut,
679 679
 			));
680
-	if ($interfaces){
680
+	if ($interfaces) {
681 681
 			$table_des_tables = $interfaces['table_des_tables'];
682 682
 			$exceptions_des_tables = $interfaces['exceptions_des_tables'];
683 683
 			$table_date = $interfaces['table_date'];
Please login to merge, or discard this patch.
ecrire/public/balises.php 1 patch
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 if (!defined('_ECRIRE_INC_VERSION')) return;
21 21
 
22 22
 // http://doc.spip.org/@interprete_argument_balise
23
-function interprete_argument_balise($n,$p) {
24
-	if (($p->param) && (!$p->param[0][0]) && (count($p->param[0])>$n))
23
+function interprete_argument_balise($n, $p) {
24
+	if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n))
25 25
 		return calculer_liste($p->param[0][$n],
26 26
 			$p->descr,
27 27
 			$p->boucles,
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 // quand #DATE est en dehors des boucles
97 97
 // http://www.spip.net/fr_article1971.html
98 98
 // http://doc.spip.org/@balise_DATE_dist
99
-function balise_DATE_dist ($p) {
99
+function balise_DATE_dist($p) {
100 100
 	$d = champ_sql('date', $p);
101 101
 #	if ($d === "@\$Pile[0]['date']")
102 102
 #		$d = "isset(\$Pile[0]['date']) ? $d : time()";
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 // #DATE_REDAC
108 108
 // http://www.spip.net/fr_article1971.html
109 109
 // http://doc.spip.org/@balise_DATE_REDAC_dist
110
-function balise_DATE_REDAC_dist ($p) {
110
+function balise_DATE_REDAC_dist($p) {
111 111
 	$d = champ_sql('date_redac', $p);
112 112
 #	if ($d === "@\$Pile[0]['date_redac']")
113 113
 #		$d = "isset(\$Pile[0]['date_redac']) ? $d : time()";
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 // #DATE_MODIF
120 120
 // http://www.spip.net/fr_article1971.html
121 121
 // http://doc.spip.org/@balise_DATE_MODIF_dist
122
-function balise_DATE_MODIF_dist ($p) {
122
+function balise_DATE_MODIF_dist($p) {
123 123
 	$p->code = champ_sql('date_modif', $p);
124 124
 	$p->interdire_scripts = false;
125 125
 	return $p;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 // http://doc.spip.org/@balise_DOSSIER_SQUELETTE_dist
141 141
 function balise_DOSSIER_SQUELETTE_dist($p) {
142 142
 	$code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));
143
-	$p->code = "_DIR_RACINE . '$code'" .
143
+	$p->code = "_DIR_RACINE . '$code'".
144 144
 	$p->interdire_scripts = false;
145 145
 	return $p;
146 146
 }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 // http://doc.spip.org/@balise_SQUELETTE_dist
149 149
 function balise_SQUELETTE_dist($p) {
150 150
 	$code = addslashes($p->descr['sourcefile']);
151
-	$p->code = "'$code'" .
151
+	$p->code = "'$code'".
152 152
 	$p->interdire_scripts = false;
153 153
 	return $p;
154 154
 }
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
 **/
184 184
 function balise_NOM_SITE_dist($p) {
185 185
 	if (!$p->etoile) {
186
-		$p->code = "supprimer_numero(calculer_url(" .
187
-		champ_sql('url_site',$p) ."," .
188
-		champ_sql('nom_site',$p) .
186
+		$p->code = "supprimer_numero(calculer_url(".
187
+		champ_sql('url_site', $p).",".
188
+		champ_sql('nom_site', $p).
189 189
 		", 'titre', \$connect, false))";
190 190
 	} else
191
-		$p->code = champ_sql('nom_site',$p);
191
+		$p->code = champ_sql('nom_site', $p);
192 192
 
193 193
 	$p->interdire_scripts = true;
194 194
 	return $p;
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	$b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];
231 231
 	if ($b === '' || !isset($p->boucles[$b])) {
232 232
 		$msg = array('zbug_champ_hors_boucle',
233
-				array('champ' => "#$b" . 'TOTAL_BOUCLE')
233
+				array('champ' => "#$b".'TOTAL_BOUCLE')
234 234
 			  );
235 235
 		erreur_squelette($msg, $p);
236 236
 	} else {
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 
250 250
 // http://doc.spip.org/@balise_POPULARITE_ABSOLUE_dist
251 251
 function balise_POPULARITE_ABSOLUE_dist($p) {
252
-	$p->code = 'ceil(' .
253
-	champ_sql('popularite', $p) .
252
+	$p->code = 'ceil('.
253
+	champ_sql('popularite', $p).
254 254
 	')';
255 255
 	$p->interdire_scripts = false;
256 256
 	return $p;
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 // http://doc.spip.org/@balise_EXPOSE_dist
274 274
 function balise_EXPOSE_dist($p) {
275 275
 	$on = "'on'";
276
-	$off= "''";
277
-	if (($v = interprete_argument_balise(1,$p))!==NULL){
276
+	$off = "''";
277
+	if (($v = interprete_argument_balise(1, $p)) !== NULL) {
278 278
 		$on = $v;
279
-		if (($v = interprete_argument_balise(2,$p))!==NULL)
279
+		if (($v = interprete_argument_balise(2, $p)) !== NULL)
280 280
 			$off = $v;
281 281
 
282 282
 	}
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 // http://doc.spip.org/@balise_VALEUR_dist
290 290
 function balise_VALEUR_dist($p) {
291 291
 	$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
292
-	$p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;
293
-	if (($v = interprete_argument_balise(1,$p))!==NULL){
292
+	$p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); ;
293
+	if (($v = interprete_argument_balise(1, $p)) !== NULL) {
294 294
 		$p->code = 'table_valeur('.$p->code.', '.$v.')';
295 295
 	}
296 296
 	$p->interdire_scripts = true;
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 		$parent = 0; // pour if (!$parent) dans calculer_expose
319 319
 	} elseif (isset($desc['field']['id_rubrique'])) {
320 320
 		$parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b);
321
-	} elseif  (isset($desc['field']['id_groupe'])) {
321
+	} elseif (isset($desc['field']['id_groupe'])) {
322 322
 		$parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b);
323 323
 	} else $parent = "''";
324 324
 
@@ -337,13 +337,13 @@  discard block
 block discarded – undo
337 337
 // http://doc.spip.org/@balise_DEBUT_SURLIGNE_dist
338 338
 function balise_DEBUT_SURLIGNE_dist($p) {
339 339
 	include_spip('inc/surligne');
340
-	$p->code = "'<!-- " . MARQUEUR_SURLIGNE . " -->'";
340
+	$p->code = "'<!-- ".MARQUEUR_SURLIGNE." -->'";
341 341
 	return $p;
342 342
 }
343 343
 // http://doc.spip.org/@balise_FIN_SURLIGNE_dist
344 344
 function balise_FIN_SURLIGNE_dist($p) {
345 345
 	include_spip('inc/surligne');
346
-	$p->code = "'<!-- " . MARQUEUR_FSURLIGNE . "-->'";
346
+	$p->code = "'<!-- ".MARQUEUR_FSURLIGNE."-->'";
347 347
 	return $p;
348 348
 }
349 349
 
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	}
368 368
 
369 369
 	// longueur en parametre, ou valeur par defaut
370
-	if (($v = interprete_argument_balise(1,$p))!==NULL) {
370
+	if (($v = interprete_argument_balise(1, $p)) !== NULL) {
371 371
 		$longueur = 'intval('.$v.')';
372 372
 	} else {
373 373
 		switch ($type) {
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 // (celle du site ou celle qui a ete passee dans l'URL par le visiteur)
399 399
 // #LANG* n'affiche rien si aucune langue n'est trouvee dans le sql/le contexte
400 400
 // http://doc.spip.org/@balise_LANG_dist
401
-function balise_LANG_dist ($p) {
401
+function balise_LANG_dist($p) {
402 402
 	$_lang = champ_sql('lang', $p);
403 403
 	if (!$p->etoile)
404 404
 		$p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 // http://www.spip.net/fr_article902.html
414 414
 // http://www.spip.net/fr_article911.html
415 415
 // http://doc.spip.org/@balise_LESAUTEURS_dist
416
-function balise_LESAUTEURS_dist ($p) {
416
+function balise_LESAUTEURS_dist($p) {
417 417
 	// Cherche le champ 'lesauteurs' dans la pile
418 418
 	$_lesauteurs = champ_sql('lesauteurs', $p, false);
419 419
 
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
 		$p->code = "safehtml($_lesauteurs)";
427 427
 		// $p->interdire_scripts = true;
428 428
 	} else {
429
-		if(!$p->id_boucle){
429
+		if (!$p->id_boucle) {
430 430
 			$connect = '';
431 431
 			$objet = 'article';
432 432
 			$id_table_objet = 'id_article';
433 433
 		}
434
-		else{
434
+		else {
435 435
 			$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
436 436
 			$connect = $p->boucles[$b]->sql_serveur;
437 437
 			$type_boucle = $p->boucles[$b]->type_requete;
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 
443 443
 		$p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",
444 444
 				   "array('objet'=>'".$objet.
445
-					   "','id_objet' => ".champ_sql($id_table_objet, $p) .
446
-					   ",'$id_table_objet' => ".champ_sql($id_table_objet, $p) .
447
-					   ($objet=='article'?"":",'id_article' => ".champ_sql('id_article', $p)).
445
+					   "','id_objet' => ".champ_sql($id_table_objet, $p).
446
+					   ",'$id_table_objet' => ".champ_sql($id_table_objet, $p).
447
+					   ($objet == 'article' ? "" : ",'id_article' => ".champ_sql('id_article', $p)).
448 448
 					   ")",
449 449
 				   "'trim'=>true, 'compil'=>array($c)",
450 450
 				   _q($connect));
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 					$m = trim($m);
505 505
 					if ($m != "''") {
506 506
 						if (!preg_match(",\W,", $m)) {
507
-							$m = $boucle->id_table . ".$m";
507
+							$m = $boucle->id_table.".$m";
508 508
 						}
509 509
 						
510 510
 						$m .= " AS titre_rang";
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 // #POPULARITE
535 535
 // http://www.spip.net/fr_article1846.html
536 536
 // http://doc.spip.org/@balise_POPULARITE_dist
537
-function balise_POPULARITE_dist ($p) {
537
+function balise_POPULARITE_dist($p) {
538 538
 	$_popularite = champ_sql('popularite', $p);
539 539
 	$p->code = "(ceil(min(100, 100 * $_popularite
540 540
 	/ max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))";
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 
556 556
 // http://www.spip.net/fr_article3367.html
557 557
 // http://doc.spip.org/@balise_PAGINATION_dist
558
-function balise_PAGINATION_dist($p, $liste='true') {
558
+function balise_PAGINATION_dist($p, $liste = 'true') {
559 559
 	$b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];
560 560
 
561 561
 	// s'il n'y a pas de nom de boucle, on ne peut pas paginer
@@ -583,16 +583,16 @@  discard block
 block discarded – undo
583 583
 	// si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise
584 584
 	// si true, les arguments simples (sans truc=chose) vont degager
585 585
 	$_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false);
586
-	if (count($_contexte)){
587
-		list($key,$val) = each($_contexte);
588
-		if (is_numeric($key)){
586
+	if (count($_contexte)) {
587
+		list($key, $val) = each($_contexte);
588
+		if (is_numeric($key)) {
589 589
 			array_shift($_contexte);
590
-			$__modele = interprete_argument_balise(1,$p);
590
+			$__modele = interprete_argument_balise(1, $p);
591 591
 		}
592 592
 	}
593 593
 
594
-	if (count($_contexte)){
595
-		$code_contexte = implode(',',$_contexte);
594
+	if (count($_contexte)) {
595
+		$code_contexte = implode(',', $_contexte);
596 596
 	}
597 597
 	else
598 598
 		$code_contexte = '';
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
 	$pas = $p->boucles[$b]->total_parties;
602 602
 	$f_pagination = chercher_filtre('pagination');
603 603
 	$type = $p->boucles[$b]->modificateur['debut_nom'];
604
-	$modif = ($type[0]!=="'") ? "'debut'.$type"
605
-	  : ("'debut" .substr($type,1));
604
+	$modif = ($type[0] !== "'") ? "'debut'.$type"
605
+	  : ("'debut".substr($type, 1));
606 606
 
607 607
 	$p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste, ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);
608 608
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 // http://doc.spip.org/@balise_ANCRE_PAGINATION_dist
618 618
 function balise_ANCRE_PAGINATION_dist($p) {
619 619
 	if ($f = charger_fonction('PAGINATION', 'balise', true))
620
-		return $f($p, $liste='false');
620
+		return $f($p, $liste = 'false');
621 621
 	else return NULL; // ou une erreur ?
622 622
 }
623 623
 
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 	$b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];
629 629
 	if ($b === '' || !isset($p->boucles[$b])) {
630 630
 		$msg = array('zbug_champ_hors_boucle',
631
-				array('champ' => "#$b" . 'TOTAL_BOUCLE')
631
+				array('champ' => "#$b".'TOTAL_BOUCLE')
632 632
 			   );
633 633
 		erreur_squelette($msg, $p);
634 634
 	} else {
@@ -657,23 +657,23 @@  discard block
 block discarded – undo
657 657
 //
658 658
 // http://doc.spip.org/@balise_CHEMIN_dist
659 659
 function balise_CHEMIN_dist($p) {
660
-	$arg = interprete_argument_balise(1,$p);
660
+	$arg = interprete_argument_balise(1, $p);
661 661
 	if (!$arg) {
662
-		$msg = array('zbug_balise_sans_argument',	array('balise' => ' CHEMIN'));
662
+		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN'));
663 663
 		erreur_squelette($msg, $p);
664 664
 	} else
665
-	  $p->code = 'find_in_path(' . $arg .')';
665
+	  $p->code = 'find_in_path('.$arg.')';
666 666
 
667 667
 	#$p->interdire_scripts = true;
668 668
 	return $p;
669 669
 }
670 670
 
671 671
 function balise_CHEMIN_IMAGE_dist($p) {
672
-	$arg = interprete_argument_balise(1,$p);
672
+	$arg = interprete_argument_balise(1, $p);
673 673
 	if (!$arg) {
674 674
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE'));
675 675
 		erreur_squelette($msg, $p);
676
-	} else $p->code = 'chemin_image(' . $arg .')';
676
+	} else $p->code = 'chemin_image('.$arg.')';
677 677
 
678 678
 	#$p->interdire_scripts = true;
679 679
 	return $p;
@@ -719,9 +719,9 @@  discard block
 block discarded – undo
719 719
 function balise_ENV_dist($p, $src = NULL) {
720 720
 
721 721
 	// cle du tableau desiree
722
-	$_nom = interprete_argument_balise(1,$p);
722
+	$_nom = interprete_argument_balise(1, $p);
723 723
 	// valeur par defaut
724
-	$_sinon = interprete_argument_balise(2,$p);
724
+	$_sinon = interprete_argument_balise(2, $p);
725 725
 	
726 726
 	// $src est un tableau de donnees sources eventuellement transmis
727 727
 	// en absence, on utilise l'environnement du squelette $Pile[0]
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
  * @return Object
767 767
  */
768 768
 function balise_CONFIG_dist($p) {
769
-	if (!$arg = interprete_argument_balise(1,$p)) {
769
+	if (!$arg = interprete_argument_balise(1, $p)) {
770 770
 		$arg = "''";
771 771
 	}
772
-	$_sinon = interprete_argument_balise(2,$p);
773
-	$_unserialize = sinon(interprete_argument_balise(3,$p),"false");
772
+	$_sinon = interprete_argument_balise(2, $p);
773
+	$_unserialize = sinon(interprete_argument_balise(3, $p), "false");
774 774
 
775
-	$p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' .
776
-		($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";
775
+	$p->code = '(include_spip(\'inc/config\')?lire_config('.$arg.','.
776
+		($_sinon && $_sinon != "''" ? $_sinon : 'null').','.$_unserialize."):'')";
777 777
 
778 778
 	return $p;
779 779
 }
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 // Ajoute x=y dans la session du visiteur
810 810
 // http://doc.spip.org/@balise_SESSION_SET_dist
811 811
 function balise_SESSION_SET_dist($p) {
812
-	$_nom = interprete_argument_balise(1,$p);
813
-	$_val = interprete_argument_balise(2,$p);
812
+	$_nom = interprete_argument_balise(1, $p);
813
+	$_val = interprete_argument_balise(2, $p);
814 814
 	if (!$_nom OR !$_val) {
815 815
 		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET'));
816 816
 		erreur_squelette($err_b_s_a, $p);
@@ -836,12 +836,12 @@  discard block
 block discarded – undo
836 836
 // #EVAL{'str_replace("r","z", "roger")'}  (attention les "'" sont interdits)
837 837
 // http://doc.spip.org/@balise_EVAL_dist
838 838
 function balise_EVAL_dist($p) {
839
-	$php = interprete_argument_balise(1,$p);
839
+	$php = interprete_argument_balise(1, $p);
840 840
 	if ($php) {
841 841
 		# optimisation sur les #EVAL{une expression sans #BALISE}
842 842
 		# attention au commentaire "// x signes" qui precede
843 843
 		if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms",
844
-		$php,$r))
844
+		$php, $r))
845 845
 			$p->code = /* $r[1]. */'('.$r[2].')';
846 846
 		else
847 847
 			$p->code = "eval('return '.$php.';')";
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 // (impossible via #NOTES qui est une balise calculee)
861 861
 // ne permet pas de passer une expression pour x qui ne peut etre qu'un texte statique !
862 862
 // http://doc.spip.org/@balise_CHAMP_SQL_dist
863
-function balise_CHAMP_SQL_dist($p){
863
+function balise_CHAMP_SQL_dist($p) {
864 864
 
865 865
 	if ($p->param
866 866
 	AND isset($p->param[0][1][0])
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 // #VAL{x} renvoie 'x' (permet d'appliquer un filtre a une chaine)
878 878
 // Attention #VAL{1,2} renvoie '1', indiquer #VAL{'1,2'}
879 879
 // http://doc.spip.org/@balise_VAL_dist
880
-function balise_VAL_dist($p){
881
-	$p->code = interprete_argument_balise(1,$p);
880
+function balise_VAL_dist($p) {
881
+	$p->code = interprete_argument_balise(1, $p);
882 882
 	if (!strlen($p->code))
883 883
 		$p->code = "''";
884 884
 	$p->interdire_scripts = false;
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 //
895 895
 // http://doc.spip.org/@balise_REM_dist
896 896
 function balise_REM_dist($p) {
897
-	$p->code="''";
897
+	$p->code = "''";
898 898
 	$p->interdire_scripts = false;
899 899
 	return $p;
900 900
 }
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 	if ($p->param) {
945 945
 		$args = array();
946 946
 		foreach ($p->param as $i => $ignore)
947
-			$args[] = interprete_argument_balise($i+1,$p);
947
+			$args[] = interprete_argument_balise($i + 1, $p);
948 948
 		$p->code = "'<' . '"
949 949
 			.'?php header("X-Spip-Filtre: \'.'
950 950
 				.join('.\'|\'.', $args)
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 // (Incompatible avec les balises dynamiques)
1062 1062
 // http://doc.spip.org/@balise_INCLUDE_dist
1063 1063
 function balise_INCLUDE_dist($p) {
1064
-	if(function_exists('balise_INCLURE'))
1064
+	if (function_exists('balise_INCLURE'))
1065 1065
 		return balise_INCLURE($p);
1066 1066
 	else
1067 1067
 		return balise_INCLURE_dist($p);
@@ -1103,21 +1103,21 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
 		$_options = array();
1105 1105
 		if (isset($_contexte['ajax'])) {
1106
-			$_options[] = preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']);
1106
+			$_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
1107 1107
 			unset($_contexte['ajax']);
1108 1108
 		}
1109 1109
 		if ($p->etoile) $_options[] = "'etoile'=>true";
1110
-		$_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) .")";
1110
+		$_options[] = "'compil'=>array(".memoriser_contexte_compil($p).")";
1111 1111
 
1112
-		$_l = 'array(' . join(",\n\t", $_contexte) .')';
1112
+		$_l = 'array('.join(",\n\t", $_contexte).')';
1113 1113
 		if ($flag_env) $_l = "array_merge(\$Pile[0],$_l)";
1114 1114
 
1115
-		$p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',',$_options),"''");
1115
+		$p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "''");
1116 1116
 
1117 1117
 	} elseif (!isset($_contexte[1])) {
1118 1118
 			$msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE'));
1119 1119
 			erreur_squelette($msg, $p);
1120
-	} else 		$p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
1120
+	} else 		$p->code = 'charge_scripts('.$_contexte[1].',false)';
1121 1121
 
1122 1122
 	$p->interdire_scripts = false; // la securite est assuree par recuperer_fond
1123 1123
 	return $p;
@@ -1141,14 +1141,14 @@  discard block
 block discarded – undo
1141 1141
 		unset($_contexte[1]);
1142 1142
 
1143 1143
 		if (preg_match("/^\s*'[^']*'/s", $nom))
1144
-			$nom = "'modeles/" . substr($nom,1);
1144
+			$nom = "'modeles/".substr($nom, 1);
1145 1145
 		else $nom = "'modeles/' . $nom";
1146 1146
 
1147 1147
 		// Incoherence dans la syntaxe du contexte. A revoir.
1148 1148
 		// Reserver la cle primaire de la boucle courante si elle existe
1149 1149
 		if (isset($p->boucles[$p->id_boucle]->primary)) {
1150 1150
 			$primary = $p->boucles[$p->id_boucle]->primary;
1151
-			if (!strpos($primary,',')) {
1151
+			if (!strpos($primary, ',')) {
1152 1152
 				$id = champ_sql($primary, $p);
1153 1153
 				$_contexte[] = "'$primary'=>".$id;
1154 1154
 				$_contexte[] = "'id'=>".$id;
@@ -1161,12 +1161,12 @@  discard block
 block discarded – undo
1161 1161
 
1162 1162
 		$_options = memoriser_contexte_compil($p);
1163 1163
 		$_options = "'compil'=>array($_options), 'trim'=>true";
1164
-	  if (isset($_contexte['ajax'])){
1165
-		  $_options .= ", ".preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']);
1164
+	  if (isset($_contexte['ajax'])) {
1165
+		  $_options .= ", ".preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
1166 1166
 			unset($_contexte['ajax']);
1167 1167
 	  }
1168 1168
 
1169
-		$page = sprintf(CODE_RECUPERER_FOND, $nom, 'array(' . join(',', $_contexte) .')', $_options, _q($connect));
1169
+		$page = sprintf(CODE_RECUPERER_FOND, $nom, 'array('.join(',', $_contexte).')', $_options, _q($connect));
1170 1170
 
1171 1171
 		$p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n";
1172 1172
 
@@ -1182,9 +1182,9 @@  discard block
 block discarded – undo
1182 1182
 // #SET{nom,valeur}
1183 1183
 // la balise renvoie la valeur
1184 1184
 // http://doc.spip.org/@balise_SET_dist
1185
-function balise_SET_dist($p){
1186
-	$_nom = interprete_argument_balise(1,$p);
1187
-	$_val = interprete_argument_balise(2,$p);
1185
+function balise_SET_dist($p) {
1186
+	$_nom = interprete_argument_balise(1, $p);
1187
+	$_val = interprete_argument_balise(2, $p);
1188 1188
 
1189 1189
 	if (!$_nom OR !$_val) {
1190 1190
 		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET'));
@@ -1229,13 +1229,13 @@  discard block
 block discarded – undo
1229 1229
  * 		Pile complétée par le code à générer
1230 1230
 **/
1231 1231
 function balise_DOUBLONS_dist($p) {
1232
-	if ($type = interprete_argument_balise(1,$p)) {
1233
-		if ($famille = interprete_argument_balise(2,$p))
1234
-			$type .= '.' . $famille;
1232
+	if ($type = interprete_argument_balise(1, $p)) {
1233
+		if ($famille = interprete_argument_balise(2, $p))
1234
+			$type .= '.'.$famille;
1235 1235
 		$p->code = '$doublons['.$type.']';
1236 1236
 		if (!$p->etoile)
1237 1237
 			$p->code = 'array_filter(array_map("intval",explode(",",'
1238
-				. $p->code . ')))';
1238
+				. $p->code.')))';
1239 1239
 	}
1240 1240
 	else
1241 1241
 		$p->code = '$doublons';
@@ -1254,13 +1254,13 @@  discard block
 block discarded – undo
1254 1254
 //
1255 1255
 // http://doc.spip.org/@balise_PIPELINE_dist
1256 1256
 function balise_PIPELINE_dist($p) {
1257
-	$_pipe = interprete_argument_balise(1,$p);
1257
+	$_pipe = interprete_argument_balise(1, $p);
1258 1258
 	if (!$_pipe) {
1259 1259
 		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE'));
1260 1260
 		erreur_squelette($err_b_s_a, $p);
1261 1261
 	} else {
1262
-		$_flux = interprete_argument_balise(2,$p);
1263
-		$_flux = $_flux?$_flux:"''";
1262
+		$_flux = interprete_argument_balise(2, $p);
1263
+		$_flux = $_flux ? $_flux : "''";
1264 1264
 		$p->code = "pipeline( $_pipe , $_flux )";
1265 1265
 		$p->interdire_scripts = false;
1266 1266
 	}
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 //
1290 1290
 // http://doc.spip.org/@balise_TOTAL_UNIQUE_dist
1291 1291
 function balise_TOTAL_UNIQUE_dist($p) {
1292
-	$_famille = interprete_argument_balise(1,$p);
1292
+	$_famille = interprete_argument_balise(1, $p);
1293 1293
 	$_famille = $_famille ? $_famille : "''";
1294 1294
 	$p->code = "unique('', $_famille, true)";
1295 1295
 	return $p;
@@ -1303,13 +1303,13 @@  discard block
 block discarded – undo
1303 1303
 // http://doc.spip.org/@balise_ARRAY_dist
1304 1304
 function balise_ARRAY_dist($p) {
1305 1305
 	$_code = array();
1306
-	$n=1;
1306
+	$n = 1;
1307 1307
 	do {
1308
-		$_key = interprete_argument_balise($n++,$p);
1309
-		$_val = interprete_argument_balise($n++,$p);
1308
+		$_key = interprete_argument_balise($n++, $p);
1309
+		$_val = interprete_argument_balise($n++, $p);
1310 1310
 		if ($_key AND $_val) $_code[] = "$_key => $_val";
1311 1311
 	} while ($_key && $_val);
1312
-	$p->code = 'array(' . join(', ',$_code).')';
1312
+	$p->code = 'array('.join(', ', $_code).')';
1313 1313
 	$p->interdire_scripts = false;
1314 1314
 	return $p;
1315 1315
 }
@@ -1322,10 +1322,10 @@  discard block
 block discarded – undo
1322 1322
  */
1323 1323
 function balise_LISTE_dist($p) {
1324 1324
 	$_code = array();
1325
-	$n=1;
1326
-	while ($_val = interprete_argument_balise($n++,$p))
1325
+	$n = 1;
1326
+	while ($_val = interprete_argument_balise($n++, $p))
1327 1327
 		$_code[] = $_val;
1328
-	$p->code = 'array(' . join(', ',$_code).')';
1328
+	$p->code = 'array('.join(', ', $_code).')';
1329 1329
 	$p->interdire_scripts = false;
1330 1330
 	return $p;
1331 1331
 }
@@ -1338,11 +1338,11 @@  discard block
 block discarded – undo
1338 1338
 	$_code = array();
1339 1339
 	$p->descr['session'] = true; // faire un cache par session
1340 1340
 
1341
-	$n=1;
1342
-	while ($_v = interprete_argument_balise($n++,$p))
1341
+	$n = 1;
1342
+	while ($_v = interprete_argument_balise($n++, $p))
1343 1343
 		$_code[] = $_v;
1344 1344
 
1345
-	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',$_code).')?" ":"")';
1345
+	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('.join(', ', $_code).')?" ":"")';
1346 1346
 	$p->interdire_scripts = false;
1347 1347
 	return $p;
1348 1348
 }
@@ -1351,9 +1351,9 @@  discard block
 block discarded – undo
1351 1351
 // Afficher des informations sur les plugins dans le site public
1352 1352
 // http://doc.spip.org/@balise_PLUGIN_dist
1353 1353
 function balise_PLUGIN_dist($p) {
1354
-	$plugin = interprete_argument_balise(1,$p);
1354
+	$plugin = interprete_argument_balise(1, $p);
1355 1355
 	$plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""';
1356
-	$type_info = interprete_argument_balise(2,$p);
1356
+	$type_info = interprete_argument_balise(2, $p);
1357 1357
 	$type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"';
1358 1358
 
1359 1359
 	$f = chercher_filtre('info_plugin');
@@ -1364,9 +1364,9 @@  discard block
 block discarded – undo
1364 1364
 // Appelle la fonction inc_aider_dist
1365 1365
 // http://doc.spip.org/@balise_AIDER_dist
1366 1366
 function balise_AIDER_dist($p) {
1367
-	$_motif = interprete_argument_balise(1,$p);
1368
-	$s = "'" . addslashes($p->descr['sourcefile']) . "'";
1369
-	$aider = charger_fonction('aider','inc');
1367
+	$_motif = interprete_argument_balise(1, $p);
1368
+	$s = "'".addslashes($p->descr['sourcefile'])."'";
1369
+	$aider = charger_fonction('aider', 'inc');
1370 1370
 	$p->code = "((\$aider=charger_fonction('aider','inc'))?\$aider($_motif,$s, \$Pile[0]):'')";
1371 1371
 	return $p;
1372 1372
 }
@@ -1374,10 +1374,10 @@  discard block
 block discarded – undo
1374 1374
 // Insertion du contexte des formulaires charger/verifier/traiter
1375 1375
 // avec les hidden de l'url d'action
1376 1376
 // http://doc.spip.org/@balise_ACTION_FORMULAIRE
1377
-function balise_ACTION_FORMULAIRE($p){
1378
-	if (!$_url = interprete_argument_balise(1,$p))
1377
+function balise_ACTION_FORMULAIRE($p) {
1378
+	if (!$_url = interprete_argument_balise(1, $p))
1379 1379
 		$_url = "@\$Pile[0]['action']";
1380
-	if (!$_form = interprete_argument_balise(2,$p))
1380
+	if (!$_form = interprete_argument_balise(2, $p))
1381 1381
 		$_form = "@\$Pile[0]['form']";
1382 1382
 
1383 1383
 	// envoyer le nom du formulaire que l'on traite
@@ -1410,18 +1410,18 @@  discard block
 block discarded – undo
1410 1410
  * @param unknown_type $p
1411 1411
  * @return unknown
1412 1412
  */
1413
-function balise_BOUTON_ACTION_dist($p){
1413
+function balise_BOUTON_ACTION_dist($p) {
1414 1414
 
1415 1415
 	$args = array();
1416
-	for ($k=1;$k<=6;$k++){
1417
-		$_a = interprete_argument_balise($k,$p);
1418
-		if (!$_a) $_a="''";
1416
+	for ($k = 1; $k <= 6; $k++) {
1417
+		$_a = interprete_argument_balise($k, $p);
1418
+		if (!$_a) $_a = "''";
1419 1419
 	  $args[] = $_a;
1420 1420
 	}
1421 1421
 	// supprimer les args vides
1422
-	while(end($args)=="''" AND count($args)>2)
1422
+	while (end($args) == "''" AND count($args) > 2)
1423 1423
 		array_pop($args);
1424
-	$args = implode(",",$args);
1424
+	$args = implode(",", $args);
1425 1425
 
1426 1426
 	$bouton_action = chercher_filtre("bouton_action");
1427 1427
 	$p->code = "$bouton_action($args)";
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
  * @param unknown_type $liste
1459 1459
  * @return unknown
1460 1460
  */
1461
-function balise_TRI_dist($p, $liste='true') {
1461
+function balise_TRI_dist($p, $liste = 'true') {
1462 1462
 	$b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];
1463 1463
 
1464 1464
 	// s'il n'y a pas de nom de boucle, on ne peut pas trier
@@ -1483,21 +1483,21 @@  discard block
 block discarded – undo
1483 1483
 		return $p;
1484 1484
 	}
1485 1485
 
1486
-	$_champ = interprete_argument_balise(1,$p);
1486
+	$_champ = interprete_argument_balise(1, $p);
1487 1487
 	// si pas de champ, renvoyer le critere de tri utilise
1488
-	if (!$_champ){
1488
+	if (!$_champ) {
1489 1489
 		$p->code = $boucle->modificateur['tri_champ'];
1490 1490
 		return $p;
1491 1491
 	}
1492 1492
 	// forcer la jointure si besoin, et si le champ est statique
1493
-	if (preg_match(",^'([\w.]+)'$,i",$_champ,$m)){
1493
+	if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) {
1494 1494
 		index_pile($b, $m[1], $p->boucles);
1495 1495
 	}
1496 1496
 
1497
-	$_libelle = interprete_argument_balise(2,$p);
1498
-	$_libelle = $_libelle?$_libelle:$_champ;
1497
+	$_libelle = interprete_argument_balise(2, $p);
1498
+	$_libelle = $_libelle ? $_libelle : $_champ;
1499 1499
 
1500
-	$_class = interprete_argument_balise(3,$p);
1500
+	$_class = interprete_argument_balise(3, $p);
1501 1501
 	// si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1
1502 1502
 	// si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1
1503 1503
 	$_issens = "in_array($_champ,array('>','<'))";
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 	$_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";
1508 1508
 	$_on = "\$s?(".$boucle->modificateur['tri_sens']."==$_sens".'):('.$boucle->modificateur['tri_champ']."==$_champ)";
1509 1509
 
1510
-	$p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class?",$_class":"").")";
1510
+	$p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class ? ",$_class" : "").")";
1511 1511
 	//$p->code = "''";
1512 1512
 	$p->interdire_scripts = false;
1513 1513
 	return $p;
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
  * @param <type> $p
1526 1526
  * @return <type>
1527 1527
  */
1528
-function balise_SAUTER_dist($p){
1528
+function balise_SAUTER_dist($p) {
1529 1529
 	$id_boucle = $p->id_boucle;
1530 1530
 	$boucle = $p->boucles[$id_boucle];
1531 1531
 
@@ -1534,7 +1534,7 @@  discard block
 block discarded – undo
1534 1534
 		erreur_squelette($msg, $p);
1535 1535
 	}
1536 1536
 	else {
1537
-		$_saut = interprete_argument_balise(1,$p);
1537
+		$_saut = interprete_argument_balise(1, $p);
1538 1538
 		$_compteur = "\$Numrows['$id_boucle']['compteur_boucle']";
1539 1539
 		$_total = "\$Numrows['$id_boucle']['total']";
1540 1540
 
@@ -1552,12 +1552,12 @@  discard block
 block discarded – undo
1552 1552
  * @return <type>
1553 1553
  */
1554 1554
 function balise_PUBLIE_dist($p) {
1555
-	if (!$_type = interprete_argument_balise(1,$p)){
1555
+	if (!$_type = interprete_argument_balise(1, $p)) {
1556 1556
 		$_type = _q($p->type_requete);
1557
-		$_id = champ_sql($p->boucles[$p->id_boucle]->primary,$p);
1557
+		$_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p);
1558 1558
 	}
1559 1559
 	else
1560
-		$_id = interprete_argument_balise(2,$p);
1560
+		$_id = interprete_argument_balise(2, $p);
1561 1561
 
1562 1562
 	$connect = $p->boucles[$p->id_boucle]->sql_serveur;
1563 1563
 
@@ -1581,11 +1581,11 @@  discard block
 block discarded – undo
1581 1581
  * @param object $p
1582 1582
  * @return object
1583 1583
  */
1584
-function balise_PRODUIRE_dist($p){
1585
-	$balise_inclure = charger_fonction('INCLURE','balise');
1584
+function balise_PRODUIRE_dist($p) {
1585
+	$balise_inclure = charger_fonction('INCLURE', 'balise');
1586 1586
 	$p = $balise_inclure($p);
1587 1587
 
1588
-	$p->code = str_replace('recuperer_fond(','produire_fond_statique(',$p->code);
1588
+	$p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code);
1589 1589
 
1590 1590
 	return $p;
1591 1591
 }
@@ -1597,9 +1597,9 @@  discard block
 block discarded – undo
1597 1597
  * @param  $p
1598 1598
  * @return
1599 1599
  */
1600
-function balise_LARGEUR_ECRAN_dist($p){
1601
-	$_class = interprete_argument_balise(1,$p);
1602
-	if (!$_class) $_class='null';
1600
+function balise_LARGEUR_ECRAN_dist($p) {
1601
+	$_class = interprete_argument_balise(1, $p);
1602
+	if (!$_class) $_class = 'null';
1603 1603
 	$p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))";
1604 1604
 	return $p;
1605 1605
 }
Please login to merge, or discard this patch.
ecrire/public/quete.php 1 patch
Spacing   +73 added lines, -75 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  * @return array|bool|null
30 30
  */
31 31
 function quete_virtuel($id_article, $connect) {
32
-	return sql_getfetsel('virtuel', 'spip_articles', array("id_article=".intval($id_article), "statut='publie'"), '','','','',$connect);
32
+	return sql_getfetsel('virtuel', 'spip_articles', array("id_article=".intval($id_article), "statut='publie'"), '', '', '', '', $connect);
33 33
 }
34 34
 
35 35
 /**
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
  * @param string $connect
43 43
  * @return array
44 44
  */
45
-function quete_parent_lang($table,$id,$connect=''){
45
+function quete_parent_lang($table, $id, $connect = '') {
46 46
 	static $cache_quete = array();
47 47
 
48 48
 	if (!isset($cache_quete[$connect][$table][$id])) {
49
-		if (!isset($cache_quete[$connect][$table]['_select'])){
50
-			$trouver_table = charger_fonction('trouver_table','base');
51
-			if (!$desc=$trouver_table($table,$connect) OR !isset($desc['field']['id_rubrique']))
49
+		if (!isset($cache_quete[$connect][$table]['_select'])) {
50
+			$trouver_table = charger_fonction('trouver_table', 'base');
51
+			if (!$desc = $trouver_table($table, $connect) OR !isset($desc['field']['id_rubrique']))
52 52
 				// pas de parent rubrique, on passe
53 53
 				$cache_quete[$connect][$table]['_select'] = false; 
54 54
 			else {
55
-				$select = ($table=='spip_rubriques'?'id_parent':'id_rubrique');
56
-				$select .= isset($desc['field']['lang'])?", lang":"";
55
+				$select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique');
56
+				$select .= isset($desc['field']['lang']) ? ", lang" : "";
57 57
 				$cache_quete[$connect][$table]['_select'] = $select;
58 58
 				$cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table));
59 59
 			}
60 60
 		}
61 61
 		if ($cache_quete[$connect][$table]['_select'])
62
-			$cache_quete[$connect][$table][$id] = sql_fetsel($cache_quete[$connect][$table]['_select'], $table,$cache_quete[$connect][$table]['_id']."=".intval($id),'','','','',$connect);
62
+			$cache_quete[$connect][$table][$id] = sql_fetsel($cache_quete[$connect][$table]['_select'], $table, $cache_quete[$connect][$table]['_id']."=".intval($id), '', '', '', '', $connect);
63 63
 	}
64 64
 	return isset($cache_quete[$connect][$table][$id]) ? $cache_quete[$connect][$table][$id] : null;
65 65
 }
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
  * @param string $connect
77 77
  * @return int
78 78
  */
79
-function quete_parent($id_rubrique, $connect='') {
79
+function quete_parent($id_rubrique, $connect = '') {
80 80
 	if (!$id_rubrique = intval($id_rubrique))
81 81
 		return 0;
82
-	$id_parent = quete_parent_lang('spip_rubriques',$id_rubrique,$connect);
82
+	$id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect);
83 83
 	return $id_parent['id_parent'];
84 84
 }
85 85
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
  * @return
96 96
  */
97 97
 function quete_rubrique($id_article, $serveur) {
98
-	$id_parent = quete_parent_lang('spip_articles',$id_article,$serveur);
98
+	$id_parent = quete_parent_lang('spip_articles', $id_article, $serveur);
99 99
 	return $id_parent['id_rubrique'];
100 100
 }
101 101
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
  * @param string $connect
110 110
  * @return int
111 111
  */
112
-function quete_profondeur($id, $connect='') {
112
+function quete_profondeur($id, $connect = '') {
113 113
 	$n = 0;
114 114
 	while ($id) {
115 115
 		$n++;
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
  * @param string $serveur
126 126
  * @return string
127 127
  */
128
-function quete_condition_postdates($champ_date, $serveur='', $ignore_previsu=false) {
128
+function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) {
129 129
 	if (defined('_VAR_PREVIEW') AND _VAR_PREVIEW AND !$ignore_previsu)
130 130
 		return "1=1";
131 131
 	return
132 132
 	  (isset($GLOBALS['meta']['date_prochain_postdate'])
133 133
 	     AND $GLOBALS['meta']['date_prochain_postdate'] > time())
134
-			? "$champ_date<".sql_quote(date('Y-m-d H:i:s',$GLOBALS['meta']['date_prochain_postdate']),$serveur)
135
-	    : "1=1" ;
134
+			? "$champ_date<".sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur)
135
+	    : "1=1";
136 136
 }
137 137
 
138 138
 
@@ -149,66 +149,66 @@  discard block
 block discarded – undo
149 149
  *  serveur de BDD
150 150
  * @return array
151 151
  */
152
-function quete_condition_statut($mstatut,$previsu,$publie, $serveur='', $ignore_previsu=false){
152
+function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) {
153 153
 	static $cond = array();
154 154
 	$key = func_get_args();
155
-	$key = implode("-",$key);
155
+	$key = implode("-", $key);
156 156
 	if (isset($cond[$key])) return $cond[$key];
157 157
 
158 158
 	$liste = $publie;
159 159
 	if (defined('_VAR_PREVIEW') AND _VAR_PREVIEW AND !$ignore_previsu)
160 160
 		$liste = $previsu;
161 161
 	$not = false;
162
-	if (strncmp($liste,'!',1)==0){
162
+	if (strncmp($liste, '!', 1) == 0) {
163 163
 		$not = true;
164
-	  $liste = substr($liste,1);
164
+	  $liste = substr($liste, 1);
165 165
 	}
166 166
 	// '' => ne rien afficher, '!'=> ne rien filtrer
167 167
 	if (!strlen($liste))
168
-		return $cond[$key]=($not?"1=1":"'0=1'");
168
+		return $cond[$key] = ($not ? "1=1" : "'0=1'");
169 169
 
170
-	$liste = explode(',',$liste);
170
+	$liste = explode(',', $liste);
171 171
 	$where = array();
172
-	foreach($liste as $k=>$v) {
172
+	foreach ($liste as $k=>$v) {
173 173
 		// filtrage /auteur pour limiter les objets d'un statut (prepa en general)
174 174
 		// a ceux de l'auteur identifie
175
-		if (strpos($v,"/")!==false){
176
-			$v = explode("/",$v);
175
+		if (strpos($v, "/") !== false) {
176
+			$v = explode("/", $v);
177 177
 			$filtre = end($v);
178 178
 			$v = reset($v);
179
-			$v = preg_replace(",\W,","",$v);
180
-			if ($filtre=="auteur"
179
+			$v = preg_replace(",\W,", "", $v);
180
+			if ($filtre == "auteur"
181 181
 				AND isset($GLOBALS['visiteur_session']['id_auteur'])
182 182
 				AND intval($GLOBALS['visiteur_session']['id_auteur'])
183
-				AND (strpos($mstatut,".")!==false)
184
-			  AND $objet = explode(".",$mstatut)
183
+				AND (strpos($mstatut, ".") !== false)
184
+			  AND $objet = explode(".", $mstatut)
185 185
 				AND $id_table = reset($objet)
186
-			  AND $objet = objet_type($id_table)){
186
+			  AND $objet = objet_type($id_table)) {
187 187
 				$primary = id_table_objet($objet);
188
-				$where[] = "($mstatut<>".sql_quote($v)." OR $id_table.$primary IN (".sql_get_select("ssss.id_objet","spip_auteurs_liens AS ssss","ssss.objet=".sql_quote($objet)." AND ssss.id_auteur=".intval($GLOBALS['visiteur_session']['id_auteur']),'','','','',$serveur)."))";
188
+				$where[] = "($mstatut<>".sql_quote($v)." OR $id_table.$primary IN (".sql_get_select("ssss.id_objet", "spip_auteurs_liens AS ssss", "ssss.objet=".sql_quote($objet)." AND ssss.id_auteur=".intval($GLOBALS['visiteur_session']['id_auteur']), '', '', '', '', $serveur)."))";
189 189
 			}
190 190
 			// ignorer ce statut si on ne sait pas comment le filtrer
191 191
 			else
192 192
 				$v = "";
193 193
 		}
194 194
 		// securite
195
-		$liste[$k] = preg_replace(",\W,","",$v);
195
+		$liste[$k] = preg_replace(",\W,", "", $v);
196 196
 	}
197 197
 	$liste = array_filter($liste);
198
-  if (count($liste)==1){
199
-		$where[] = array('=', $mstatut, sql_quote(reset($liste),$serveur));
198
+  if (count($liste) == 1) {
199
+		$where[] = array('=', $mstatut, sql_quote(reset($liste), $serveur));
200 200
   }
201 201
   else {
202
-	  $where[] = sql_in($mstatut,$liste,$not,$serveur);
202
+	  $where[] = sql_in($mstatut, $liste, $not, $serveur);
203 203
   }
204 204
 
205
-	while (count($where)>1){
206
-		$and = array('AND',array_pop($where),array_pop($where));
205
+	while (count($where) > 1) {
206
+		$and = array('AND', array_pop($where), array_pop($where));
207 207
 		$where[] = $and;
208 208
 	}
209 209
 	$cond[$key] = reset($where);
210 210
 	if ($not)
211
-		$cond[$key] = array('NOT',$cond[$key]);
211
+		$cond[$key] = array('NOT', $cond[$key]);
212 212
 
213 213
 	return $cond[$key];
214 214
 }
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
  * @param string $serveur
223 223
  * @return array|bool|null
224 224
  */
225
-function quete_fichier($id_document, $serveur='') {
226
-	return sql_getfetsel('fichier', 'spip_documents', ("id_document=" . intval($id_document)),	'',array(), '', '', $serveur);
225
+function quete_fichier($id_document, $serveur = '') {
226
+	return sql_getfetsel('fichier', 'spip_documents', ("id_document=".intval($id_document)), '', array(), '', '', $serveur);
227 227
 }
228 228
 
229 229
 /**
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
  * @param string $serveur
234 234
  * @return array|bool
235 235
  */
236
-function quete_document($id_document, $serveur='') {
237
-	return sql_fetsel('*', 'spip_documents', ("id_document=" . intval($id_document)),	'',array(), '', '', $serveur);
236
+function quete_document($id_document, $serveur = '') {
237
+	return sql_fetsel('*', 'spip_documents', ("id_document=".intval($id_document)), '', array(), '', '', $serveur);
238 238
 }
239 239
 
240 240
 /**
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
  * @return array|bool|null
248 248
  */
249 249
 function quete_meta($nom, $serveur) {
250
-	return sql_getfetsel("valeur", "spip_meta", "nom=" . sql_quote($nom),
251
-			     '','','','',$serveur);
250
+	return sql_getfetsel("valeur", "spip_meta", "nom=".sql_quote($nom),
251
+			     '', '', '', '', $serveur);
252 252
 }
253 253
 
254 254
 /**
@@ -277,13 +277,12 @@  discard block
 block discarded – undo
277 277
 				return "$on[2].$on[3]";
278 278
 			else {
279 279
 				$taille = @getimagesize($on[0]);
280
-				$off = ($onoff != 'ON') ? '' :
281
-					$chercher_logo($id, $type, 'off');
280
+				$off = ($onoff != 'ON') ? '' : $chercher_logo($id, $type, 'off');
282 281
 				// on retourne une url du type IMG/artonXX?timestamp
283 282
 				// qui permet de distinguer le changement de logo
284 283
 				// et placer un expire sur le dossier IMG/
285
-				return array ($on[0].($on[4]?"?$on[4]":""),
286
-					($off ? $off[0] . ($off[4]?"?$off[4]":"") : ''),
284
+				return array($on[0].($on[4] ? "?$on[4]" : ""),
285
+					($off ? $off[0].($off[4] ? "?$off[4]" : "") : ''),
287 286
 					(!$taille ? '' : (" ".$taille[3])));
288 287
 			}
289 288
 		}
@@ -308,18 +307,18 @@  discard block
 block discarded – undo
308 307
  * @param string $connect
309 308
  * @return bool|string
310 309
  */
311
-function quete_logo_file($row, $connect=NULL) {
310
+function quete_logo_file($row, $connect = NULL) {
312 311
 	include_spip('inc/documents');
313 312
 	$logo = vignette_logo_document($row, $connect);
314 313
 	if (!$logo) $logo = image_du_document($row);
315
-	if (!$logo){
316
-		$f = charger_fonction('vignette','inc');
314
+	if (!$logo) {
315
+		$f = charger_fonction('vignette', 'inc');
317 316
 		$logo = $f($row['extension'], false);
318 317
 	}
319 318
 	// si c'est une vignette type doc, la renvoyer direct
320
-	if (strcmp($logo,_DIR_PLUGINS)==0
321
-		OR strcmp($logo,_DIR_PLUGINS_DIST)==0
322
-		OR strcmp($logo,_DIR_RACINE.'prive/')==0)
319
+	if (strcmp($logo, _DIR_PLUGINS) == 0
320
+		OR strcmp($logo, _DIR_PLUGINS_DIST) == 0
321
+		OR strcmp($logo, _DIR_RACINE.'prive/') == 0)
323 322
 		return $logo;
324 323
 	return get_spip_doc($logo);
325 324
 }
@@ -347,10 +346,10 @@  discard block
 block discarded – undo
347 346
  *   serveur
348 347
  * @return string
349 348
  */
350
-function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, $connect=NULL) {
349
+function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, $connect = NULL) {
351 350
 	include_spip('inc/documents');
352 351
 	$logo = '';
353
-	if (!in_array($mode_logo,array('icone','apercu')))
352
+	if (!in_array($mode_logo, array('icone', 'apercu')))
354 353
 		$logo = vignette_logo_document($row, $connect);
355 354
 	// si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas
356 355
 	if ($mode_logo == 'vignette' AND !$logo)
@@ -369,7 +368,7 @@  discard block
 block discarded – undo
369 368
  * @param string $connect
370 369
  * @return string
371 370
  */
372
-function vignette_logo_document($row, $connect='')
371
+function vignette_logo_document($row, $connect = '')
373 372
 {
374 373
 	if (!$row['id_vignette']) return '';
375 374
 	$fichier = quete_fichier($row['id_vignette'], $connect);
@@ -381,7 +380,7 @@  discard block
 block discarded – undo
381 380
 	$f = get_spip_doc($fichier);
382 381
 	if ($f AND @file_exists($f)) return $f;
383 382
 	if ($row['mode'] !== 'vignette') return '';
384
-	return generer_url_entite($row['id_document'], 'document','','', $connect);
383
+	return generer_url_entite($row['id_document'], 'document', '', '', $connect);
385 384
 }
386 385
 
387 386
 /**
@@ -398,41 +397,40 @@  discard block
 block discarded – undo
398 397
  * @param string $connect
399 398
  * @return bool|string
400 399
  */
401
-function calcul_exposer ($id, $prim, $reference, $parent, $type, $connect='') {
400
+function calcul_exposer($id, $prim, $reference, $parent, $type, $connect = '') {
402 401
 	static $exposer = array();
403 402
 
404 403
 	// Que faut-il exposer ? Tous les elements de $reference
405 404
 	// ainsi que leur hierarchie ; on ne fait donc ce calcul
406 405
 	// qu'une fois (par squelette) et on conserve le resultat
407 406
 	// en static.
408
-	if (!isset($exposer[$m=md5(serialize($reference))][$prim])) {
409
-		$principal = isset($reference[$type])?$reference[$type]:
410
-			// cas de la pagination indecte @xx qui positionne la page avec l'id xx
407
+	if (!isset($exposer[$m = md5(serialize($reference))][$prim])) {
408
+		$principal = isset($reference[$type]) ? $reference[$type] : // cas de la pagination indecte @xx qui positionne la page avec l'id xx
411 409
 			// et donne la reference dynamique @type=xx dans le contexte
412
-			(isset($reference["@$type"])?$reference["@$type"]:'');
410
+			(isset($reference["@$type"]) ? $reference["@$type"] : '');
413 411
 		// le parent fournit en argument est le parent de $id, pas celui de $principal
414 412
 		// il n'est donc pas utile
415 413
 		$parent = 0;
416 414
 		if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant
417
-			$enfants = array('id_rubrique'=>array('id_article'),'id_groupe'=>array('id_mot'));
415
+			$enfants = array('id_rubrique'=>array('id_article'), 'id_groupe'=>array('id_mot'));
418 416
 			if (isset($enfants[$type]))
419
-				foreach($enfants[$type] as $t)
417
+				foreach ($enfants[$type] as $t)
420 418
 					if (isset($reference[$t])
421 419
 						// cas de la reference donnee dynamiquement par la pagination
422 420
 						OR isset($reference["@$t"])) {
423 421
 						$type = $t;
424
-						$principal = isset($reference[$type])?$reference[$type]:$reference["@$type"];
422
+						$principal = isset($reference[$type]) ? $reference[$type] : $reference["@$type"];
425 423
 						continue;
426 424
 					}
427 425
 		}
428 426
 		$exposer[$m][$type] = array();
429 427
 		if ($principal) {
430
-			$principaux = is_array($principal)?$principal:array($principal);
431
-			foreach($principaux as $principal){
428
+			$principaux = is_array($principal) ? $principal : array($principal);
429
+			foreach ($principaux as $principal) {
432 430
 				$exposer[$m][$type][$principal] = true;
433
-				if ($type == 'id_mot'){
431
+				if ($type == 'id_mot') {
434 432
 					if (!$parent) {
435
-						$parent = sql_getfetsel('id_groupe','spip_mots',"id_mot=" . intval($principal), '','','','',$connect);
433
+						$parent = sql_getfetsel('id_groupe', 'spip_mots', "id_mot=".intval($principal), '', '', '', '', $connect);
436 434
 					}
437 435
 					if ($parent)
438 436
 						$exposer[$m]['id_groupe'][$parent] = true;
@@ -442,7 +440,7 @@  discard block
 block discarded – undo
442 440
 				  	if ($type == 'id_rubrique')
443 441
 				  		$parent = $principal;
444 442
 				  	if ($type == 'id_article') {
445
-						$parent = quete_rubrique($principal,$connect);
443
+						$parent = quete_rubrique($principal, $connect);
446 444
 				  	}
447 445
 				  }
448 446
 				  do { $exposer[$m]['id_rubrique'][$parent] = true; }
@@ -466,21 +464,21 @@  discard block
 block discarded – undo
466 464
  * @param objetc $iter
467 465
  * @return int
468 466
  */
469
-function quete_debut_pagination($primary,$valeur,$pas,$iter){
467
+function quete_debut_pagination($primary, $valeur, $pas, $iter) {
470 468
 	// on ne devrait pas arriver ici si la cle primaire est inexistante
471 469
 	// ou composee, mais verifions
472
-	if (!$primary OR preg_match('/[,\s]/',$primary))
470
+	if (!$primary OR preg_match('/[,\s]/', $primary))
473 471
 		return 0;
474 472
 
475 473
 	$pos = 0;
476
-	while ($row = $iter->fetch() AND $row[$primary]!=$valeur){
474
+	while ($row = $iter->fetch() AND $row[$primary] != $valeur) {
477 475
 		$pos++;
478 476
 	}
479 477
 	// si on a pas trouve
480
-	if ($row[$primary]!=$valeur)
478
+	if ($row[$primary] != $valeur)
481 479
 		return 0;
482 480
 
483 481
 	// sinon, calculer le bon numero de page
484
-	return floor($pos/$pas)*$pas;
482
+	return floor($pos / $pas) * $pas;
485 483
 }
486 484
 ?>
Please login to merge, or discard this patch.
ecrire/public/styliser.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
  *
32 32
  * http://doc.spip.org/@public_styliser_dist
33 33
  */
34
-function public_styliser_dist($fond, $contexte, $lang='', $connect='') {
34
+function public_styliser_dist($fond, $contexte, $lang = '', $connect = '') {
35 35
 	static $styliser_par_z;
36 36
 
37 37
 	// s'assurer que le fond est licite
38 38
 	// car il peut etre construit a partir d'une variable d'environnement
39
-	if (strpos($fond,"../")!==false OR strncmp($fond,'/',1)==0)
39
+	if (strpos($fond, "../") !== false OR strncmp($fond, '/', 1) == 0)
40 40
 		$fond = "404";
41 41
   
42 42
 	// Choisir entre $fond-dist.html, $fond=7.html, etc?
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	// ne rien dire si on ne trouve pas, 
50 50
 	// c'est l'appelant qui sait comment gerer la situation
51 51
 	// ou les plugins qui feront mieux dans le pipeline
52
-	$squelette = trouver_fond($fond,"",true);
52
+	$squelette = trouver_fond($fond, "", true);
53 53
 	$ext = $squelette['extension'];
54 54
 
55 55
 	$flux = array(
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 	if (test_espace_prive() OR defined('_ZPIP')) {
68 68
 		if (!$styliser_par_z)
69
-			$styliser_par_z = charger_fonction('styliser_par_z','public');
69
+			$styliser_par_z = charger_fonction('styliser_par_z', 'public');
70 70
 		$flux = $styliser_par_z($flux);
71 71
 	}
72 72
 
@@ -78,25 +78,25 @@  discard block
 block discarded – undo
78 78
 	return array($squelette, $ext, $ext, "$squelette.$ext");
79 79
 }
80 80
 
81
-function styliser_par_objets($flux){
81
+function styliser_par_objets($flux) {
82 82
 	if (test_espace_prive()
83 83
 		AND !$squelette = $flux['data']
84
-	  AND strncmp($flux['args']['fond'],'prive/objets/',13)==0
85
-	  AND $echafauder = charger_fonction('echafauder','prive',true)) {
86
-		if (strncmp($flux['args']['fond'],'prive/objets/liste/',19)==0){
87
-			$table = table_objet(substr($flux['args']['fond'],19));
84
+	  AND strncmp($flux['args']['fond'], 'prive/objets/', 13) == 0
85
+	  AND $echafauder = charger_fonction('echafauder', 'prive', true)) {
86
+		if (strncmp($flux['args']['fond'], 'prive/objets/liste/', 19) == 0) {
87
+			$table = table_objet(substr($flux['args']['fond'], 19));
88 88
 			$table_sql = table_objet_sql($table);
89 89
 			$objets = lister_tables_objets_sql();
90 90
 			if (isset($objets[$table_sql]))
91
-				$flux['data'] = $echafauder($table,$table,$table_sql,"prive/objets/liste/objets",$flux['args']['ext']);
91
+				$flux['data'] = $echafauder($table, $table, $table_sql, "prive/objets/liste/objets", $flux['args']['ext']);
92 92
 		}
93
-		if (strncmp($flux['args']['fond'],'prive/objets/contenu/',21)==0){
94
-			$type = substr($flux['args']['fond'],21);
93
+		if (strncmp($flux['args']['fond'], 'prive/objets/contenu/', 21) == 0) {
94
+			$type = substr($flux['args']['fond'], 21);
95 95
 			$table = table_objet($type);
96 96
 			$table_sql = table_objet_sql($table);
97 97
 			$objets = lister_tables_objets_sql();
98 98
 			if (isset($objets[$table_sql]))
99
-				$flux['data'] = $echafauder($type,$table,$table_sql,"prive/objets/contenu/objet",$flux['args']['ext']);
99
+				$flux['data'] = $echafauder($type, $table, $table_sql, "prive/objets/contenu/objet", $flux['args']['ext']);
100 100
 		}
101 101
 	}
102 102
 	return $flux;
@@ -125,33 +125,33 @@  discard block
 block discarded – undo
125 125
 		include_spip('public/quete');
126 126
 		$l = urls_liste_objets(false);
127 127
 		// placer la rubrique en tete des objets
128
-		$l = array_diff($l,array('rubrique'));
128
+		$l = array_diff($l, array('rubrique'));
129 129
 		array_unshift($l, 'rubrique');
130
-		foreach($l as $objet){
130
+		foreach ($l as $objet) {
131 131
 			$id = id_table_objet($objet);
132 132
 			if (!isset($liste_objets[$id]))
133
-				$liste_objets[$id] = objet_type($objet,false);
133
+				$liste_objets[$id] = objet_type($objet, false);
134 134
 		}
135 135
 	}
136
-	$c = array_intersect_key($contexte,$liste_objets);
136
+	$c = array_intersect_key($contexte, $liste_objets);
137 137
 	if (!count($c)) return false;
138 138
 
139
-	$c = array_map('intval',$c);
139
+	$c = array_map('intval', $c);
140 140
 	$s = serialize($c);
141 141
 	if (isset($quete[$s]))
142 142
 		return $quete[$s];
143 143
 
144
-	if (isset($c['id_rubrique']) AND $r = $c['id_rubrique']){
144
+	if (isset($c['id_rubrique']) AND $r = $c['id_rubrique']) {
145 145
 		unset($c['id_rubrique']);
146 146
 		$c = array('id_rubrique'=>$r) + $c;
147 147
 	}
148 148
 
149
-	foreach($c as $_id=>$id) {
149
+	foreach ($c as $_id=>$id) {
150 150
 		if ($id
151
-		  AND $row = quete_parent_lang(table_objet_sql($liste_objets[$_id]),$id)) {
151
+		  AND $row = quete_parent_lang(table_objet_sql($liste_objets[$_id]), $id)) {
152 152
 			$lang = isset($row['lang']) ? $row['lang'] : '';
153
-			if ($_id=='id_rubrique' OR (isset($row['id_rubrique']) AND $id=$row['id_rubrique']))
154
-				return $quete[$s] = array ($id, $lang);
153
+			if ($_id == 'id_rubrique' OR (isset($row['id_rubrique']) AND $id = $row['id_rubrique']))
154
+				return $quete[$s] = array($id, $lang);
155 155
 		}
156 156
 	}
157 157
 	return $quete[$s] = false;
Please login to merge, or discard this patch.
ecrire/public/jointures.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  * @param string $champ
30 30
  * @return array
31 31
  */
32
-function decompose_champ_id_objet($champ){
33
-	if (($champ!=='id_objet') AND preg_match(',^id_([a-z_]+)$,', $champ, $regs)){
32
+function decompose_champ_id_objet($champ) {
33
+	if (($champ !== 'id_objet') AND preg_match(',^id_([a-z_]+)$,', $champ, $regs)) {
34 34
 		return array('id_objet', 'objet', objet_type($regs[1]));
35 35
 	}
36 36
 	return $champ;
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
  * @param array $desc
46 46
  * @return array
47 47
  */
48
-function trouver_champs_decomposes($champ, $desc){
48
+function trouver_champs_decomposes($champ, $desc) {
49 49
 	if (!is_array($desc) // on ne se risque pas en conjectures si on ne connait pas la table
50 50
 	    OR array_key_exists($champ, $desc['field'])
51 51
 	)
52 52
 		return array($champ);
53
-	if (is_array($decompose = decompose_champ_id_objet($champ))){
53
+	if (is_array($decompose = decompose_champ_id_objet($champ))) {
54 54
 		array_pop($decompose);
55
-		if (count(array_intersect($decompose, array_keys($desc['field'])))==count($decompose))
55
+		if (count(array_intersect($decompose, array_keys($desc['field']))) == count($decompose))
56 56
 			return $decompose;
57 57
 	}
58 58
 	return array($champ);
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
  *     flag pour savoir si le critere est conditionnel ou non
79 79
  * @return string
80 80
  */
81
-function calculer_jointure(&$boucle, $depart, $arrivee, $col = '', $cond = false, $max_liens=5){
81
+function calculer_jointure(&$boucle, $depart, $arrivee, $col = '', $cond = false, $max_liens = 5) {
82 82
 	// les jointures minimales sont optimales :
83 83
 	// on contraint le nombre d'etapes en l'augmentant
84 84
 	// jusqu'a ce qu'on trouve une jointure ou qu'on atteigne la limite maxi 
85 85
 	$max = 1;
86 86
 	$res = false;
87
-	$milieu_exclus = ($col?$col:array());
88
-	while ($max<=$max_liens AND !$res){
87
+	$milieu_exclus = ($col ? $col : array());
88
+	while ($max <= $max_liens AND !$res) {
89 89
 		$res = calculer_chaine_jointures($boucle, $depart, $arrivee, array(), $milieu_exclus, $max);
90 90
 		$max++;
91 91
 	}
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
  * @param bool $echap
125 125
  * @return string
126 126
  */
127
-function fabrique_jointures(&$boucle, $res, $cond = false, $desc = array(), $nom = '', $col = '', $echap = true){
127
+function fabrique_jointures(&$boucle, $res, $cond = false, $desc = array(), $nom = '', $col = '', $echap = true) {
128 128
 	static $num = array();
129 129
 	$id_table = "";
130 130
 	$cpt = &$num[$boucle->descr['nom']][$boucle->descr['gram']][$boucle->id_boucle];
131
-	foreach ($res as $cle => $r){
131
+	foreach ($res as $cle => $r) {
132 132
 		list($d, $a, $j) = $r;
133 133
 		if (!$id_table) $id_table = $d;
134 134
 		$n = ++$cpt;
135
-		if (is_array($j)){ // c'est un lien sur un champ du type id_objet,objet,'article'
135
+		if (is_array($j)) { // c'est un lien sur un champ du type id_objet,objet,'article'
136 136
 			list($j1, $j2, $obj, $type) = $j;
137 137
 			// trouver de quel cote est (id_objet,objet)
138
-			if ($j1=="id_$obj")
138
+			if ($j1 == "id_$obj")
139 139
 				$obj = "$id_table.$obj";
140 140
 			else
141 141
 				$obj = "L$n.$obj";
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	// de l'index principal et de l'index de jointure (non conditionnel! [6031])
161 161
 	// et operateur d'egalite (http://trac.rezo.net/trac/spip/ticket/477)
162 162
 
163
-	if ($pk = (isset($a[1]) && (count($boucle->from)==2) && !$cond)){
163
+	if ($pk = (isset($a[1]) && (count($boucle->from) == 2) && !$cond)) {
164 164
 		$pk = nogroupby_if($desc, $a[1], $col);
165 165
 	}
166 166
 
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
 	// si une seule jointure
169 169
 	// et si l'index de jointure est une primary key a l'arrivee !
170 170
 	if (!$pk
171
-	    AND (count($boucle->from)==2)
171
+	    AND (count($boucle->from) == 2)
172 172
 	        AND isset($a[1]['key']['PRIMARY KEY'])
173
-	            AND ($j==$a[1]['key']['PRIMARY KEY'])
173
+	            AND ($j == $a[1]['key']['PRIMARY KEY'])
174 174
 	)
175 175
 		$pk = true;
176 176
 
177 177
 	// la clause Group by est en conflit avec ORDER BY, a completer
178 178
 	$groups = liste_champs_jointures($nom, $desc, true);
179
-	if (!$pk) foreach ($groups as $id_prim){
179
+	if (!$pk) foreach ($groups as $id_prim) {
180 180
 		$id_field = $nom.'.'.$id_prim;
181
-		if (!in_array($id_field, $boucle->group)){
181
+		if (!in_array($id_field, $boucle->group)) {
182 182
 			$boucle->group[] = $id_field;
183 183
 		}
184 184
 	}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
  * @param string|array $col
200 200
  * @return bool
201 201
  */
202
-function nogroupby_if($depart, $arrivee, $col){
202
+function nogroupby_if($depart, $arrivee, $col) {
203 203
 	$pk = $arrivee['key']['PRIMARY KEY'];
204 204
 	if (!$pk) return false;
205 205
 	$id_primary = $depart['key']['PRIMARY KEY'];
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
  * @param bool $primary
223 223
  * @return array
224 224
  */
225
-function liste_champs_jointures($nom, $desc, $primary = false){
225
+function liste_champs_jointures($nom, $desc, $primary = false) {
226 226
 
227 227
 	static $nojoin = array('idx', 'maj', 'date', 'statut');
228 228
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
  * @param array $join
263 263
  * @return array
264 264
  */
265
-function split_key($v, $join = array()){
265
+function split_key($v, $join = array()) {
266 266
 	foreach (preg_split('/,\s*/', $v) as $k) $join[$k] = $k;
267 267
 	return $join;
268 268
 }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
  *  nombre maxi d'etapes
286 286
  * @return array
287 287
  */
288
-function calculer_chaine_jointures(&$boucle, $depart, $arrivee, $vu = array(), $milieu_exclus = array(), $max_liens = 5){
288
+function calculer_chaine_jointures(&$boucle, $depart, $arrivee, $vu = array(), $milieu_exclus = array(), $max_liens = 5) {
289 289
 	static $trouver_table;
290 290
 	if (!$trouver_table)
291 291
 		$trouver_table = charger_fonction('trouver_table', 'base');
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 		$milieu_exclus = array($milieu_exclus);
295 295
 	// quand on a exclus id_objet comme cle de jointure, il faut aussi exclure objet
296 296
 	// faire une jointure sur objet tout seul n'a pas de sens
297
-	if (in_array('id_objet',$milieu_exclus) AND !in_array('objet',$milieu_exclus))
297
+	if (in_array('id_objet', $milieu_exclus) AND !in_array('objet', $milieu_exclus))
298 298
 		$milieu_exclus[] = 'objet';
299 299
 
300 300
 	list($dnom, $ddesc) = $depart;
301 301
 	list($anom, $adesc) = $arrivee;
302
-	if (!count($vu)){
302
+	if (!count($vu)) {
303 303
 		$vu[] = $dnom; // ne pas oublier la table de depart
304 304
 		$vu[] = $anom; // ne pas oublier la table d'arrivee
305 305
 	}
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 		return array(array($dnom, array($adesc['table'], $adesc), array_shift($v)));
325 325
 
326 326
 	// regarder si l'on a (id_objet,objet) au depart et si on peut le mapper sur un id_xx
327
-	if (count(array_intersect(array('id_objet', 'objet'), $keys))==2){
327
+	if (count(array_intersect(array('id_objet', 'objet'), $keys)) == 2) {
328 328
 		// regarder si l'une des cles d'arrivee peut se decomposer en 
329 329
 		// id_objet,objet
330 330
 		// si oui on la prend
331
-		foreach ($akeys as $key){
331
+		foreach ($akeys as $key) {
332 332
 			$v = decompose_champ_id_objet($key);
333
-			if (is_array($v)){
333
+			if (is_array($v)) {
334 334
 				$objet = array_shift($v); // objet,'article'
335 335
 				array_unshift($v, $key); // id_article,objet,'article'
336 336
 				array_unshift($v, $objet); // id_objet,id_article,objet,'article'
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
 		// regarder si l'une des cles de depart peut se decomposer en 
343 343
 		// id_objet,objet a l'arrivee
344 344
 		// si oui on la prend
345
-		foreach ($keys as $key){
346
-			if (count($v = trouver_champs_decomposes($key, $adesc))>1){
347
-				if (count($v)==count(array_intersect($v, $akeys))){
345
+		foreach ($keys as $key) {
346
+			if (count($v = trouver_champs_decomposes($key, $adesc)) > 1) {
347
+				if (count($v) == count(array_intersect($v, $akeys))) {
348 348
 					$v = decompose_champ_id_objet($key); // id_objet,objet,'article'
349 349
 					array_unshift($v, $key); // id_article,id_objet,objet,'article'
350 350
 					return array(array($dnom, array($adesc['table'], $adesc), $v));
@@ -353,38 +353,38 @@  discard block
 block discarded – undo
353 353
 		}
354 354
 	}
355 355
 	// si l'on voulait une jointure direct, c'est rate !
356
-	if ($max_liens<=1) return array();
356
+	if ($max_liens <= 1) return array();
357 357
 
358 358
 	// sinon essayer de passer par une autre table
359 359
 	$new = $vu;
360
-	foreach ($boucle->jointures as $v){
360
+	foreach ($boucle->jointures as $v) {
361 361
 		if ($v
362 362
 		    AND !in_array($v, $vu)
363 363
 		    AND $def = $trouver_table($v, $boucle->sql_serveur)
364 364
 			  AND !in_array($def['table_sql'], $vu)
365
-		){
365
+		) {
366 366
 			// ne pas tester les cles qui sont exclues a l'appel
367 367
 			// ie la cle de la jointure precedente
368 368
 			$test_cles = $milieu_exclus;
369 369
 			$new[] = $v;
370 370
 			$max_iter = 50; // securite
371 371
 			while (count($jointure_directe_possible = calculer_chaine_jointures($boucle, $depart, array($v, $def), $vu, $test_cles, 1))
372
-			       AND $max_iter--){
372
+			       AND $max_iter--) {
373 373
 				$jointure_directe_possible = reset($jointure_directe_possible);
374 374
 				$milieu = end($jointure_directe_possible);
375 375
 				$exclure_fin = $milieu_exclus;
376
-				if (is_string($milieu)){
376
+				if (is_string($milieu)) {
377 377
 					$exclure_fin[] = $milieu;
378 378
 					$test_cles[] = $milieu;
379 379
 				}
380
-				else{
380
+				else {
381 381
 					$exclure_fin = array_merge($exclure_fin, $milieu);
382 382
 					$test_cles = array_merge($test_cles, $milieu);
383 383
 				}
384 384
 				// essayer de rejoindre l'arrivee a partir de cette etape intermediaire
385 385
 				// sans repasser par la meme cle milieu, ni une cle deja vue !
386
-				$r = calculer_chaine_jointures($boucle, array($v, $def), $arrivee, $new, $exclure_fin, $max_liens-1);
387
-				if ($r){
386
+				$r = calculer_chaine_jointures($boucle, array($v, $def), $arrivee, $new, $exclure_fin, $max_liens - 1);
387
+				if ($r) {
388 388
 					array_unshift($r, $jointure_directe_possible);
389 389
 					return $r;
390 390
 				}
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
  * @param $keys
404 404
  * @return array
405 405
  */
406
-function trouver_cles_table($keys){
406
+function trouver_cles_table($keys) {
407 407
 	$res = array();
408
-	foreach ($keys as $v){
408
+	foreach ($keys as $v) {
409 409
 		if (!strpos($v, ","))
410 410
 			$res[$v] = 1;
411 411
 		else {
412
-			foreach (preg_split("/\s*,\s*/", $v) as $k){
412
+			foreach (preg_split("/\s*,\s*/", $v) as $k) {
413 413
 				$res[$k] = 1;
414 414
 			}
415 415
 		}
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
  * @param bool $checkarrivee
427 427
  * @return array|string
428 428
  */
429
-function trouver_champ_exterieur($cle, $joints, &$boucle, $checkarrivee = false){
429
+function trouver_champ_exterieur($cle, $joints, &$boucle, $checkarrivee = false) {
430 430
 	static $trouver_table = '';
431 431
 	if (!$trouver_table)
432 432
 		$trouver_table = charger_fonction('trouver_table', 'base');
@@ -438,28 +438,28 @@  discard block
 block discarded – undo
438 438
 	if (!is_array($cle))
439 439
 		$cle = array($cle);
440 440
 
441
-	foreach ($joints as $k => $join){
442
-		if ($join && $table = $trouver_table($join, $boucle->sql_serveur)){
441
+	foreach ($joints as $k => $join) {
442
+		if ($join && $table = $trouver_table($join, $boucle->sql_serveur)) {
443 443
 			if (isset($table['field'])
444 444
 			    // verifier que toutes les cles cherchees sont la
445
-			    AND (count(array_intersect($cle, array_keys($table['field'])))==count($cle))
445
+			    AND (count(array_intersect($cle, array_keys($table['field']))) == count($cle))
446 446
 			        // si on sait ou on veut arriver, il faut que ca colle
447
-			        AND ($checkarrivee==false || $checkarrivee==$table['table'])
447
+			        AND ($checkarrivee == false || $checkarrivee == $table['table'])
448 448
 			)
449 449
 				return array($table['table'], $table);
450 450
 		}
451 451
 	}
452 452
 
453 453
 	// au premier coup, on essaye de decomposer, si possible
454
-	if (count($cle)==1
454
+	if (count($cle) == 1
455 455
 	    AND $c = reset($cle)
456 456
 	        AND is_array($decompose = decompose_champ_id_objet($c))
457
-	){
457
+	) {
458 458
 
459 459
 		$desc = $boucle->show;
460 460
 		// cas 1 : la cle id_xx est dans la table de depart
461 461
 		// -> on cherche uniquement id_objet,objet a l'arrivee
462
-		if (isset($desc['field'][$c])){
462
+		if (isset($desc['field'][$c])) {
463 463
 			$cle = array();
464 464
 			$cle[] = array_shift($decompose); // id_objet
465 465
 			$cle[] = array_shift($decompose); // objet
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 			// id_objet,objet,zzz soit a l'arrivee
471 471
 		else {
472 472
 			$depart = liste_champs_jointures($desc['table'], $desc);
473
-			foreach ($depart as $d){
473
+			foreach ($depart as $d) {
474 474
 				$cle = array();
475 475
 				$cle[] = array_shift($decompose); // id_objet
476 476
 				$cle[] = array_shift($decompose); // objet
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 		$jointures = $boucle->jointures;
511 511
 	}
512 512
 	$cle = trouver_champ_exterieur($champ, $jointures, $boucle);
513
-	if ($cle){
513
+	if ($cle) {
514 514
 		$desc = $boucle->show;
515 515
 		$cle = calculer_jointure($boucle, array($desc['id_table'], $desc), $cle, '', $cond);
516 516
 	}
Please login to merge, or discard this patch.
ecrire/public/iterateur.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
  * fourni dans le fichier iterateurs/xxx.php
20 20
  * 
21 21
  */
22
-class IterFactory{
23
-	public static function create($iterateur, $command, $info=null){
22
+class IterFactory {
23
+	public static function create($iterateur, $command, $info = null) {
24 24
 
25 25
 		// cas des SI {si expression} analises tres tot
26 26
 		// pour eviter le chargement de tout iterateur
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 		// (il faudrait passer l'argument ->sql_serveur
39 39
 		// pour etre certain qu'on est sur un "php:")
40 40
 		if (class_exists($iterateur)) {
41
-			$a = isset($command['args']) ? $command['args'] : array() ;
41
+			$a = isset($command['args']) ? $command['args'] : array();
42 42
 
43 43
 			// permettre de passer un Iterateur directement {args #ITERATEUR} :
44 44
 			// si on recoit deja un iterateur en argument, on l'utilise
45
-			if (count($a)==1 and is_object($a[0]) and is_subclass_of($a[0], 'Iterator')) {
45
+			if (count($a) == 1 and is_object($a[0]) and is_subclass_of($a[0], 'Iterator')) {
46 46
 				$iter = $a[0];
47 47
 
48 48
 			// sinon, on cree un iterateur du type donne
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 				// (pas glop)
52 52
 				try {
53 53
 					switch (count($a)) {
54
-						case 0:    $iter = new $iterateur();  break;
55
-						case 1:    $iter = new $iterateur($a[0]);  break;
56
-						case 2:    $iter = new $iterateur($a[0], $a[1]);  break;
57
-						case 3:    $iter = new $iterateur($a[0], $a[1], $a[2]);  break;
58
-						case 4:    $iter = new $iterateur($a[0], $a[1], $a[2], $a[3]);  break;
54
+						case 0:    $iter = new $iterateur(); break;
55
+						case 1:    $iter = new $iterateur($a[0]); break;
56
+						case 2:    $iter = new $iterateur($a[0], $a[1]); break;
57
+						case 3:    $iter = new $iterateur($a[0], $a[1], $a[2]); break;
58
+						case 4:    $iter = new $iterateur($a[0], $a[1], $a[2], $a[3]); break;
59 59
 					}
60 60
 				} catch (Exception $e) {
61 61
 					spip_log("Erreur de chargement de l'iterateur $iterateur");
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 			// IterateurXXX
69 69
 			// definie dans le fichier iterateurs/xxx.php
70 70
 			$class = "Iterateur".$iterateur;
71
-			if (!class_exists($class)){
72
-				if (!include_spip("iterateur/" . strtolower($iterateur))
71
+			if (!class_exists($class)) {
72
+				if (!include_spip("iterateur/".strtolower($iterateur))
73 73
 					OR !class_exists($class)) {
74 74
 					die("Iterateur $iterateur non trouv&#233;");
75 75
 					// si l'iterateur n'existe pas, on se rabat sur le generique
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * en tenant compte des filtres
115 115
 	 * @var int
116 116
 	 */
117
-	protected $fetched=0;
117
+	protected $fetched = 0;
118 118
 
119 119
 	/**
120 120
 	 * Y a t'il une erreur ?
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		return false;
136 136
 	}
137 137
 
138
-	public function __construct(Iterator $iter, $command, $info){
138
+	public function __construct(Iterator $iter, $command, $info) {
139 139
 		parent::__construct($iter);
140 140
 		parent::rewind(); // remettre a la premiere position (bug? connu de FilterIterator)
141 141
 		
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	// 
169 169
 	private function calculer_select() {
170 170
 		if ($select = &$this->command['select']) {
171
-			foreach($select as $s) {
171
+			foreach ($select as $s) {
172 172
 				// /!\ $s = '.nom'
173 173
 				if ($s[0] == '.') {
174 174
 					$s = substr($s, 1);
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
 		AND method_exists($this->iter, $nom)) {
187 187
 			try {
188 188
 				return $this->iter->$nom();
189
-			} catch(Exception $e) {
189
+			} catch (Exception $e) {
190 190
 				// #GETCHILDREN sur un fichier de DirectoryIterator ...
191
-				spip_log("Methode $nom en echec sur " . get_class($this->iter));
191
+				spip_log("Methode $nom en echec sur ".get_class($this->iter));
192 192
 				spip_log("Cela peut être normal : retour d'une ligne de resultat ne pouvant pas calculer cette methode");
193 193
 				return '';
194 194
 			}
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 		// IN sur collection vide (ce dernier devrait pouvoir etre fait a la compil)
221 221
 		if ($where = &$this->command['where']) {
222 222
 			$menage = false;
223
-			foreach($where as $k => $v) { 
224
-				if (is_array($v)){
225
-					if ((count($v)>=2) && ($v[0]=='REGEXP') && ($v[2]=="'.*'")) $op= false;
226
-					elseif ((count($v)>=2) && ($v[0]=='LIKE') && ($v[2]=="'%'")) $op= false;
223
+			foreach ($where as $k => $v) { 
224
+				if (is_array($v)) {
225
+					if ((count($v) >= 2) && ($v[0] == 'REGEXP') && ($v[2] == "'.*'")) $op = false;
226
+					elseif ((count($v) >= 2) && ($v[0] == 'LIKE') && ($v[2] == "'%'")) $op = false;
227 227
 					else $op = $v[0] ? $v[0] : $v;
228 228
 				} else $op = $v;
229
-				if ((!$op) OR ($op==1) OR ($op=='0=0')) {
229
+				if ((!$op) OR ($op == 1) OR ($op == '0=0')) {
230 230
 					unset($where[$k]);
231 231
 					$menage = true;
232 232
 				}
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 				// produites par sql_in quand plus de 255 valeurs passees a IN
236 236
 				if (preg_match_all(',\s+IN\s+(\(.*\)),', $op, $s_req)) {
237 237
 					$req = '';
238
-					foreach($s_req[1] as $key => $val) {
239
-						$req .= trim($val, '(,)') . ',';
238
+					foreach ($s_req[1] as $key => $val) {
239
+						$req .= trim($val, '(,)').',';
240 240
 					}
241
-					$req = '(' . rtrim($req, ',') . ')';
241
+					$req = '('.rtrim($req, ',').')';
242 242
 				}
243 243
 				if (preg_match(',^\(\(([\w/]+)(\s+NOT)?\s+IN\s+(\(.*\))\)(?:\s+(AND|OR)\s+\(([\w/]+)(\s+NOT)?\s+IN\s+(\(.*\))\))*\)$,', $op, $regs)) {
244 244
 					$this->ajouter_filtre($regs[1], 'IN', strlen($req) ? $req : $regs[3], $regs[2]);
245 245
 					unset($op);
246 246
 				}
247 247
 			}
248
-			foreach($where as $k => $v) {
248
+			foreach ($where as $k => $v) {
249 249
 				// 3 possibilites : count($v) =
250 250
 				// * 1 : {x y} ; on recoit $v[0] = y
251 251
 				// * 2 : {x !op y} ; on recoit $v[0] = 'NOT', $v[1] = array() // array du type {x op y}
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
 		// critere {2,7}
268 268
 		if (isset($this->command['limit']) AND $this->command['limit']) {
269
-			$limit = explode(',',$this->command['limit']);
269
+			$limit = explode(',', $this->command['limit']);
270 270
 			$this->offset = $limit[0];
271 271
 			$this->limit = $limit[1];
272 272
 		}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
 
281 281
 
282
-	protected function ajouter_filtre($cle, $op, $valeur, $not=false) {
282
+	protected function ajouter_filtre($cle, $op, $valeur, $not = false) {
283 283
 		if (method_exists($this->iter, 'exception_des_criteres')) {
284 284
 			if (in_array($cle, $this->iter->exception_des_criteres())) {
285 285
 				return;
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 		} else if ($op == 'IN') {
311 311
 			$filtre = 'in_array('.$a.', array'.$valeur.')';
312 312
 			$op = '';
313
-		} else if (!in_array($op, array('<','<=', '>', '>='))) {
314
-			spip_log('operateur non reconnu ' . $op); // [todo] mettre une erreur de squelette
313
+		} else if (!in_array($op, array('<', '<=', '>', '>='))) {
314
+			spip_log('operateur non reconnu '.$op); // [todo] mettre une erreur de squelette
315 315
 			$op = '';
316 316
 		}
317 317
 	
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	}
328 328
 
329 329
 	
330
-	public function next(){
330
+	public function next() {
331 331
 		$this->pos++;
332 332
 		parent::next();
333 333
 	}
@@ -366,26 +366,26 @@  discard block
 block discarded – undo
366 366
 	 * position courante de l'iterateur
367 367
 	 * @var int
368 368
 	 */
369
-	protected $pos=null;
369
+	protected $pos = null;
370 370
 
371 371
 	/**
372 372
 	 * nombre total resultats dans l'iterateur
373 373
 	 * @var int
374 374
 	 */
375
-	protected $total=null;
375
+	protected $total = null;
376 376
 
377 377
 	/**
378 378
 	 * nombre maximal de recherche pour $total
379 379
 	 * si l'iterateur n'implemente pas de fonction specifique
380 380
 	 */
381
-	 protected $max=100000;
381
+	 protected $max = 100000;
382 382
 
383 383
 
384 384
 	/**
385 385
 	 * Liste des champs a inserer dans les $row
386 386
 	 * retournes par ->fetch()
387 387
 	 */
388
-	 protected $select=array();
388
+	 protected $select = array();
389 389
 
390 390
 	 
391 391
 	/**
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	 * @return bool
400 400
 	 *   success or fail if not implemented
401 401
 	 */
402
-	public function seek($n=0, $continue=null) {
402
+	public function seek($n = 0, $continue = null) {
403 403
 		if ($this->func_filtre OR !method_exists($this->iter, 'seek') OR !$this->iter->seek($n)) {
404 404
 			$this->seek_loop($n);
405 405
 		}
@@ -429,16 +429,16 @@  discard block
 block discarded – undo
429 429
 	 * @param  $max
430 430
 	 * @return int
431 431
 	 */
432
-	public function skip($saut, $max=null){
432
+	public function skip($saut, $max = null) {
433 433
 		// pas de saut en arriere autorise pour cette fonction
434
-		if (($saut=intval($saut))<=0) return $this->pos;
434
+		if (($saut = intval($saut)) <= 0) return $this->pos;
435 435
 		$seek = $this->pos + $saut;
436 436
 		// si le saut fait depasser le maxi, on libere la resource
437 437
 		// et on sort
438 438
 		if (is_null($max))
439 439
 			$max = $this->count();
440 440
 
441
-		if ($seek>=$max OR $seek>=$this->count()) {
441
+		if ($seek >= $max OR $seek >= $this->count()) {
442 442
 			// sortie plus rapide que de faire next() jusqu'a la fin !
443 443
 			$this->free();
444 444
 		  return $max;
Please login to merge, or discard this patch.
ecrire/action/editer_objet.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
  * @param array $set
23 23
  * @return array
24 24
  */
25
-function action_editer_objet_dist($id=null, $objet=null, $set=null) {
25
+function action_editer_objet_dist($id = null, $objet = null, $set = null) {
26 26
 
27 27
 	// appel direct depuis une url interdit
28
-	if (is_null($id) OR is_null($objet)){
28
+	if (is_null($id) OR is_null($objet)) {
29 29
 		include_spip('inc/minipres');
30 30
 		echo minipres(_T('info_acces_interdit'));
31 31
 		die();
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		$id = objet_inserer($objet, $id_parent);
40 40
 	}
41 41
 
42
-	if (!($id = intval($id))>0)
43
-		return array($id,_L('echec enregistrement en base'));
42
+	if (!($id = intval($id)) > 0)
43
+		return array($id, _L('echec enregistrement en base'));
44 44
 
45 45
 	// Enregistre l'envoi dans la BD
46 46
 	$err = objet_modifier($objet, $id, $set);
47 47
 
48
-	return array($id,$err);
48
+	return array($id, $err);
49 49
 }
50 50
 
51 51
 /**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param array|null $set
58 58
  * @return mixed|string
59 59
  */
60
-function objet_modifier($objet, $id, $set=null) {
60
+function objet_modifier($objet, $id, $set = null) {
61 61
 	if (include_spip('action/editer_'.$objet)
62 62
 	  AND function_exists($modifier = $objet."_modifier"))
63
-		return $modifier($id,$set);
63
+		return $modifier($id, $set);
64 64
 
65 65
 	$table_sql = table_objet_sql($objet);
66
-	$trouver_table = charger_fonction('trouver_table','base');
66
+	$trouver_table = charger_fonction('trouver_table', 'base');
67 67
 	$desc = $trouver_table($table_sql);
68 68
 	if (!$desc OR !isset($desc['field'])) {
69
-		spip_log("Objet $objet inconnu dans objet_modifier",_LOG_ERREUR);
69
+		spip_log("Objet $objet inconnu dans objet_modifier", _LOG_ERREUR);
70 70
 		return _L("Erreur objet $objet inconnu");
71 71
 	}
72 72
 	include_spip('inc/modifier');
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 		// white list
90 90
 		$white,
91 91
 		// black list
92
-		array($champ_date,'statut','id_parent','id_secteur'),
92
+		array($champ_date, 'statut', 'id_parent', 'id_secteur'),
93 93
 		// donnees eventuellement fournies
94 94
 		$set
95 95
 	);
96 96
 
97 97
 	// Si l'objet est publie, invalider les caches et demander sa reindexation
98
-	if (objet_test_si_publie($objet,$id)){
98
+	if (objet_test_si_publie($objet, $id)) {
99 99
 		$invalideur = "id='$objet/$id'";
100 100
 		$indexation = true;
101 101
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			'invalideur' => $invalideur,
112 112
 			'indexation' => $indexation,
113 113
 			 // champ a mettre a date('Y-m-d H:i:s') s'il y a modif
114
-			'date_modif' => (isset($desc['field']['date_modif'])?'date_modif':'')
114
+			'date_modif' => (isset($desc['field']['date_modif']) ? 'date_modif' : '')
115 115
 		),
116 116
 		$c))
117 117
 		return $err;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	// Modification de statut, changement de rubrique ?
120 120
 	// FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout
121 121
 	//         le tableau $set hors black liste, mais du coup on a possiblement des champs en trop. 
122
-	$c = collecter_requests(array($champ_date, 'statut', 'id_parent'),array(),$set);
122
+	$c = collecter_requests(array($champ_date, 'statut', 'id_parent'), array(), $set);
123 123
 	$err = objet_instituer($objet, $id, $c);
124 124
 
125 125
 	return $err;
@@ -132,24 +132,24 @@  discard block
 block discarded – undo
132 132
  * @param array|null $set
133 133
  * @return bool|int
134 134
  */
135
-function objet_inserer($objet, $id_parent=null, $set=null) {
135
+function objet_inserer($objet, $id_parent = null, $set = null) {
136 136
 	if (include_spip('action/editer_'.$objet)
137 137
 	  AND function_exists($inserer = $objet."_inserer"))
138 138
 		return $inserer($id_parent);
139 139
 
140 140
 	$table_sql = table_objet_sql($objet);
141
-	$trouver_table = charger_fonction('trouver_table','base');
141
+	$trouver_table = charger_fonction('trouver_table', 'base');
142 142
 	$desc = $trouver_table($table_sql);
143 143
 	if (!$desc OR !isset($desc['field']))
144 144
 		return 0;
145 145
 
146 146
 	$lang_rub = "";
147 147
 	$champs = array();
148
-	if (isset($desc['field']['id_rubrique'])){
148
+	if (isset($desc['field']['id_rubrique'])) {
149 149
 		// Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet
150 150
 		// dans la premiere rubrique racine
151 151
 		if (!$id_rubrique = intval($id_parent)) {
152
-			$row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1");
152
+			$row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0", '', '0+titre,titre', "1");
153 153
 			$id_rubrique = $row['id_rubrique'];
154 154
 		}
155 155
 		else
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 		$champs['langue_choisie'] = 'non';
180 180
 	}
181 181
 
182
-	if (isset($desc['field']['statut'])){
183
-		if (isset($desc['statut_textes_instituer'])){
182
+	if (isset($desc['field']['statut'])) {
183
+		if (isset($desc['statut_textes_instituer'])) {
184 184
 			$cles_statut = array_keys($desc['statut_textes_instituer']); 
185 185
 			$champs['statut'] = reset($cles_statut);
186 186
 		}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	}
190 190
 
191 191
 
192
-	if ((isset($desc['date']) AND $d=$desc['date']) OR isset($desc['field'][$d='date']))
192
+	if ((isset($desc['date']) AND $d = $desc['date']) OR isset($desc['field'][$d = 'date']))
193 193
 		$champs[$d] = date('Y-m-d H:i:s');
194 194
 
195 195
 	if ($set)
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 
208 208
 	$id = sql_insertq($table_sql, $champs);
209 209
 
210
-	if ($id){
210
+	if ($id) {
211 211
 		pipeline('post_insertion',
212 212
 			array(
213 213
 				'args' => array(
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 		// si la table n'a pas deja un champ id_auteur
224 224
 		// et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association)
225 225
 		if ($id > 0
226
-		  AND !isset($desc['field']['id_auteur'])){
227
-			$id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))?
226
+		  AND !isset($desc['field']['id_auteur'])) {
227
+			$id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur'])) ?
228 228
 				$GLOBALS['visiteur_session']['id_auteur']
229 229
 				:_request('id_auteur'));
230 230
 		  if ($id_auteur) {
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
  * @param bool $calcul_rub
250 250
  * @return mixed|string
251 251
  */
252
-function objet_instituer($objet, $id, $c, $calcul_rub=true) {
252
+function objet_instituer($objet, $id, $c, $calcul_rub = true) {
253 253
 	if (include_spip('action/editer_'.$objet)
254 254
 	  AND function_exists($instituer = $objet."_instituer"))
255
-		return $instituer($id,$c,$calcul_rub);
255
+		return $instituer($id, $c, $calcul_rub);
256 256
 
257 257
 	$table_sql = table_objet_sql($objet);
258
-	$trouver_table = charger_fonction('trouver_table','base');
258
+	$trouver_table = charger_fonction('trouver_table', 'base');
259 259
 	$desc = $trouver_table($table_sql);
260 260
 	if (!$desc OR !isset($desc['field']))
261 261
 		return _L("Impossible d'instituer $objet : non connu en base");
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	include_spip('inc/modifier');
266 266
 
267 267
 	$sel = array();
268
-	$sel[] = (isset($desc['field']['statut'])?"statut":"'' as statut");
268
+	$sel[] = (isset($desc['field']['statut']) ? "statut" : "'' as statut");
269 269
 
270 270
 	$champ_date = '';
271 271
 	if (isset($desc['date']) AND $desc['date'])
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		$champ_date = 'date';
275 275
 
276 276
 	$sel[] = ($champ_date ? "$champ_date as date" : "'' as date");
277
-	$sel[] = (isset($desc['field']['id_rubrique'])?'id_rubrique':"0 as id_rubrique");
277
+	$sel[] = (isset($desc['field']['id_rubrique']) ? 'id_rubrique' : "0 as id_rubrique");
278 278
 
279 279
 	$row = sql_fetsel($sel, $table_sql, id_table_objet($objet).'='.intval($id));
280 280
 
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 	$date_ancienne = $date = $row['date'];
284 284
 	$champs = array();
285 285
 
286
-	$d = ($date AND isset($c[$champ_date]))?$c[$champ_date]:null;
287
-	$s = (isset($desc['field']['statut']) AND isset($c['statut']))?$c['statut']:$statut;
286
+	$d = ($date AND isset($c[$champ_date])) ? $c[$champ_date] : null;
287
+	$s = (isset($desc['field']['statut']) AND isset($c['statut'])) ? $c['statut'] : $statut;
288 288
 
289 289
 	// cf autorisations dans inc/instituer_objet
290 290
 	if ($s != $statut OR ($d AND $d != $date)) {
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 				autoriser('instituer', $objet, $id, null, array('statut'=>$s))
295 295
 			)
296 296
 			$statut = $champs['statut'] = $s;
297
-		else if ($s!='publie' AND autoriser('modifier', $objet, $id))
297
+		else if ($s != 'publie' AND autoriser('modifier', $objet, $id))
298 298
 			$statut = $champs['statut'] = $s;
299 299
 		else
300
-			spip_log("editer_objet $id refus " . join(' ', $c));
300
+			spip_log("editer_objet $id refus ".join(' ', $c));
301 301
 
302 302
 		// En cas de publication, fixer la date a "maintenant"
303 303
 		// sauf si $c commande autre chose
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 			 OR ($champs['statut'] == 'prop' AND !in_array($statut_ancien, array('publie', 'prop')))
309 309
 			 OR $d
310 310
 			) {
311
-				if ($d OR strtotime($d=$date)>time())
311
+				if ($d OR strtotime($d = $date) > time())
312 312
 					$champs[$champ_date] = $date = $d;
313 313
 				else
314 314
 					$champs[$champ_date] = $date = date('Y-m-d H:i:s');
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
  * @param bool $cond
403 403
  * @return 
404 404
  */
405
-function objet_editer_heritage($objet, $id, $id_rubrique, $statut, $champs, $cond=true) {
405
+function objet_editer_heritage($objet, $id, $id_rubrique, $statut, $champs, $cond = true) {
406 406
 	$table_sql = table_objet_sql($objet);
407
-	$trouver_table = charger_fonction('trouver_table','base');
407
+	$trouver_table = charger_fonction('trouver_table', 'base');
408 408
 	$desc = $trouver_table($table_sql);
409 409
 
410 410
 	// Si on deplace l'objet
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			$champs['id_secteur'] = $row_rub['id_secteur'];
419 419
 
420 420
 		if (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie']))
421
-			if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) {
421
+			if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>".sql_quote($langue))) {
422 422
 				$champs['lang'] = $langue;
423 423
 			}
424 424
 	}
Please login to merge, or discard this patch.