Completed
Push — spip-3.0 ( 1797f4...52731c )
by cam
09:29
created
ecrire/install/etape_chmod.php 1 patch
Spacing   +16 added lines, -17 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 	// Comparer l'appartenance d'un fichier cree par PHP
38 38
 	// avec celle du script et du repertoire courant
39
-	if(!$chmod) {
39
+	if (!$chmod) {
40 40
 		@rmdir('test');
41 41
 		spip_unlink('test'); // effacer au cas ou
42 42
 		@touch('test');
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 function install_etape_chmod_dist()
68 68
 {
69 69
 	global $test_dirs;
70
-	$test_dir =  _request('test_dir');
70
+	$test_dir = _request('test_dir');
71 71
 	$chmod = 0;
72 72
 
73 73
 	if ($test_dir) {
74
-		if (substr($test_dir,-1)!=='/') $test_dir .= '/';
75
-		if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE  . $test_dir;
74
+		if (substr($test_dir, -1) !== '/') $test_dir .= '/';
75
+		if (!in_array($test_dir, $test_dirs)) $test_dirs[] = _DIR_RACINE.$test_dir;
76 76
 	} else {
77 77
 		if (!_FILE_CONNECT) {
78 78
 			$test_dirs[] = _DIR_CONNECT;
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 	}
82 82
 
83 83
 	$bad_dirs = array();
84
-	$absent_dirs  = array();;
84
+	$absent_dirs = array(); ;
85 85
 
86 86
 	while (list(, $my_dir) = each($test_dirs)) {
87 87
 		$test = test_ecrire($my_dir);
88 88
 		if (!$test) {
89
-			$m = preg_replace(',^' . _DIR_RACINE . ',', '',$my_dir);
89
+			$m = preg_replace(',^'._DIR_RACINE.',', '', $my_dir);
90 90
 			if (@file_exists($my_dir)) {
91 91
 				$bad_dirs["<li>".$m."</li>"] = 1;
92 92
 			} else
@@ -98,35 +98,34 @@  discard block
 block discarded – undo
98 98
 
99 99
 	if (!_FILE_CONNECT) {
100 100
 		$titre = _T('dirs_preliminaire');
101
-		$continuer = ' '._T('dirs_commencer') . '.';
101
+		$continuer = ' '._T('dirs_commencer').'.';
102 102
 	} else
103 103
 		$titre = _T('dirs_probleme_droits');
104 104
 
105 105
 
106
-	$res = "<div align='right'>". menu_langues('var_lang_ecrire')."</div>\n";
106
+	$res = "<div align='right'>".menu_langues('var_lang_ecrire')."</div>\n";
107 107
 
108 108
 	if ($bad_dirs) {
109 109
 		$res .=
110 110
 		  _T('dirs_repertoires_suivants',
111
-		     array('bad_dirs' => join("\n", array_keys($bad_dirs)))) .
112
-		  	"<b>". _T('login_recharger')."</b>.";
111
+		     array('bad_dirs' => join("\n", array_keys($bad_dirs)))).
112
+		  	"<b>"._T('login_recharger')."</b>.";
113 113
 	}
114 114
 
115 115
 	if ($absent_dirs) {
116 116
 	  	$res .=
117 117
 			_T('dirs_repertoires_absents',
118
-			   array('bad_dirs' => join("\n", array_keys($absent_dirs)))) .
119
-			"<b>". _T('login_recharger')."</b>.";
118
+			   array('bad_dirs' => join("\n", array_keys($absent_dirs)))).
119
+			"<b>"._T('login_recharger')."</b>.";
120 120
 	}
121
-	$res = "<p>" . $continuer  . $res . aide ("install0", true) . "</p>";
121
+	$res = "<p>".$continuer.$res.aide("install0", true)."</p>";
122 122
 
123 123
 	$t = _T('login_recharger');
124
-	$t = (!$test_dir ? '' :
125
-		"<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />")
124
+	$t = (!$test_dir ? '' : "<input type='hidden' name='test_dir' value='".spip_htmlspecialchars($test_dir, ENT_QUOTES)."' />")
126 125
 	. "<input type='hidden' name='etape' value='chmod' />"
127
-	. "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>";
126
+	. "<div style='text-align: right'><input type='submit' value='".attribut_html($t)."' /></div>";
128 127
 
129
-	echo minipres($titre, $res . generer_form_ecrire('install',  $t));
128
+	echo minipres($titre, $res.generer_form_ecrire('install', $t));
130 129
 
131 130
 	} else {
132 131
 		$deja = (_FILE_CONNECT AND analyse_fichier_connection(_FILE_CONNECT));
Please login to merge, or discard this patch.
ecrire/inc/utils.php 1 patch
Spacing   +342 added lines, -345 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
  * @param bool $continue
30 30
  * @return string
31 31
  */
32
-function charger_fonction($nom, $dossier='exec', $continue=false) {
32
+function charger_fonction($nom, $dossier = 'exec', $continue = false) {
33 33
 	static $echecs = array();
34 34
 
35
-	if (strlen($dossier) AND substr($dossier,-1) != '/') $dossier .= '/';
36
-	$f = str_replace('/','_',$dossier) . $nom;
35
+	if (strlen($dossier) AND substr($dossier, -1) != '/') $dossier .= '/';
36
+	$f = str_replace('/', '_', $dossier).$nom;
37 37
 
38 38
 	if (function_exists($f))
39 39
 		return $f;
40
-	if (function_exists($g = $f . '_dist'))
40
+	if (function_exists($g = $f.'_dist'))
41 41
 		return $g;
42 42
 
43 43
 	if (isset($echecs[$f])) return $echecs[$f];
44 44
 	// Sinon charger le fichier de declaration si plausible
45 45
 
46
-	if (!preg_match(',^\w+$,', $f)){
46
+	if (!preg_match(',^\w+$,', $f)) {
47 47
 		if ($continue) return false; //appel interne, on passe
48 48
 		include_spip('inc/minipres');
49 49
 		echo minipres();
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
 	if (!$inc = include_spip($dossier.($d = strtolower($nom)))
56 56
 		// si le fichier truc/machin/nom.php n'existe pas,
57 57
 		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
58
-		AND strlen(dirname($dossier)) AND dirname($dossier)!='.')
59
-		include_spip(substr($dossier,0,-1));
58
+		AND strlen(dirname($dossier)) AND dirname($dossier) != '.')
59
+		include_spip(substr($dossier, 0, -1));
60 60
 	if (function_exists($f)) return $f;
61 61
 	if (function_exists($g)) return $g;
62 62
 
63 63
 	if ($continue) return $echecs[$f] = false;
64 64
 
65 65
 	// Echec : message d'erreur
66
-	spip_log("fonction $nom ($f ou $g) indisponible" .
66
+	spip_log("fonction $nom ($f ou $g) indisponible".
67 67
 		($inc ? "" : " (fichier $d absent de $dossier)"));
68 68
 
69 69
 	include_spip('inc/minipres');
70 70
 	echo minipres(_T('forum_titre_erreur'),
71 71
 		 _T('fichier_introuvable', array('fichier'=> '<b>'.spip_htmlentities($d).'</b>')),
72
-		array('all_inline'=>true,'status'=>404));
72
+		array('all_inline'=>true, 'status'=>404));
73 73
 	exit;
74 74
 }
75 75
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
  * @param string $file
79 79
  * @return bool
80 80
  */
81
-function include_once_check($file){
82
-	if (file_exists($file)) {include_once $file;return true;}
83
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins'])?unserialize($GLOBALS['meta']['message_crash_plugins']):'');
84
-	$crash = ($crash?$crash:array());
81
+function include_once_check($file) {
82
+	if (file_exists($file)) {include_once $file; return true; }
83
+	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ?unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
84
+	$crash = ($crash ? $crash : array());
85 85
 	$crash[$file] = true;
86
-	ecrire_meta('message_crash_plugins',serialize($crash));
86
+	ecrire_meta('message_crash_plugins', serialize($crash));
87 87
 	return false;
88 88
 }
89 89
 
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 //
93 93
 // http://doc.spip.org/@include_spip
94 94
 function include_spip($f, $include = true) {
95
-	return find_in_path($f . '.php', '', $include);
95
+	return find_in_path($f.'.php', '', $include);
96 96
 }
97 97
 
98 98
 
99 99
 function require_spip($f) {
100
-	return find_in_path($f . '.php', '', 'required');
100
+	return find_in_path($f.'.php', '', 'required');
101 101
 }
102 102
 
103 103
 // un pipeline est lie a une action et une valeur
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 // utilisee dans le script pipeline precompile
114 114
 // on passe $val par reference pour limiter les allocations memoire
115 115
 // http://doc.spip.org/@minipipe
116
-function minipipe($fonc,&$val){
116
+function minipipe($fonc, &$val) {
117 117
 	// fonction
118 118
 	if (function_exists($fonc))
119 119
 		$val = call_user_func($fonc, $val);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 // chargement du pipeline sous la forme d'un fichier php prepare
132 132
 // http://doc.spip.org/@pipeline
133
-function pipeline($action, $val=null) {
133
+function pipeline($action, $val = null) {
134 134
 	static $charger;
135 135
 
136 136
 	// chargement initial des fonctions mises en cache, ou generation du cache
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 	}
157 157
 	// plantage ?
158 158
 	else {
159
-		spip_log("fonction $fonc absente : pipeline desactive",_LOG_ERREUR);
159
+		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
160 160
 	}
161 161
 
162 162
 	// si le flux est une table avec 2 cle args&data
163 163
 	// on ne ressort du pipe que les donnees dans 'data'
164 164
 	// array_key_exists pour php 4.1.0
165 165
 	if (is_array($val)
166
-	  AND count($val)==2
167
-	  AND (array_key_exists('data',$val)))
166
+	  AND count($val) == 2
167
+	  AND (array_key_exists('data', $val)))
168 168
 		$val = $val['data'];
169 169
 	return $val;
170 170
 }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
  * @param string $logdir  ## inutile !! a supprimer ?
187 187
  * @param string $logsuf  ## inutile !! a supprimer ?
188 188
  */
189
-function spip_log($message=NULL, $name=NULL) {
189
+function spip_log($message = NULL, $name = NULL) {
190 190
 	static $pre = array();
191 191
 	static $log;
192 192
 	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		$niveau = _LOG_INFO;
197 197
 
198 198
 	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
199
-		if (!$pre){
199
+		if (!$pre) {
200 200
 			$pre = array(
201 201
 				_LOG_HS=>'HS:',
202 202
 				_LOG_ALERTE_ROUGE=>'ALERTE:',
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 // Renvoie le _GET ou le _POST emis par l'utilisateur
225 225
 // ou pioche dans $c si c'est un array()
226 226
 // http://doc.spip.org/@_request
227
-function _request($var, $c=false) {
227
+function _request($var, $c = false) {
228 228
 
229 229
 	if (is_array($c))
230 230
 		return isset($c[$var]) ? $c[$var] : NULL;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 // Methode set de la fonction _request()
257 257
 // Attention au cas ou l'on fait set_request('truc', NULL);
258 258
 // http://doc.spip.org/@set_request
259
-function set_request($var, $val = NULL, $c=false) {
259
+function set_request($var, $val = NULL, $c = false) {
260 260
 	if (is_array($c)) {
261 261
 		unset($c[$var]);
262 262
 		if ($val !== NULL)
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
  * @param string $sep
313 313
  * @return string
314 314
  */
315
-function parametre_url($url, $c, $v=NULL, $sep='&amp;') {
315
+function parametre_url($url, $c, $v = NULL, $sep = '&amp;') {
316 316
 	// requete erronnee : plusieurs variable dans $c et aucun $v
317
-	if (strpos($c,"|")!==false AND is_null($v))
317
+	if (strpos($c, "|") !== false AND is_null($v))
318 318
 		return null;
319 319
 
320 320
 	// lever l'#ancre
@@ -329,17 +329,17 @@  discard block
 block discarded – undo
329 329
 
330 330
 	// recuperer la base
331 331
 	$a = array_shift($url);
332
-	if (!$a) $a= './';
332
+	if (!$a) $a = './';
333 333
 
334
-	$regexp = ',^(' . str_replace('[]','\[\]',$c) . '[[]?[]]?)(=.*)?$,';
335
-	$ajouts = array_flip(explode('|',$c));
334
+	$regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,';
335
+	$ajouts = array_flip(explode('|', $c));
336 336
 	$u = is_array($v) ? $v : rawurlencode($v);
337
-	$testv = (is_array($v)?count($v):strlen($v));
337
+	$testv = (is_array($v) ?count($v) : strlen($v));
338 338
 	// lire les variables et agir
339 339
 	foreach ($url as $n => $val) {
340 340
 		if (preg_match($regexp, urldecode($val), $r)) {
341 341
 			if ($v === NULL) {
342
-				return $r[2]?substr($r[2],1):'';
342
+				return $r[2] ?substr($r[2], 1) : '';
343 343
 			}
344 344
 			// suppression
345 345
 			elseif (!$testv) {
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			}
348 348
 	// Ajout. Pour une variable, remplacer au meme endroit,
349 349
 	// pour un tableau ce sera fait dans la prochaine boucle
350
-			elseif (substr($r[1],-2) != '[]') {
350
+			elseif (substr($r[1], -2) != '[]') {
351 351
 				$url[$n] = $r[1].'='.$u;
352 352
 				unset($ajouts[$r[1]]);
353 353
 			}
@@ -357,15 +357,15 @@  discard block
 block discarded – undo
357 357
 	// traiter les parametres pas encore trouves
358 358
 	if ($v === NULL
359 359
 	AND $args = func_get_args()
360
-	AND count($args)==2)
360
+	AND count($args) == 2)
361 361
 		return $v;
362 362
 	elseif ($testv) {
363
-		foreach($ajouts as $k => $n) {
363
+		foreach ($ajouts as $k => $n) {
364 364
 		  if (!is_array($v))
365
-		    $url[] = $k .'=' . $u;
365
+		    $url[] = $k.'='.$u;
366 366
 		  else {
367
-		  	$id = (substr($k,-2) == '[]') ? $k : ($k ."[]");
368
-		    foreach ($v as $w) $url[]= $id .'=' . $w;
367
+		  	$id = (substr($k, -2) == '[]') ? $k : ($k."[]");
368
+		    foreach ($v as $w) $url[] = $id.'='.$w;
369 369
 		  }
370 370
 		}
371 371
 	}
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
 
376 376
 	// recomposer l'adresse
377 377
 	if ($url)
378
-		$a .= '?' . join($sep, $url);
378
+		$a .= '?'.join($sep, $url);
379 379
 
380
-	return $a . $ancre;
380
+	return $a.$ancre;
381 381
 }
382 382
 
383 383
 // Prend une URL et lui ajoute/retire une ancre apres l'avoir nettoyee
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
390 390
 		$url = $r[1];
391 391
 	}
392
-	if (preg_match('/[^-_a-zA-Z0-9]+/S',$ancre)){
392
+	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
393 393
 		if (!function_exists('translitteration'))
394 394
 			include_spip('inc/charsets');
395 395
 		$ancre = preg_replace(array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), array('', '-'),
396 396
 						translitteration($ancre));
397 397
 	}
398
-	return $url . (strlen($ancre) ? '#'. $ancre : '');
398
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
399 399
 }
400 400
 
401 401
 /**
@@ -409,17 +409,16 @@  discard block
 block discarded – undo
409 409
 {
410 410
 	static $done = false;
411 411
 	static $propre = '';
412
-	if (!is_null($reset)) return $propre=$reset;
412
+	if (!is_null($reset)) return $propre = $reset;
413 413
 	if ($done) return $propre;
414 414
 	$done = true;
415 415
 
416 416
 	$uri1 = $GLOBALS['REQUEST_URI'];
417 417
 	do {
418 418
 		$uri = $uri1;
419
-		$uri1 = preg_replace
420
-			(',([?&])(PHPSESSID|(var_[^=&]*))=[^&]*(&|$),i',
419
+		$uri1 = preg_replace(',([?&])(PHPSESSID|(var_[^=&]*))=[^&]*(&|$),i',
421 420
 			'\1', $uri);
422
-	} while ($uri<>$uri1);
421
+	} while ($uri <> $uri1);
423 422
 
424 423
 	return $propre = (preg_replace(',[?&]$,', '', $uri1));
425 424
 }
@@ -439,19 +438,19 @@  discard block
 block discarded – undo
439 438
 	if (!$root
440 439
 		AND (
441 440
 			// si pas de profondeur on peut tronquer
442
-			$GLOBALS['profondeur_url']<(_DIR_RESTREINT?1:2)
441
+			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
443 442
 			// sinon c'est OK si _SET_HTML_BASE a ete force a false
444 443
 			OR (defined('_SET_HTML_BASE') AND !_SET_HTML_BASE))
445 444
 		)
446 445
 		$url = preg_replace(',^[^?]*/,', '', $url);
447 446
 	// ajouter le cas echeant les variables _POST['id_...']
448 447
 	foreach ($_POST as $v => $c)
449
-		if (substr($v,0,3) == 'id_')
448
+		if (substr($v, 0, 3) == 'id_')
450 449
 			$url = parametre_url($url, $v, $c, '&');
451 450
 
452 451
 	// supprimer les variables sans interet
453 452
 	if (test_espace_prive()) {
454
-		$url = preg_replace (',([?&])('
453
+		$url = preg_replace(',([?&])('
455 454
 		.'lang|show_docs|'
456 455
 		.'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
457 456
 		$url = preg_replace(',([?&])[&]+,', '\1', $url);
@@ -487,8 +486,8 @@  discard block
 block discarded – undo
487 486
  * @param string $plugin
488 487
  * @return bool
489 488
  */
490
-function test_plugin_actif($plugin){
491
-	return ($plugin AND defined('_DIR_PLUGIN_'.strtoupper($plugin)))? true:false;
489
+function test_plugin_actif($plugin) {
490
+	return ($plugin AND defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true:false;
492 491
 }
493 492
 
494 493
 /**
@@ -502,14 +501,14 @@  discard block
 block discarded – undo
502 501
  *   bool force : forcer un retour meme si la chaine n'a pas de traduction
503 502
  * @return mixed|string
504 503
  */
505
-function _T($texte, $args=array(), $options=array()) {
506
-	static $traduire=false ;
504
+function _T($texte, $args = array(), $options = array()) {
505
+	static $traduire = false;
507 506
 	$o = array('class'=>'', 'force'=>true);
508
-	if ($options){
507
+	if ($options) {
509 508
 		// support de l'ancien argument $class
510 509
 		if (is_string($options))
511 510
 			$options = array('class'=>$options);
512
-		$o = array_merge($o,$options);
511
+		$o = array_merge($o, $options);
513 512
 	}
514 513
 
515 514
  	if (!$traduire) {
@@ -519,7 +518,7 @@  discard block
 block discarded – undo
519 518
 	
520 519
 	// On peut passer explicitement la langue dans le tableau
521 520
 	// On utilise le même nom de variable que la globale
522
-	if (isset($args['spip_lang'])){
521
+	if (isset($args['spip_lang'])) {
523 522
 		$lang = $args['spip_lang'];
524 523
 		// On l'enleve pour ne pas le passer au remplacement
525 524
 		unset($args['spip_lang']);
@@ -530,7 +529,7 @@  discard block
 block discarded – undo
530 529
 	}
531 530
 	$text = $traduire($texte, $lang);
532 531
 
533
-	if (!strlen($text)){
532
+	if (!strlen($text)) {
534 533
 		if (!$o['force'])
535 534
 			return '';
536 535
 
@@ -539,8 +538,7 @@  discard block
 block discarded – undo
539 538
 		// pour les chaines non traduites, assurer un service minimum
540 539
 		if (!$GLOBALS['test_i18n'] AND (_request('var_mode') != 'traduction'))
541 540
 			$text = str_replace('_', ' ',
542
-				 (($n = strpos($text,':')) === false ? $texte :
543
-					substr($texte, $n+1)));
541
+				 (($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1)));
544 542
 		$o['class'] = null;
545 543
 
546 544
 	}
@@ -552,21 +550,21 @@  discard block
 block discarded – undo
552 550
 // Remplacer les variables @....@ par leur valeur dans une chaine de langue.
553 551
 // Aussi appelee quand une chaine n'est pas encore dans les fichiers de langue
554 552
 // http://doc.spip.org/@_L
555
-function _L($text, $args=array(), $class=null) {
553
+function _L($text, $args = array(), $class = null) {
556 554
 	$f = $text;
557 555
 	if (is_array($args)) {
558 556
 		foreach ($args as $name => $value) {
559 557
 			if ($class)
560 558
 				$value = "<span class='$class'>$value</span>";
561
-			$t = str_replace ("@$name@", $value, $text);
562
-			if ($text !== $t) {unset($args[$name]); $text = $t;}
559
+			$t = str_replace("@$name@", $value, $text);
560
+			if ($text !== $t) {unset($args[$name]); $text = $t; }
563 561
 		}
564 562
 		// Si des variables n'ont pas ete inserees, le signaler
565 563
 		// (chaines de langues pas a jour)
566
-		if ($args) spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)),_LOG_DEBUG);
564
+		if ($args) spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
567 565
 	}
568 566
 
569
-	if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class===null)
567
+	if (($GLOBALS['test_i18n'] OR (_request('var_mode') == 'traduction')) AND $class === null)
570 568
 		return "<span class=debug-traduction-erreur>$text</span>";
571 569
 	else
572 570
 		return $text;
@@ -576,9 +574,9 @@  discard block
 block discarded – undo
576 574
 // ou tmp/ au lieu de ../tmp/
577 575
 // http://doc.spip.org/@joli_repertoire
578 576
 function joli_repertoire($rep) {
579
-	$a = substr($rep,0,1);
580
-	if ($a<>'.' AND $a<>'/')
581
-		$rep = (_DIR_RESTREINT?'':_DIR_RESTREINT_ABS).$rep;
577
+	$a = substr($rep, 0, 1);
578
+	if ($a <> '.' AND $a <> '/')
579
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
582 580
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
583 581
 	return $rep;
584 582
 }
@@ -588,12 +586,12 @@  discard block
 block discarded – undo
588 586
 // spip_timer : on l'appelle deux fois et on a la difference, affichable
589 587
 //
590 588
 // http://doc.spip.org/@spip_timer
591
-function spip_timer($t='rien', $raw = false) {
589
+function spip_timer($t = 'rien', $raw = false) {
592 590
 	static $time;
593
-	$a=time(); $b=microtime();
591
+	$a = time(); $b = microtime();
594 592
 	// microtime peut contenir les microsecondes et le temps
595
-	$b=explode(' ',$b);
596
-	if (count($b)==2) $a = end($b); // plus precis !
593
+	$b = explode(' ', $b);
594
+	if (count($b) == 2) $a = end($b); // plus precis !
597 595
 	$b = reset($b);
598 596
 	if (!isset($time[$t])) {
599 597
 		$time[$t] = $a + $b;
@@ -605,10 +603,10 @@  discard block
 block discarded – undo
605 603
 		if ($p < 1000)
606 604
 			$s = '';
607 605
 		else {
608
-			$s = sprintf("%d ", $x = floor($p/1000));
609
-			$p -= ($x*1000);
606
+			$s = sprintf("%d ", $x = floor($p / 1000));
607
+			$p -= ($x * 1000);
610 608
 		}
611
-		return $s . sprintf($s?"%07.3f ms":"%.3f ms", $p);
609
+		return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
612 610
 	}
613 611
 }
614 612
 
@@ -616,13 +614,13 @@  discard block
 block discarded – undo
616 614
 // Renvoie False si un fichier n'est pas plus vieux que $duree secondes,
617 615
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
618 616
 // http://doc.spip.org/@spip_touch
619
-function spip_touch($fichier, $duree=0, $touch=true) {
617
+function spip_touch($fichier, $duree = 0, $touch = true) {
620 618
 	if ($duree) {
621 619
 		clearstatcache();
622
-		if ((@$f=filemtime($fichier)) AND ($f >= time() - $duree))
620
+		if ((@$f = filemtime($fichier)) AND ($f >= time() - $duree))
623 621
 			return false;
624 622
 	}
625
-	if ($touch!==false) {
623
+	if ($touch !== false) {
626 624
 		if (!@touch($fichier)) { spip_unlink($fichier); @touch($fichier); };
627 625
 		@chmod($fichier, _SPIP_CHMOD & ~0111);
628 626
 	}
@@ -641,7 +639,7 @@  discard block
 block discarded – undo
641 639
 	include_spip('inc/headers');
642 640
 	http_status(204); // No Content
643 641
 	header("Connection: close");
644
-	define('_DIRECT_CRON_FORCE',true);
642
+	define('_DIRECT_CRON_FORCE', true);
645 643
 	cron();
646 644
 }
647 645
 
@@ -661,7 +659,7 @@  discard block
 block discarded – undo
661 659
  *   taches forcees, pour compat avec ancienne syntaxe
662 660
  * @return bool
663 661
  */
664
-function cron ($taches=array(), $taches_old= array()) {
662
+function cron($taches = array(), $taches_old = array()) {
665 663
 	// si pas en mode cron force, laisser tomber.
666 664
 	if (!defined('_DIRECT_CRON_FORCE')) return false;
667 665
 	if (!is_array($taches)) $taches = $taches_old; // compat anciens appels
@@ -670,7 +668,7 @@  discard block
 block discarded – undo
670 668
 	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
671 669
 	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
672 670
 	if ($taches AND count($taches) AND !spip_connect())  return false;
673
-	spip_log("cron !",'jq'._LOG_DEBUG);
671
+	spip_log("cron !", 'jq'._LOG_DEBUG);
674 672
 	if ($genie = charger_fonction('genie', 'inc', true)) {
675 673
 		return $genie($taches);
676 674
 	}
@@ -699,7 +697,7 @@  discard block
 block discarded – undo
699 697
  * @return int
700 698
  *	id of job
701 699
  */
702
-function job_queue_add($function, $description, $arguments = array(), $file = '', $no_duplicate = FALSE, $time=0, $priority=0) {
700
+function job_queue_add($function, $description, $arguments = array(), $file = '', $no_duplicate = FALSE, $time = 0, $priority = 0) {
703 701
 	include_spip('inc/queue');
704 702
 	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
705 703
 }
@@ -710,7 +708,7 @@  discard block
 block discarded – undo
710 708
  *  id of jonb to delete
711 709
  * @return bool
712 710
  */
713
-function job_queue_remove($id_job){
711
+function job_queue_remove($id_job) {
714 712
 	include_spip('inc/queue');
715 713
 	return queue_remove_job($id_job);
716 714
 }
@@ -723,9 +721,9 @@  discard block
 block discarded – undo
723 721
  *  can be a simple array('objet'=>'article','id_objet'=>23)
724 722
  *  or an array of simple array to link multiples objet in one time
725 723
  */
726
-function job_queue_link($id_job,$objets){
724
+function job_queue_link($id_job, $objets) {
727 725
 	include_spip('inc/queue');
728
-	return queue_link_job($id_job,$objets);
726
+	return queue_link_job($id_job, $objets);
729 727
 }
730 728
 
731 729
 
@@ -741,15 +739,15 @@  discard block
 block discarded – undo
741 739
  * @param int/bool $force_next
742 740
  * @return int
743 741
  */
744
-function queue_sleep_time_to_next_job($force=null) {
742
+function queue_sleep_time_to_next_job($force = null) {
745 743
 	static $queue_next_job_time = -1;
746
-	if ($force===true)
744
+	if ($force === true)
747 745
 		$queue_next_job_time = -1;
748 746
 	elseif ($force)
749 747
 		$queue_next_job_time = $force;
750 748
 
751
-	if ($queue_next_job_time==-1) {
752
-		define('_JQ_NEXT_JOB_TIME_FILENAME',_DIR_TMP . "job_queue_next.txt");
749
+	if ($queue_next_job_time == -1) {
750
+		define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt");
753 751
 		// utiliser un cache memoire si dispo
754 752
 		if (include_spip('inc/memoization') AND defined('_MEMOIZE_MEMORY') AND _MEMOIZE_MEMORY) {
755 753
 			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
@@ -765,7 +763,7 @@  discard block
 block discarded – undo
765 763
 		return null;
766 764
 	if (!$_SERVER['REQUEST_TIME'])
767 765
 		$_SERVER['REQUEST_TIME'] = time();
768
-	return $queue_next_job_time-$_SERVER['REQUEST_TIME'];
766
+	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
769 767
 }
770 768
 
771 769
 
@@ -774,23 +772,23 @@  discard block
 block discarded – undo
774 772
 function quote_amp($u) {
775 773
 	return preg_replace(
776 774
 		"/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,5};)/i",
777
-		"&amp;",$u);
775
+		"&amp;", $u);
778 776
 }
779 777
 
780 778
 // Production d'une balise Script valide
781 779
 // http://doc.spip.org/@http_script
782
-function http_script($script, $src='', $noscript='') {
780
+function http_script($script, $src = '', $noscript = '') {
783 781
 	static $done = array();
784 782
 
785
-	if ($src && !isset($done[$src])){
783
+	if ($src && !isset($done[$src])) {
786 784
 		$done[$src] = true;
787 785
 		$src = find_in_path($src, _JAVASCRIPT);
788 786
 		$src = " src='$src'";
789 787
 	}
790 788
 	else $src = '';
791 789
 	if ($script)
792
-		$script = ("/*<![CDATA[*/\n" .
793
-		preg_replace(',</([^>]*)>,','<\/\1>', $script) .
790
+		$script = ("/*<![CDATA[*/\n".
791
+		preg_replace(',</([^>]*)>,', '<\/\1>', $script).
794 792
 		"/*]]>*/");
795 793
 	if ($noscript)
796 794
 		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
@@ -815,10 +813,10 @@  discard block
 block discarded – undo
815 813
 // du path, dans cet ordre.
816 814
 // Exception: si un $dossier_squelette est defini, il reste en tete, pour raison historique
817 815
 // http://doc.spip.org/@_chemin
818
-function _chemin($dir_path=NULL){
816
+function _chemin($dir_path = NULL) {
819 817
 	static $path_base = NULL;
820 818
 	static $path_full = NULL;
821
-	if ($path_base==NULL){
819
+	if ($path_base == NULL) {
822 820
 		// Chemin standard depuis l'espace public
823 821
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
824 822
 			_DIR_RACINE.':'.
@@ -827,9 +825,9 @@  discard block
 block discarded – undo
827 825
 			_DIR_RESTREINT;
828 826
 		// Ajouter squelettes/
829 827
 		if (@is_dir(_DIR_RACINE.'squelettes'))
830
-			$path = _DIR_RACINE.'squelettes/:' . $path;
828
+			$path = _DIR_RACINE.'squelettes/:'.$path;
831 829
 		foreach (explode(':', $path) as $dir) {
832
-			if (strlen($dir) AND substr($dir,-1) != '/')
830
+			if (strlen($dir) AND substr($dir, -1) != '/')
833 831
 				$dir .= "/";
834 832
 			$path_base[] = $dir;
835 833
 		}
@@ -837,32 +835,32 @@  discard block
 block discarded – undo
837 835
 		// Et le(s) dossier(s) des squelettes nommes
838 836
 		if (strlen($GLOBALS['dossier_squelettes']))
839 837
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d)
840
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
838
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
841 839
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
842 840
 	}
843
-	if ($dir_path===NULL) return $path_full;
841
+	if ($dir_path === NULL) return $path_full;
844 842
 
845
-	if (strlen($dir_path)){
843
+	if (strlen($dir_path)) {
846 844
 		$tete = "";
847
-		if (reset($path_base)==_DIR_RACINE.'squelettes/')
845
+		if (reset($path_base) == _DIR_RACINE.'squelettes/')
848 846
 			$tete = array_shift($path_base);
849
-		$dirs = array_reverse(explode(':',$dir_path));
850
-		foreach($dirs as $dir_path){
847
+		$dirs = array_reverse(explode(':', $dir_path));
848
+		foreach ($dirs as $dir_path) {
851 849
 				#if ($dir_path{0}!='/')
852 850
 				#	$dir_path = $dir_path;
853
-				if (substr($dir_path,-1) != '/')
851
+				if (substr($dir_path, -1) != '/')
854 852
 					$dir_path .= "/";
855
-				if (!in_array($dir_path,$path_base))
856
-					array_unshift($path_base,$dir_path);
853
+				if (!in_array($dir_path, $path_base))
854
+					array_unshift($path_base, $dir_path);
857 855
 		}
858 856
 		if (strlen($tete))
859
-			array_unshift($path_base,$tete);
857
+			array_unshift($path_base, $tete);
860 858
 	}
861 859
 	$path_full = $path_base;
862 860
 	// Et le(s) dossier(s) des squelettes nommes
863 861
 	if (strlen($GLOBALS['dossier_squelettes']))
864 862
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d)
865
-			array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
863
+			array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
866 864
 
867 865
 	$GLOBALS['path_sig'] = md5(serialize($path_full));
868 866
 	return $path_full;
@@ -883,9 +881,9 @@  discard block
 block discarded – undo
883 881
 }
884 882
 
885 883
 
886
-function lister_themes_prives(){
884
+function lister_themes_prives() {
887 885
 	static $themes = null;
888
-	if (is_null($themes)){
886
+	if (is_null($themes)) {
889 887
 		// si pas encore definie
890 888
 		if (!defined('_SPIP_THEME_PRIVE'))
891 889
 			define('_SPIP_THEME_PRIVE', 'spip');
@@ -902,20 +900,20 @@  discard block
 block discarded – undo
902 900
 			((isset($prefs['theme']) AND $theme = $prefs['theme'])
903 901
 			OR (isset($GLOBALS['theme_prive_defaut']) AND $theme = $GLOBALS['theme_prive_defaut']))
904 902
 			AND $theme != _SPIP_THEME_PRIVE)
905
-			array_unshift($themes,$theme); // placer le theme choisi en tete
903
+			array_unshift($themes, $theme); // placer le theme choisi en tete
906 904
 	}
907 905
 	return $themes;
908 906
 }
909 907
 
910
-function find_in_theme($file, $subdir='', $include=false){
911
-	static $themefiles=array();
908
+function find_in_theme($file, $subdir = '', $include = false) {
909
+	static $themefiles = array();
912 910
 	if (isset($themefiles["$subdir$file"])) return $themefiles["$subdir$file"];
913 911
 	$themes = lister_themes_prives();
914
-	foreach($themes as $theme){
915
-		if ($f = find_in_path($file,"prive/themes/$theme/$subdir",$include))
912
+	foreach ($themes as $theme) {
913
+		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include))
916 914
 			return $themefiles["$subdir$file"] = $f;
917 915
 	}
918
-	spip_log("$file introuvable dans le theme prive ".reset($themes),'theme');
916
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
919 917
 	return $themefiles["$subdir$file"] = "";
920 918
 }
921 919
 
@@ -925,23 +923,23 @@  discard block
 block discarded – undo
925 923
 // peut se trouver dans un dossier plugin, donc on passe par un find_in_path si elle n'est pas
926 924
 // dans _DIR_IMG_PACK
927 925
 // http://doc.spip.org/@chemin_image
928
-function chemin_image($icone){
926
+function chemin_image($icone) {
929 927
 	static $icone_renommer;
930 928
 	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
931
-	if (strpos($icone,"/")!==false AND file_exists($icone)) return $icone;
929
+	if (strpos($icone, "/") !== false AND file_exists($icone)) return $icone;
932 930
 	
933 931
 	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
934
-	if (preg_match(',[.](png|gif|jpg)$,',$icone) AND $f = find_in_theme("images/$icone"))
932
+	if (preg_match(',[.](png|gif|jpg)$,', $icone) AND $f = find_in_theme("images/$icone"))
935 933
 		return $f;
936 934
 	// sinon passer par le module de renommage
937 935
 	if (is_null($icone_renommer))
938
-		$icone_renommer = charger_fonction('icone_renommer','inc',true);
939
-	if ($icone_renommer){
940
-		list($icone,$fonction) = $icone_renommer($icone,"");
936
+		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
937
+	if ($icone_renommer) {
938
+		list($icone, $fonction) = $icone_renommer($icone, "");
941 939
 		if (file_exists($icone))
942 940
 			return $icone;
943 941
 	}
944
-	return find_in_path ($icone, _NOM_IMG_PACK);
942
+	return find_in_path($icone, _NOM_IMG_PACK);
945 943
 }
946 944
 
947 945
 //
@@ -952,13 +950,13 @@  discard block
 block discarded – undo
952 950
 $GLOBALS['path_files'] = null;
953 951
 
954 952
 // http://doc.spip.org/@find_in_path
955
-function find_in_path ($file, $dirname='', $include=false) {
956
-	static $dirs=array();
953
+function find_in_path($file, $dirname = '', $include = false) {
954
+	static $dirs = array();
957 955
 	static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743
958 956
 	static $c = '';
959 957
 
960 958
 	// on calcule le chemin si le dossier skel a change
961
-	if ($c != $GLOBALS['dossier_squelettes']){
959
+	if ($c != $GLOBALS['dossier_squelettes']) {
962 960
 		// assurer le non plantage lors de la montee de version :
963 961
 		$c = $GLOBALS['dossier_squelettes'];
964 962
 		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
@@ -968,40 +966,40 @@  discard block
 block discarded – undo
968 966
 		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])
969 967
 			return false;
970 968
 		if ($include AND !isset($inc[$dirname][$file])) {
971
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
972
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
969
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
970
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
973 971
 		}
974 972
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
975 973
 	}
976 974
 
977
-	$a = strrpos($file,'/');
975
+	$a = strrpos($file, '/');
978 976
 	if ($a !== false) {
979 977
 		$dirname .= substr($file, 0, ++$a);
980 978
 		$file = substr($file, $a);
981 979
 	}
982 980
 
983
-	foreach(creer_chemin() as $dir) {
984
-		if (!isset($dirs[$a = $dir . $dirname]))
985
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a) ;
981
+	foreach (creer_chemin() as $dir) {
982
+		if (!isset($dirs[$a = $dir.$dirname]))
983
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
986 984
 		if ($dirs[$a]) {
987
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
985
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
988 986
 				if ($include AND !isset($inc[$dirname][$file])) {
989
-					include_once _ROOT_CWD . $a;
990
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
987
+					include_once _ROOT_CWD.$a;
988
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
991 989
 				}
992
-				if (!defined('_SAUVER_CHEMIN')){
990
+				if (!defined('_SAUVER_CHEMIN')) {
993 991
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
994 992
 					if (is_null($GLOBALS['path_files'])) return $a;
995 993
 					define('_SAUVER_CHEMIN', true);
996 994
 				}
997
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
995
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
998 996
 			}
999 997
 		}
1000 998
 	}
1001 999
 
1002
-	if ($include){
1000
+	if ($include) {
1003 1001
 		spip_log("include_spip $dirname$file non trouve");
1004
-		if ($include==='required'){
1002
+		if ($include === 'required') {
1005 1003
 			echo '<pre>',
1006 1004
 			"<strong>Erreur Fatale</strong><br />";
1007 1005
 			if (function_exists('debug_print_backtrace'))
@@ -1011,21 +1009,21 @@  discard block
 block discarded – undo
1011 1009
 		}
1012 1010
 	}
1013 1011
 
1014
-	if (!defined('_SAUVER_CHEMIN')){
1012
+	if (!defined('_SAUVER_CHEMIN')) {
1015 1013
 		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1016 1014
 		if (is_null($GLOBALS['path_files'])) return false;
1017 1015
 		define('_SAUVER_CHEMIN', true);
1018 1016
 	}
1019
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1017
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1020 1018
 }
1021 1019
 
1022
-function clear_path_cache(){
1020
+function clear_path_cache() {
1023 1021
 	$GLOBALS['path_files'] = array();
1024 1022
 	spip_unlink(_CACHE_CHEMIN);
1025 1023
 }
1026
-function load_path_cache(){
1024
+function load_path_cache() {
1027 1025
 	// charger le path des plugins
1028
-	if (@is_readable(_CACHE_PLUGINS_PATH)){
1026
+	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1029 1027
 		include_once(_CACHE_PLUGINS_PATH);
1030 1028
 	}
1031 1029
 	$GLOBALS['path_files'] = array();
@@ -1039,23 +1037,23 @@  discard block
 block discarded – undo
1039 1037
 		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1040 1038
 		// et en ignorant ce cache en cas de recalcul explicite
1041 1039
 		!_request('var_mode')
1042
-		){
1040
+		) {
1043 1041
 		// on essaye de lire directement sans verrou pour aller plus vite
1044
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)){
1042
+		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1045 1043
 			// mais si semble corrompu on relit avec un verrou
1046
-			if (!$GLOBALS['path_files']=unserialize($contenu)){
1047
-				lire_fichier(_CACHE_CHEMIN,$contenu);
1048
-				if (!$GLOBALS['path_files']=unserialize($contenu))
1044
+			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1045
+				lire_fichier(_CACHE_CHEMIN, $contenu);
1046
+				if (!$GLOBALS['path_files'] = unserialize($contenu))
1049 1047
 					$GLOBALS['path_files'] = array();
1050 1048
 			}
1051 1049
 		}
1052 1050
 	}
1053 1051
 }
1054 1052
 
1055
-function save_path_cache(){
1053
+function save_path_cache() {
1056 1054
 	if (defined('_SAUVER_CHEMIN')
1057 1055
 		AND _SAUVER_CHEMIN)
1058
-		ecrire_fichier(_CACHE_CHEMIN,serialize($GLOBALS['path_files']));
1056
+		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1059 1057
 }
1060 1058
 
1061 1059
 
@@ -1070,16 +1068,16 @@  discard block
 block discarded – undo
1070 1068
  * @return array
1071 1069
  */
1072 1070
 // http://doc.spip.org/@find_all_in_path
1073
-function find_all_in_path($dir,$pattern, $recurs=false){
1074
-	$liste_fichiers=array();
1071
+function find_all_in_path($dir, $pattern, $recurs = false) {
1072
+	$liste_fichiers = array();
1075 1073
 	$maxfiles = 10000;
1076 1074
 
1077 1075
 	// Parcourir le chemin
1078 1076
 	foreach (creer_chemin() as $d) {
1079 1077
 		$f = $d.$dir;
1080
-		if (@is_dir($f)){
1081
-			$liste = preg_files($f,$pattern,$maxfiles-count($liste_fichiers),$recurs===true?array():$recurs);
1082
-			foreach($liste as $chemin){
1078
+		if (@is_dir($f)) {
1079
+			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1080
+			foreach ($liste as $chemin) {
1083 1081
 				$nom = basename($chemin);
1084 1082
 				// ne prendre que les fichiers pas deja trouves
1085 1083
 				// car find_in_path prend le premier qu'il trouve,
@@ -1126,7 +1124,7 @@  discard block
 block discarded – undo
1126 1124
  *   array : derogatoire, la fonction d'url retourne (objet,id_objet) utilises par nettoyer_raccourcis_typo() pour generer un lien titre
1127 1125
  *           (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip)
1128 1126
  */
1129
-function generer_url_entite($id='', $entite='', $args='', $ancre='', $public=NULL, $type=NULL)
1127
+function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = NULL, $type = NULL)
1130 1128
 {
1131 1129
 	if ($public === NULL) $public = !test_espace_prive();
1132 1130
 	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
@@ -1135,12 +1133,12 @@  discard block
 block discarded – undo
1135 1133
 		if (!$entite) return '';
1136 1134
 		if (!function_exists('generer_url_ecrire_objet'))
1137 1135
 			include_spip('inc/urls');
1138
-		$res = generer_url_ecrire_objet($entite,$id, $args, $ancre, false);
1136
+		$res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1139 1137
 	} else {
1140 1138
 		if ($type === NULL) {
1141 1139
 			$type = ($GLOBALS['type_urls'] === 'page'
1142 1140
 				AND $GLOBALS['meta']['type_urls'])
1143
-			?  $GLOBALS['meta']['type_urls']
1141
+			? $GLOBALS['meta']['type_urls']
1144 1142
 			:  $GLOBALS['type_urls']; // pour SPIP <2
1145 1143
 		}
1146 1144
 
@@ -1163,7 +1161,7 @@  discard block
 block discarded – undo
1163 1161
 	}
1164 1162
 	if ($res) return $res;
1165 1163
 	// Sinon c'est un raccourci ou compat SPIP < 2
1166
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1164
+	if (!function_exists($f = 'generer_url_'.$entite)) {
1167 1165
 		if (!function_exists($f .= '_dist')) $f = '';
1168 1166
 	}
1169 1167
 	if ($f) {
@@ -1179,23 +1177,23 @@  discard block
 block discarded – undo
1179 1177
 	return '';
1180 1178
 }
1181 1179
 
1182
-function generer_url_ecrire_entite_edit($id, $entite, $args='', $ancre=''){
1183
-	$exec = objet_info($entite,'url_edit');
1184
-	$url = generer_url_ecrire($exec,$args);
1180
+function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1181
+	$exec = objet_info($entite, 'url_edit');
1182
+	$url = generer_url_ecrire($exec, $args);
1185 1183
 	if (intval($id))
1186
-		$url = parametre_url($url,id_table_objet($entite),$id);
1184
+		$url = parametre_url($url, id_table_objet($entite), $id);
1187 1185
 	else
1188
-		$url = parametre_url($url,'new','oui');
1186
+		$url = parametre_url($url, 'new', 'oui');
1189 1187
 	if ($ancre)
1190
-		$url = ancre_url($url,$ancre);
1188
+		$url = ancre_url($url, $ancre);
1191 1189
 	return $url;
1192 1190
 }
1193 1191
 
1194 1192
 // http://doc.spip.org/@urls_connect_dist
1195
-function urls_connect_dist($i, &$entite, $args='', $ancre='', $public=null) {
1193
+function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1196 1194
 	include_spip('base/connect_sql');
1197
-	$id_type = id_table_objet($entite,$public);
1198
-	return _DIR_RACINE . get_spip_script('./')
1195
+	$id_type = id_table_objet($entite, $public);
1196
+	return _DIR_RACINE.get_spip_script('./')
1199 1197
 	  . "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1200 1198
 	  . (!$args ? '' : "&$args")
1201 1199
 	  . (!$ancre ? '' : "#$ancre");
@@ -1204,9 +1202,9 @@  discard block
 block discarded – undo
1204 1202
 
1205 1203
 // Transformer les caracteres utf8 d'une URL (farsi par ex) selon la RFC 1738
1206 1204
 function urlencode_1738($url) {
1207
-	if (preg_match(',[^\x00-\x7E],sS', $url)){
1205
+	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1208 1206
 		$uri = '';
1209
-		for ($i=0; $i < strlen($url); $i++) {
1207
+		for ($i = 0; $i < strlen($url); $i++) {
1210 1208
 			if (ord($a = $url[$i]) > 127)
1211 1209
 				$a = rawurlencode($a);
1212 1210
 			$uri .= $a;
@@ -1217,7 +1215,7 @@  discard block
 block discarded – undo
1217 1215
 }
1218 1216
 
1219 1217
 // http://doc.spip.org/@generer_url_entite_absolue
1220
-function generer_url_entite_absolue($id='', $entite='', $args='', $ancre='', $connect=NULL)
1218
+function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = NULL)
1221 1219
 {
1222 1220
 	if (!$connect) $connect = true;
1223 1221
 	$h = generer_url_entite($id, $entite, $args, $ancre, $connect);
@@ -1256,11 +1254,11 @@  discard block
 block discarded – undo
1256 1254
  *    si array : reinitialise le tableau static complet avec la valeur fournie
1257 1255
  * @return string|array
1258 1256
  */
1259
-function url_de_base($profondeur=null) {
1257
+function url_de_base($profondeur = null) {
1260 1258
 
1261 1259
 	static $url = array();
1262 1260
 	if (is_array($profondeur)) return $url = $profondeur;
1263
-	if ($profondeur===false) return $url;
1261
+	if ($profondeur === false) return $url;
1264 1262
 
1265 1263
 	if (is_null($profondeur)) $profondeur = $GLOBALS['profondeur_url'];
1266 1264
 
@@ -1269,7 +1267,7 @@  discard block
 block discarded – undo
1269 1267
 
1270 1268
 	$http = (
1271 1269
 		(isset($_SERVER["SCRIPT_URI"]) AND
1272
-			substr($_SERVER["SCRIPT_URI"],0,5) == 'https')
1270
+			substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https')
1273 1271
 		OR (isset($_SERVER['HTTPS']) AND
1274 1272
 		    test_valeur_serveur($_SERVER['HTTPS']))
1275 1273
 	) ? 'https' : 'http';
@@ -1284,12 +1282,12 @@  discard block
 block discarded – undo
1284 1282
 		}
1285 1283
 	}
1286 1284
 	if (isset($_SERVER['SERVER_PORT'])
1287
-		AND $port=$_SERVER['SERVER_PORT']
1288
-		AND strpos($host,":")==false){
1289
-		if ($http=="http" AND $port!=80) $host.=":$port";
1290
-		if ($http=="https" AND $port!=443) $host.=":$port";
1285
+		AND $port = $_SERVER['SERVER_PORT']
1286
+		AND strpos($host, ":") == false) {
1287
+		if ($http == "http" AND $port != 80) $host .= ":$port";
1288
+		if ($http == "https" AND $port != 443) $host .= ":$port";
1291 1289
 	}
1292
-	if (!$GLOBALS['REQUEST_URI']){
1290
+	if (!$GLOBALS['REQUEST_URI']) {
1293 1291
 		if (isset($_SERVER['REQUEST_URI'])) {
1294 1292
 			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
1295 1293
 		} else {
@@ -1300,7 +1298,7 @@  discard block
 block discarded – undo
1300 1298
 		}
1301 1299
 	}
1302 1300
 
1303
-	$url[$profondeur] = url_de_($http,$host,$GLOBALS['REQUEST_URI'],$profondeur);
1301
+	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
1304 1302
 
1305 1303
 	return $url[$profondeur];
1306 1304
 }
@@ -1312,25 +1310,25 @@  discard block
 block discarded – undo
1312 1310
  * @param int $prof
1313 1311
  * @return string
1314 1312
  */
1315
-function url_de_($http,$host,$request,$prof=0){
1316
-	$prof = max($prof,0);
1313
+function url_de_($http, $host, $request, $prof = 0) {
1314
+	$prof = max($prof, 0);
1317 1315
 
1318
-	$myself = ltrim($request,'/');
1316
+	$myself = ltrim($request, '/');
1319 1317
 	# supprimer la chaine de GET
1320 1318
 	list($myself) = explode('?', $myself);
1321 1319
 	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
1322 1320
 	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
1323
-	if (strpos($myself,'://') !== false) {
1324
-		$myself = explode('://',$myself);
1321
+	if (strpos($myself, '://') !== false) {
1322
+		$myself = explode('://', $myself);
1325 1323
 		array_shift($myself);
1326
-		$myself = implode('://',$myself);
1327
-		$myself = explode('/',$myself);
1324
+		$myself = implode('://', $myself);
1325
+		$myself = explode('/', $myself);
1328 1326
 		array_shift($myself);
1329
-		$myself = implode('/',$myself);
1327
+		$myself = implode('/', $myself);
1330 1328
 	}
1331
-	$url = join('/', array_slice(explode('/', $myself), 0, -1-$prof)).'/';
1329
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
1332 1330
 
1333
-	$url = $http.'://'.rtrim($host,'/').'/'.ltrim($url,'/');
1331
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
1334 1332
 	return $url;
1335 1333
 }
1336 1334
 
@@ -1344,24 +1342,24 @@  discard block
 block discarded – undo
1344 1342
 // http://httpd.apache.org/docs/2.0/mod/mod_dir.html
1345 1343
 
1346 1344
 // http://doc.spip.org/@generer_url_ecrire
1347
-function generer_url_ecrire($script='', $args="", $no_entities=false, $rel=false) {
1345
+function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) {
1348 1346
 	if (!$rel)
1349
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
1347
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
1350 1348
 	else if (!is_string($rel))
1351 1349
 		$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
1352
-			('./'  . _SPIP_ECRIRE_SCRIPT);
1350
+			('./'._SPIP_ECRIRE_SCRIPT);
1353 1351
 
1354 1352
 	@list($script, $ancre) = explode('#', $script);
1355
-	if ($script AND ($script<>'accueil' OR $rel))
1356
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
1353
+	if ($script AND ($script <> 'accueil' OR $rel))
1354
+		$args = "?exec=$script".(!$args ? '' : "&$args");
1357 1355
 	elseif ($args)
1358
-		$args ="?$args";
1356
+		$args = "?$args";
1359 1357
 	if ($ancre) $args .= "#$ancre";
1360
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
1358
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
1361 1359
 }
1362 1360
 
1363 1361
 // http://doc.spip.org/@generer_url_retour
1364
-function generer_url_retour($script, $args="")
1362
+function generer_url_retour($script, $args = "")
1365 1363
 {
1366 1364
 	return rawurlencode(generer_url_ecrire($script, $args, true, true));
1367 1365
 }
@@ -1373,7 +1371,7 @@  discard block
 block discarded – undo
1373 1371
 // Detecter le fichier de base, a la racine, comme etant spip.php ou ''
1374 1372
 // dans le cas de '', un $default = './' peut servir (comme dans urls/page.php)
1375 1373
 // http://doc.spip.org/@get_spip_script
1376
-function get_spip_script($default='') {
1374
+function get_spip_script($default = '') {
1377 1375
 	# cas define('_SPIP_SCRIPT', '');
1378 1376
 	if (_SPIP_SCRIPT)
1379 1377
 		return _SPIP_SCRIPT;
@@ -1382,7 +1380,7 @@  discard block
 block discarded – undo
1382 1380
 }
1383 1381
 
1384 1382
 // http://doc.spip.org/@generer_url_public
1385
-function generer_url_public($script='', $args="", $no_entities=false, $rel=true, $action='') {
1383
+function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') {
1386 1384
 	// si le script est une action (spip_pass, spip_inscription),
1387 1385
 	// standardiser vers la nouvelle API
1388 1386
 
@@ -1393,23 +1391,23 @@  discard block
 block discarded – undo
1393 1391
 	if ($args) {
1394 1392
 		if (is_array($args)) {
1395 1393
 			$r = '';
1396
-			foreach($args as $k => $v) $r .= '&' . $k . '=' . $v;
1397
-			$args = substr($r,1);
1394
+			foreach ($args as $k => $v) $r .= '&'.$k.'='.$v;
1395
+			$args = substr($r, 1);
1398 1396
 		}
1399 1397
 		$action .=
1400
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
1398
+			(strpos($action, '?') !== false ? '&' : '?').$args;
1401 1399
 	}
1402 1400
 	if (!$no_entities)
1403 1401
 		$action = quote_amp($action);
1404 1402
 
1405 1403
 	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
1406
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(),'/') . preg_replace(",^/[.]/,","/","/$action"));
1404
+	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action"));
1407 1405
 }
1408 1406
 
1409 1407
 // http://doc.spip.org/@generer_url_prive
1410
-function generer_url_prive($script, $args="", $no_entities=false) {
1408
+function generer_url_prive($script, $args = "", $no_entities = false) {
1411 1409
 
1412
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS .  'prive.php');
1410
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
1413 1411
 }
1414 1412
 
1415 1413
 // Pour les formulaires en methode POST,
@@ -1418,7 +1416,7 @@  discard block
 block discarded – undo
1418 1416
 // 2) ca suit http://en.wikipedia.org/wiki/Representational_State_Transfer
1419 1417
 
1420 1418
 // http://doc.spip.org/@generer_form_ecrire
1421
-function generer_form_ecrire($script, $corps, $atts='', $submit='') {
1419
+function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
1422 1420
 	global $spip_lang_right;
1423 1421
 
1424 1422
 	$script1 = explode('&', $script);
@@ -1431,8 +1429,7 @@  discard block
 block discarded – undo
1431 1429
 	.  "><div>\n"
1432 1430
 	. "<input type='hidden' name='exec' value='$script1' />"
1433 1431
 	. $corps
1434
-	. (!$submit ? '' :
1435
-	     ("<div style='text-align: $spip_lang_right'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>"))
1432
+	. (!$submit ? '' : ("<div style='text-align: $spip_lang_right'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>"))
1436 1433
 	. "</div></form>\n";
1437 1434
 }
1438 1435
 
@@ -1450,7 +1447,7 @@  discard block
 block discarded – undo
1450 1447
  * @param bool $public
1451 1448
  * @return string
1452 1449
  */
1453
-function generer_form_action($script, $corps, $atts='', $public=false) {
1450
+function generer_form_action($script, $corps, $atts = '', $public = false) {
1454 1451
 	// si l'on est dans l'espace prive, on garde dans l'url
1455 1452
 	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
1456 1453
 	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
@@ -1458,29 +1455,29 @@  discard block
 block discarded – undo
1458 1455
 	? generer_url_ecrire(_request('exec'))
1459 1456
 	: generer_url_public();
1460 1457
 
1461
-	return "\n<form action='" .
1462
-	  $h .
1463
-	  "'" .
1464
-	  $atts .
1465
-	  ">\n" .
1466
-	  "<div>" .
1467
-  	  "\n<input type='hidden' name='action' value='$script' />" .
1468
-	  $corps .
1458
+	return "\n<form action='".
1459
+	  $h.
1460
+	  "'".
1461
+	  $atts.
1462
+	  ">\n".
1463
+	  "<div>".
1464
+  	  "\n<input type='hidden' name='action' value='$script' />".
1465
+	  $corps.
1469 1466
 	  "</div></form>";
1470 1467
 }
1471 1468
 
1472 1469
 // http://doc.spip.org/@generer_url_action
1473
-function generer_url_action($script, $args="", $no_entities=false , $public = false) {
1470
+function generer_url_action($script, $args = "", $no_entities = false, $public = false) {
1474 1471
 	// si l'on est dans l'espace prive, on garde dans l'url
1475 1472
 	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
1476 1473
 	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
1477
-	$url = (_DIR_RACINE  AND !$public)
1474
+	$url = (_DIR_RACINE AND !$public)
1478 1475
 	  ? generer_url_ecrire(_request('exec'))
1479
-	  :  generer_url_public('','',false,false);
1480
-	$url = parametre_url($url,'action',$script);
1476
+	  :  generer_url_public('', '', false, false);
1477
+	$url = parametre_url($url, 'action', $script);
1481 1478
 	if ($args) $url .= quote_amp('&'.$args);
1482 1479
 
1483
-	if ($no_entities) $url = str_replace('&amp;','&',$url);
1480
+	if ($no_entities) $url = str_replace('&amp;', '&', $url);
1484 1481
 	return $url;
1485 1482
 }
1486 1483
 
@@ -1493,8 +1490,8 @@  discard block
 block discarded – undo
1493 1490
  * @param string $ti
1494 1491
  * @param string $ta
1495 1492
  */
1496
-function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) {
1497
-	spip_initialisation_core($pi,$pa,$ti,$ta);
1493
+function spip_initialisation($pi = NULL, $pa = NULL, $ti = NULL, $ta = NULL) {
1494
+	spip_initialisation_core($pi, $pa, $ti, $ta);
1498 1495
 	spip_initialisation_suite();
1499 1496
 }
1500 1497
 
@@ -1512,32 +1509,32 @@  discard block
 block discarded – undo
1512 1509
  * @param string $ti
1513 1510
  * @param string $ta
1514 1511
  */
1515
-function spip_initialisation_core($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) {
1512
+function spip_initialisation_core($pi = NULL, $pa = NULL, $ti = NULL, $ta = NULL) {
1516 1513
 	static $too_late = 0;
1517 1514
 	if ($too_late++) return;
1518 1515
 	
1519 1516
 	// Declaration des repertoires
1520 1517
 
1521 1518
 	// le nom du repertoire plugins/ activables/desactivables
1522
-	if (!defined('_DIR_PLUGINS')) define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
1519
+	if (!defined('_DIR_PLUGINS')) define('_DIR_PLUGINS', _DIR_RACINE."plugins/");
1523 1520
 
1524 1521
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
1525
-	if (!defined('_DIR_PLUGINS_DIST')) define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
1522
+	if (!defined('_DIR_PLUGINS_DIST')) define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/");
1526 1523
 
1527 1524
 	// le nom du repertoire des librairies
1528
-	if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE . "lib/");
1525
+	if (!defined('_DIR_LIB')) define('_DIR_LIB', _DIR_RACINE."lib/");
1529 1526
 	
1530 1527
 	if (!defined('_DIR_IMG')) define('_DIR_IMG', $pa);
1531 1528
 	if (!defined('_DIR_LOGOS')) define('_DIR_LOGOS', $pa);
1532
-	if (!defined('_DIR_IMG_ICONES')) define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
1533
-
1534
-	if (!defined('_DIR_DUMP')) define('_DIR_DUMP', $ti . "dump/");
1535
-	if (!defined('_DIR_SESSIONS')) define('_DIR_SESSIONS', $ti . "sessions/");
1536
-	if (!defined('_DIR_TRANSFERT')) define('_DIR_TRANSFERT', $ti . "upload/");
1537
-	if (!defined('_DIR_CACHE')) define('_DIR_CACHE', $ti . "cache/");
1538
-	if (!defined('_DIR_CACHE_XML')) define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
1539
-	if (!defined('_DIR_SKELS')) define('_DIR_SKELS',  _DIR_CACHE . "skel/");
1540
-	if (!defined('_DIR_AIDE')) define('_DIR_AIDE',  _DIR_CACHE . "aide/");
1529
+	if (!defined('_DIR_IMG_ICONES')) define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/");
1530
+
1531
+	if (!defined('_DIR_DUMP')) define('_DIR_DUMP', $ti."dump/");
1532
+	if (!defined('_DIR_SESSIONS')) define('_DIR_SESSIONS', $ti."sessions/");
1533
+	if (!defined('_DIR_TRANSFERT')) define('_DIR_TRANSFERT', $ti."upload/");
1534
+	if (!defined('_DIR_CACHE')) define('_DIR_CACHE', $ti."cache/");
1535
+	if (!defined('_DIR_CACHE_XML')) define('_DIR_CACHE_XML', _DIR_CACHE."xml/");
1536
+	if (!defined('_DIR_SKELS')) define('_DIR_SKELS', _DIR_CACHE."skel/");
1537
+	if (!defined('_DIR_AIDE')) define('_DIR_AIDE', _DIR_CACHE."aide/");
1541 1538
 	if (!defined('_DIR_TMP')) define('_DIR_TMP', $ti);
1542 1539
 
1543 1540
 	if (!defined('_DIR_VAR')) define('_DIR_VAR', $ta);
@@ -1549,19 +1546,19 @@  discard block
 block discarded – undo
1549 1546
 	if (!isset($GLOBALS['test_dirs']))
1550 1547
 	  // Pas $pi car il est bon de le mettre hors ecriture apres intstall
1551 1548
 	  // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
1552
-		$GLOBALS['test_dirs'] =  array($pa, $ti, $ta);
1549
+		$GLOBALS['test_dirs'] = array($pa, $ti, $ta);
1553 1550
 
1554 1551
 	// Declaration des fichiers
1555 1552
 
1556
-	if (!defined('_CACHE_PLUGINS_PATH')) define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
1557
-	if (!defined('_CACHE_PLUGINS_OPT')) define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
1558
-	if (!defined('_CACHE_PLUGINS_FCT')) define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
1559
-	if (!defined('_CACHE_PIPELINES')) define('_CACHE_PIPELINES',  _DIR_CACHE."charger_pipelines.php");
1560
-	if (!defined('_CACHE_CHEMIN')) define('_CACHE_CHEMIN',  _DIR_CACHE."chemin.txt");
1553
+	if (!defined('_CACHE_PLUGINS_PATH')) define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php");
1554
+	if (!defined('_CACHE_PLUGINS_OPT')) define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php");
1555
+	if (!defined('_CACHE_PLUGINS_FCT')) define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php");
1556
+	if (!defined('_CACHE_PIPELINES')) define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php");
1557
+	if (!defined('_CACHE_CHEMIN')) define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt");
1561 1558
 
1562 1559
 	# attention .php obligatoire pour ecrire_fichier_securise
1563
-	if (!defined('_FILE_META')) define('_FILE_META', $ti . 'meta_cache.php');
1564
-	if (!defined('_DIR_LOG')) define('_DIR_LOG', _DIR_TMP . 'log/');
1560
+	if (!defined('_FILE_META')) define('_FILE_META', $ti.'meta_cache.php');
1561
+	if (!defined('_DIR_LOG')) define('_DIR_LOG', _DIR_TMP.'log/');
1565 1562
 	if (!defined('_FILE_LOG')) define('_FILE_LOG', 'spip');
1566 1563
 	if (!defined('_FILE_LOG_SUFFIX')) define('_FILE_LOG_SUFFIX', '.log');
1567 1564
 
@@ -1569,21 +1566,21 @@  discard block
 block discarded – undo
1569 1566
 	// tient compte des anciennes versions (inc_connect...)
1570 1567
 	if (!defined('_FILE_CONNECT_INS')) define('_FILE_CONNECT_INS', 'connect');
1571 1568
 	if (!defined('_FILE_CONNECT')) define('_FILE_CONNECT',
1572
-		(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
1573
-	:	(@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
1569
+		(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
1570
+	:	(@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
1574 1571
 	:	false)));
1575 1572
 
1576 1573
 	// Le fichier de reglages des droits
1577 1574
 	if (!defined('_FILE_CHMOD_INS')) define('_FILE_CHMOD_INS', 'chmod');
1578 1575
 	if (!defined('_FILE_CHMOD')) define('_FILE_CHMOD',
1579
-		(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
1576
+		(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
1580 1577
 	:	false));
1581 1578
 
1582 1579
 	if (!defined('_FILE_LDAP')) define('_FILE_LDAP', 'ldap.php');
1583 1580
 
1584 1581
 	if (!defined('_FILE_TMP_SUFFIX')) define('_FILE_TMP_SUFFIX', '.tmp.php');
1585
-	if (!defined('_FILE_CONNECT_TMP')) define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
1586
-	if (!defined('_FILE_CHMOD_TMP')) define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
1582
+	if (!defined('_FILE_CONNECT_TMP')) define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
1583
+	if (!defined('_FILE_CHMOD_TMP')) define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
1587 1584
 
1588 1585
 	// Definition des droits d'acces en ecriture
1589 1586
 	if (!defined('_SPIP_CHMOD') AND _FILE_CHMOD)
@@ -1594,31 +1591,31 @@  discard block
 block discarded – undo
1594 1591
 
1595 1592
 	// Le charset par defaut lors de l'installation
1596 1593
 	if (!defined('_DEFAULT_CHARSET')) define('_DEFAULT_CHARSET', 'utf-8');
1597
-	if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
1598
-	if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
1599
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE,'',_DIR_PLUGINS_SUPPL));
1594
+	if (!defined('_ROOT_PLUGINS')) define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/");
1595
+	if (!defined('_ROOT_PLUGINS_DIST')) define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/");
1596
+	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
1600 1597
 
1601 1598
 	// La taille des Log
1602 1599
 	if (!defined('_MAX_LOG')) define('_MAX_LOG', 100);
1603 1600
 
1604 1601
 	// Sommes-nous dans l'empire du Mal ?
1605 1602
 	// (ou sous le signe du Pingouin, ascendant GNU ?)
1606
-	if (strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false){
1603
+	if (strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
1607 1604
 		if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', 'windows');
1608
-		if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php
1605
+		if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE', 1); // utiliser le flock php
1609 1606
 	}
1610 1607
 	else {
1611 1608
 		if (!defined('_OS_SERVEUR')) define('_OS_SERVEUR', '');
1612
-		if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',1); // utiliser le flock php
1609
+		if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE', 1); // utiliser le flock php
1613 1610
 		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
1614 1611
 	}
1615 1612
 
1616 1613
 	// Langue par defaut
1617
-	if (!defined('_LANGUE_PAR_DEFAUT')) define('_LANGUE_PAR_DEFAUT','fr');
1614
+	if (!defined('_LANGUE_PAR_DEFAUT')) define('_LANGUE_PAR_DEFAUT', 'fr');
1618 1615
 
1619 1616
 	// PHP_VERSION_ID dispo depuis PHP 5.2.7
1620 1617
 	if (!defined('PHP_VERSION_ID')) {
1621
-	   $version = explode('.',PHP_VERSION);
1618
+	   $version = explode('.', PHP_VERSION);
1622 1619
 	   define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
1623 1620
 	}
1624 1621
 
@@ -1627,7 +1624,7 @@  discard block
 block discarded – undo
1627 1624
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
1628 1625
 	// pour le rendre surchargeable, on va provoquer un reecriture
1629 1626
 	// systematique du noyau ou une baisse de perfs => a etudier)
1630
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
1627
+	include_once _ROOT_RESTREINT.'inc/flock.php';
1631 1628
 
1632 1629
 	// charger tout de suite le path et son cache
1633 1630
 	load_path_cache();
@@ -1647,7 +1644,7 @@  discard block
 block discarded – undo
1647 1644
 	spip_desinfecte($_REQUEST);
1648 1645
 
1649 1646
 	// Par ailleurs on ne veut pas de magic_quotes au cours de l'execution
1650
-	if (PHP_VERSION_ID<50300) {
1647
+	if (PHP_VERSION_ID < 50300) {
1651 1648
 		@set_magic_quotes_runtime(0);
1652 1649
 	}
1653 1650
 
@@ -1657,7 +1654,7 @@  discard block
 block discarded – undo
1657 1654
 	if (test_valeur_serveur(@ini_get('register_globals'))) {
1658 1655
 		// ne pas desinfecter les globales en profondeur car elle contient aussi les
1659 1656
 		// precedentes, qui seraient desinfectees 2 fois.
1660
-		spip_desinfecte($GLOBALS,false);
1657
+		spip_desinfecte($GLOBALS, false);
1661 1658
 		if (include_spip('inc/php3'))
1662 1659
 			spip_register_globals(true);
1663 1660
 
@@ -1701,8 +1698,8 @@  discard block
 block discarded – undo
1701 1698
 	$inc_meta();
1702 1699
 
1703 1700
 	// on a pas pu le faire plus tot
1704
-	if  ($avertir_register_globals)
1705
-		avertir_auteurs("register_globals",_L("Probl&egrave;me de s&eacute;curit&eacute; : register_globals=on; dans php.ini &agrave; corriger."));
1701
+	if ($avertir_register_globals)
1702
+		avertir_auteurs("register_globals", _L("Probl&egrave;me de s&eacute;curit&eacute; : register_globals=on; dans php.ini &agrave; corriger."));
1706 1703
 
1707 1704
 	// nombre de repertoires depuis la racine
1708 1705
 	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
@@ -1718,7 +1715,7 @@  discard block
 block discarded – undo
1718 1715
 			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
1719 1716
 			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
1720 1717
 			// s'en remettre a l'adresse du site. alea jacta est.
1721
-			OR $ti!==_NOM_TEMPORAIRES_INACCESSIBLES){
1718
+			OR $ti !== _NOM_TEMPORAIRES_INACCESSIBLES) {
1722 1719
 
1723 1720
 			if (isset($GLOBALS['meta']['adresse_site'])) {
1724 1721
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
@@ -1732,12 +1729,12 @@  discard block
 block discarded – undo
1732 1729
 		else {
1733 1730
 			$GLOBALS['profondeur_url'] = max(0,
1734 1731
 				substr_count($uri[0], '/')
1735
-				- substr_count($uri_ref,'/'));
1732
+				- substr_count($uri_ref, '/'));
1736 1733
 		}
1737 1734
 	}
1738 1735
 	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
1739 1736
 	if (_FILE_CONNECT) {
1740
-		if (verifier_visiteur()=='0minirezo'
1737
+		if (verifier_visiteur() == '0minirezo'
1741 1738
 			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
1742 1739
 		  AND !isset($_COOKIE['spip_admin']))
1743 1740
 			clear_path_cache();
@@ -1767,7 +1764,7 @@  discard block
 block discarded – undo
1767 1764
 	if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
1768 1765
 	if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
1769 1766
 	if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
1770
-	if (!defined('_PASS_LONGUEUR_MINI')) define('_PASS_LONGUEUR_MINI',6);
1767
+	if (!defined('_PASS_LONGUEUR_MINI')) define('_PASS_LONGUEUR_MINI', 6);
1771 1768
 
1772 1769
 
1773 1770
 	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
@@ -1777,7 +1774,7 @@  discard block
 block discarded – undo
1777 1774
 	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
1778 1775
         if (!defined('_IMG_IMAGICK_QUALITE')) define('_IMG_IMAGICK_QUALITE', 75); # surcharge pour imagick en PHP
1779 1776
 
1780
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) define('_COPIE_LOCALE_MAX_SIZE',16777216); // poids en octet
1777
+	if (!defined('_COPIE_LOCALE_MAX_SIZE')) define('_COPIE_LOCALE_MAX_SIZE', 16777216); // poids en octet
1781 1778
 
1782 1779
 	// qq chaines standard
1783 1780
 	if (!defined('_ACCESS_FILE_NAME')) define('_ACCESS_FILE_NAME', '.htaccess');
@@ -1809,7 +1806,7 @@  discard block
 block discarded – undo
1809 1806
 	// meme pb sur thttpd cf. http://forum.spip.org/fr_184153.html
1810 1807
 
1811 1808
 	if (!defined('_SPIP_ECRIRE_SCRIPT')) define('_SPIP_ECRIRE_SCRIPT', // true ? #decommenter ici et commenter la
1812
-	       preg_match(',IIS|thttpd,',$_SERVER['SERVER_SOFTWARE']) ?
1809
+	       preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE']) ?
1813 1810
 	       'index.php' : '');
1814 1811
 
1815 1812
 
@@ -1832,32 +1829,32 @@  discard block
 block discarded – undo
1832 1829
 	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
1833 1830
 	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
1834 1831
 	if (!defined('_IMG_GD_MAX_PIXELS')) define('_IMG_GD_MAX_PIXELS',
1835
-		(isset($GLOBALS['meta']['max_taille_vignettes'])&&$GLOBALS['meta']['max_taille_vignettes']<5500000)
1832
+		(isset($GLOBALS['meta']['max_taille_vignettes']) && $GLOBALS['meta']['max_taille_vignettes'] < 5500000)
1836 1833
 		 ? $GLOBALS['meta']['max_taille_vignettes']
1837 1834
 		 : 0);
1838 1835
 
1839
-	if (!defined('_MEMORY_LIMIT_MIN')) define('_MEMORY_LIMIT_MIN',10); // en Mo
1836
+	if (!defined('_MEMORY_LIMIT_MIN')) define('_MEMORY_LIMIT_MIN', 10); // en Mo
1840 1837
 	// si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
1841 1838
 	// on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
1842 1839
 	// il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
1843
-	if (test_espace_prive() AND _MEMORY_LIMIT_MIN>8){
1840
+	if (test_espace_prive() AND _MEMORY_LIMIT_MIN > 8) {
1844 1841
 		if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
1845
-			$unit = strtolower(substr($memory,strlen($memory/1),1));
1846
-			switch($unit) {
1842
+			$unit = strtolower(substr($memory, strlen($memory / 1), 1));
1843
+			switch ($unit) {
1847 1844
 				// Le modifieur 'G' est disponible depuis PHP 5.1.0
1848 1845
 				case 'g': $memory *= 1024;
1849 1846
 				case 'm': $memory *= 1024;
1850 1847
 				case 'k': $memory *= 1024;
1851 1848
 			}
1852
-			if ($memory<_MEMORY_LIMIT_MIN*1024*1024){
1853
-				ini_set('memory_limit',$m=_MEMORY_LIMIT_MIN.'M');
1854
-				if (trim(ini_get('memory_limit'))!=$m){
1855
-					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit
1849
+			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
1850
+				ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M');
1851
+				if (trim(ini_get('memory_limit')) != $m) {
1852
+					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); // evite une page blanche car on ne saura pas calculer la css dans ce hit
1856 1853
 				}
1857 1854
 			}
1858 1855
 		}
1859 1856
 		else
1860
-			if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE',true); // evite une page blanche car on ne saura pas calculer la css dans ce hit
1857
+			if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); // evite une page blanche car on ne saura pas calculer la css dans ce hit
1861 1858
 	}
1862 1859
 	// Protocoles a normaliser dans les chaines de langues
1863 1860
 	if (!defined('_PROTOCOLES_STD'))
@@ -1869,7 +1866,7 @@  discard block
 block discarded – undo
1869 1866
 // Reperer les variables d'URL qui conditionnent la perennite du cache, des urls
1870 1867
 // ou d'autres petit caches (trouver_table, css et js compactes ...)
1871 1868
 // http://doc.spip.org/@init_var_mode
1872
-function init_var_mode(){
1869
+function init_var_mode() {
1873 1870
 	static $done = false;
1874 1871
 	if (!$done) {
1875 1872
 
@@ -1877,56 +1874,56 @@  discard block
 block discarded – undo
1877 1874
 			// tout le monde peut calcul/recalcul
1878 1875
 			if ($_GET['var_mode'] == 'calcul'
1879 1876
 			OR $_GET['var_mode'] == 'recalcul') {
1880
-				if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']);
1877
+				if (!defined('_VAR_MODE')) define('_VAR_MODE', $_GET['var_mode']);
1881 1878
 			}
1882 1879
 			// preview, debug, blocs, urls et images necessitent une autorisation
1883
-			else if (in_array($_GET['var_mode'],array('preview','debug','inclure','urls','images','traduction'))) {
1880
+			else if (in_array($_GET['var_mode'], array('preview', 'debug', 'inclure', 'urls', 'images', 'traduction'))) {
1884 1881
 				include_spip('inc/autoriser');
1885 1882
 				if (autoriser(
1886 1883
 					($_GET['var_mode'] == 'preview')
1887 1884
 						? 'previsualiser'
1888 1885
 						: 'debug'
1889 1886
 				)) {
1890
-					switch($_GET['var_mode']){
1887
+					switch ($_GET['var_mode']) {
1891 1888
 						case 'traduction':
1892 1889
 							// forcer le calcul pour passer dans traduire
1893
-							if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul');
1890
+							if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul');
1894 1891
 							// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
1895
-							if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true);
1892
+							if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE', true);
1896 1893
 							break;
1897 1894
 						case 'preview':
1898 1895
 							// basculer sur les criteres de preview dans les boucles
1899
-							if (!defined('_VAR_PREVIEW')) define('_VAR_PREVIEW',true);
1896
+							if (!defined('_VAR_PREVIEW')) define('_VAR_PREVIEW', true);
1900 1897
 							// forcer le calcul
1901
-							if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul');
1898
+							if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul');
1902 1899
 							// et ne pas enregistrer de cache
1903
-							if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true);
1900
+							if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE', true);
1904 1901
 							break;
1905 1902
 						case 'inclure':
1906 1903
 							// forcer le compilo et ignorer les caches existants
1907
-							if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul');
1908
-							if (!defined('_VAR_INCLURE')) define('_VAR_INCLURE',true);
1904
+							if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul');
1905
+							if (!defined('_VAR_INCLURE')) define('_VAR_INCLURE', true);
1909 1906
 							// et ne pas enregistrer de cache
1910
-							if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true);
1907
+							if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE', true);
1911 1908
 							break;
1912 1909
 						case 'urls':
1913 1910
 							// forcer le compilo et ignorer les caches existants
1914
-							if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul');
1915
-							if (!defined('_VAR_URLS')) define('_VAR_URLS',true);
1911
+							if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul');
1912
+							if (!defined('_VAR_URLS')) define('_VAR_URLS', true);
1916 1913
 							break;
1917 1914
 						case 'images':
1918 1915
 							// forcer le compilo et ignorer les caches existants
1919
-							if (!defined('_VAR_MODE')) define('_VAR_MODE','calcul');
1916
+							if (!defined('_VAR_MODE')) define('_VAR_MODE', 'calcul');
1920 1917
 							// indiquer qu'on doit recalculer les images
1921
-							if (!defined('_VAR_IMAGES')) define('_VAR_IMAGES',true);
1918
+							if (!defined('_VAR_IMAGES')) define('_VAR_IMAGES', true);
1922 1919
 							break;
1923 1920
 						case 'debug':
1924
-							if (!defined('_VAR_MODE')) define('_VAR_MODE','debug');
1921
+							if (!defined('_VAR_MODE')) define('_VAR_MODE', 'debug');
1925 1922
 							// et ne pas enregistrer de cache
1926
-							if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE',true);
1923
+							if (!defined('_VAR_NOCACHE')) define('_VAR_NOCACHE', true);
1927 1924
 							break;
1928 1925
 						default :
1929
-							if (!defined('_VAR_MODE')) define('_VAR_MODE',$_GET['var_mode']);
1926
+							if (!defined('_VAR_MODE')) define('_VAR_MODE', $_GET['var_mode']);
1930 1927
 							break;
1931 1928
 					}
1932 1929
           if (isset($GLOBALS['visiteur_session']['nom']))
@@ -1946,7 +1943,7 @@  discard block
 block discarded – undo
1946 1943
 					// sinon tant pis
1947 1944
 				}
1948 1945
 			}
1949
-			if (!defined('_VAR_MODE')) define('_VAR_MODE',false);
1946
+			if (!defined('_VAR_MODE')) define('_VAR_MODE', false);
1950 1947
 		}
1951 1948
 		$done = true;
1952 1949
 	}
@@ -1956,7 +1953,7 @@  discard block
 block discarded – undo
1956 1953
 // supprimer aussi les eventuels caracteres nuls %00, qui peuvent tromper
1957 1954
 // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal')
1958 1955
 // http://doc.spip.org/@spip_desinfecte
1959
-function spip_desinfecte(&$t,$deep = true) {
1956
+function spip_desinfecte(&$t, $deep = true) {
1960 1957
 	static $magic_quotes;
1961 1958
 	if (!isset($magic_quotes))
1962 1959
 		$magic_quotes = @get_magic_quotes_gpc();
@@ -1968,8 +1965,8 @@  discard block
 block discarded – undo
1968 1965
 			$t[$key] = str_replace(chr(0), '-', $t[$key]);
1969 1966
 		}
1970 1967
 		// traiter aussi les "texte_plus" de article_edit
1971
-		else if ($deep AND is_array($t[$key]) AND $key!=='GLOBALS')
1972
-			spip_desinfecte($t[$key],$deep);
1968
+		else if ($deep AND is_array($t[$key]) AND $key !== 'GLOBALS')
1969
+			spip_desinfecte($t[$key], $deep);
1973 1970
 	}
1974 1971
 }
1975 1972
 
@@ -1982,10 +1979,10 @@  discard block
 block discarded – undo
1982 1979
 	// mais on risque de perturber des plugins en initialisant trop tot
1983 1980
 	// certaines constantes
1984 1981
 	@spip_initialisation_core(
1985
-		(_DIR_RACINE  . _NOM_PERMANENTS_INACCESSIBLES),
1986
-		(_DIR_RACINE  . _NOM_PERMANENTS_ACCESSIBLES),
1987
-		(_DIR_RACINE  . _NOM_TEMPORAIRES_INACCESSIBLES),
1988
-		(_DIR_RACINE  . _NOM_TEMPORAIRES_ACCESSIBLES)
1982
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
1983
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
1984
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
1985
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
1989 1986
 	);
1990 1987
 
1991 1988
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -1993,7 +1990,7 @@  discard block
 block discarded – undo
1993 1990
 	// Attention on separe bien session_nom et nom, pour eviter
1994 1991
 	// les melanges entre donnees SQL et variables plus aleatoires
1995 1992
 	$variables_session = array('session_nom', 'session_email');
1996
-	foreach($variables_session as $var) {
1993
+	foreach ($variables_session as $var) {
1997 1994
 		if (_request($var) !== null) {
1998 1995
 			$init = true;
1999 1996
 			break;
@@ -2004,7 +2001,7 @@  discard block
 block discarded – undo
2004 2001
 		$session = charger_fonction('session', 'inc');
2005 2002
 		$session();
2006 2003
 		include_spip('inc/texte');
2007
-		foreach($variables_session as $var)
2004
+		foreach ($variables_session as $var)
2008 2005
 			if (($a = _request($var)) !== null)
2009 2006
 				$GLOBALS['visiteur_session'][$var] = safehtml($a);
2010 2007
 		if (!isset($GLOBALS['visiteur_session']['id_auteur']))
@@ -2013,14 +2010,14 @@  discard block
 block discarded – undo
2013 2010
 		return 0;
2014 2011
 	}
2015 2012
 
2016
-	$h = (isset($_SERVER['PHP_AUTH_USER'])  AND !$GLOBALS['ignore_auth_http']);
2013
+	$h = (isset($_SERVER['PHP_AUTH_USER']) AND !$GLOBALS['ignore_auth_http']);
2017 2014
 	if ($h OR isset($_COOKIE['spip_session']) OR isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
2018 2015
 
2019 2016
 		$session = charger_fonction('session', 'inc');
2020 2017
 		if ($session()) {
2021 2018
 			return $GLOBALS['visiteur_session']['statut'];
2022 2019
 		}
2023
-		if ($h  AND isset($_SERVER['PHP_AUTH_PW'])) {
2020
+		if ($h AND isset($_SERVER['PHP_AUTH_PW'])) {
2024 2021
 			include_spip('inc/auth');
2025 2022
 			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
2026 2023
 		}
@@ -2045,7 +2042,7 @@  discard block
 block discarded – undo
2045 2042
 // cette fonction retourne toujours non False
2046 2043
 
2047 2044
 // http://doc.spip.org/@lang_select
2048
-function lang_select ($lang=NULL) {
2045
+function lang_select($lang = NULL) {
2049 2046
 	static $pile_langues = array();
2050 2047
 	if (!function_exists('changer_langue'))
2051 2048
 		include_spip('inc/lang');
@@ -2075,7 +2072,7 @@  discard block
 block discarded – undo
2075 2072
 		$s = pipeline('definir_session',
2076 2073
 			$GLOBALS['visiteur_session']
2077 2074
 			? serialize($GLOBALS['visiteur_session'])
2078
-				. '_' . @$_COOKIE['spip_session']
2075
+				. '_'.@$_COOKIE['spip_session']
2079 2076
 			: ''
2080 2077
 		);
2081 2078
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -2097,9 +2094,9 @@  discard block
 block discarded – undo
2097 2094
  * @return Lien sur une icone d'aide
2098 2095
 **/
2099 2096
 // http://doc.spip.org/@aide
2100
-function aide($aide='', $distante = false) {
2097
+function aide($aide = '', $distante = false) {
2101 2098
 		$aider = charger_fonction('aider', 'inc', true);
2102
-	return $aider ?  $aider($aide, '', array(), $distante) : '';
2099
+	return $aider ? $aider($aide, '', array(), $distante) : '';
2103 2100
 }
2104 2101
 
2105 2102
 // normalement il faudrait creer exec/info.php, mais pour mettre juste ca:
@@ -2128,7 +2125,7 @@  discard block
 block discarded – undo
2128 2125
  * 		Rien dans la plupart des cas
2129 2126
  * 		- string si $message à false.
2130 2127
 **/
2131
-function erreur_squelette($message='', $lieu='') {
2128
+function erreur_squelette($message = '', $lieu = '') {
2132 2129
 	$debusquer = charger_fonction('debusquer', 'public');
2133 2130
 	if (is_array($lieu)) {
2134 2131
 		include_spip('public/compiler');
@@ -2168,15 +2165,15 @@  discard block
 block discarded – undo
2168 2165
  * 		Contenu du squelette calculé
2169 2166
  * 		ou tableau d'information sur le squelette.
2170 2167
  */
2171
-function recuperer_fond($fond, $contexte=array(), $options = array(), $connect='') {
2168
+function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') {
2172 2169
 	if (!function_exists('evaluer_fond'))
2173 2170
 		include_spip('public/assembler');
2174 2171
 	// assurer la compat avec l'ancienne syntaxe
2175 2172
 	// (trim etait le 3eme argument, par defaut a true)
2176 2173
 	if (!is_array($options)) $options = array('trim'=>$options);
2177
-	if (!isset($options['trim'])) $options['trim']=true;
2174
+	if (!isset($options['trim'])) $options['trim'] = true;
2178 2175
 
2179
-	if (isset($contexte['connect'])){
2176
+	if (isset($contexte['connect'])) {
2180 2177
 		$connect = ($connect ? $connect : $contexte['connect']);
2181 2178
 		unset($contexte['connect']);
2182 2179
 	}
@@ -2184,7 +2181,7 @@  discard block
 block discarded – undo
2184 2181
 	$texte = "";
2185 2182
 	$pages = array();
2186 2183
 	$lang_select = '';
2187
-	if (!isset($options['etoile']) OR !$options['etoile']){
2184
+	if (!isset($options['etoile']) OR !$options['etoile']) {
2188 2185
 		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
2189 2186
 		if (!isset($contexte['lang']))
2190 2187
 			$contexte['lang'] = $GLOBALS['spip_lang'];
@@ -2196,10 +2193,10 @@  discard block
 block discarded – undo
2196 2193
 
2197 2194
 	@$GLOBALS['_INC_PUBLIC']++;
2198 2195
 
2199
-	foreach(is_array($fond) ? $fond : array($fond) as $f){
2196
+	foreach (is_array($fond) ? $fond : array($fond) as $f) {
2200 2197
 		$page = evaluer_fond($f, $contexte, $connect);
2201 2198
 		if ($page === '') {
2202
-			$c = isset($options['compil']) ? $options['compil'] :'';
2199
+			$c = isset($options['compil']) ? $options['compil'] : '';
2203 2200
 			$a = array('fichier'=>$fond);
2204 2201
 			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
2205 2202
 			erreur_squelette($erreur, $c);
@@ -2207,14 +2204,14 @@  discard block
 block discarded – undo
2207 2204
 			$page = array('texte' => '', 'erreur' => $erreur);
2208 2205
 		}
2209 2206
 
2210
-		$page = pipeline('recuperer_fond',array(
2211
-			'args'=>array('fond'=>$f,'contexte'=>$contexte,'options'=>$options,'connect'=>$connect),
2207
+		$page = pipeline('recuperer_fond', array(
2208
+			'args'=>array('fond'=>$f, 'contexte'=>$contexte, 'options'=>$options, 'connect'=>$connect),
2212 2209
 			'data'=>$page
2213 2210
 		));
2214
-		if (isset($options['ajax']) AND $options['ajax']){
2211
+		if (isset($options['ajax']) AND $options['ajax']) {
2215 2212
 			if (!function_exists('encoder_contexte_ajax'))
2216 2213
 				include_spip('inc/filtres');
2217
-			$page['texte'] = encoder_contexte_ajax(array_merge($contexte,array('fond'=>$f)),'',$page['texte'], $options['ajax']);
2214
+			$page['texte'] = encoder_contexte_ajax(array_merge($contexte, array('fond'=>$f)), '', $page['texte'], $options['ajax']);
2218 2215
 		}
2219 2216
 
2220 2217
 		if (isset($options['raw']) AND $options['raw'])
@@ -2227,7 +2224,7 @@  discard block
 block discarded – undo
2227 2224
 
2228 2225
 	if ($lang_select) lang_select();
2229 2226
 	if (isset($options['raw']) AND $options['raw'])
2230
-		return is_array($fond)?$pages:reset($pages);
2227
+		return is_array($fond) ? $pages : reset($pages);
2231 2228
 	else
2232 2229
 		return $options['trim'] ? ltrim($texte) : $texte;
2233 2230
 }
@@ -2239,7 +2236,7 @@  discard block
 block discarded – undo
2239 2236
  * @return string
2240 2237
  */
2241 2238
 function trouve_modele($nom) {
2242
-	return trouver_fond($nom,'modeles/');
2239
+	return trouver_fond($nom, 'modeles/');
2243 2240
 }
2244 2241
 
2245 2242
 /**
@@ -2254,8 +2251,8 @@  discard block
 block discarded – undo
2254 2251
  * @param bool $pathinfo
2255 2252
  * @return array|string
2256 2253
  */
2257
-function trouver_fond($nom, $dir='', $pathinfo = false) {
2258
-	$f = find_in_path($nom.'.'. _EXTENSION_SQUELETTES, $dir?rtrim($dir,'/').'/':'');
2254
+function trouver_fond($nom, $dir = '', $pathinfo = false) {
2255
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ?rtrim($dir, '/').'/' : '');
2259 2256
 	if (!$pathinfo) return $f;
2260 2257
 	// renvoyer un tableau detaille si $pathinfo==true
2261 2258
 	$p = pathinfo($f);
@@ -2263,14 +2260,14 @@  discard block
 block discarded – undo
2263 2260
 		$p['extension'] = _EXTENSION_SQUELETTES;
2264 2261
 	}
2265 2262
 	if (!isset($p['extension']) OR !$p['filename']) {
2266
-		$p['filename'] = ($p['basename']?substr($p['basename'],0,-strlen($p['extension'])-1):'');
2263
+		$p['filename'] = ($p['basename'] ?substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
2267 2264
 	}
2268
-	$p['fond'] = ($f?substr($f,0,-strlen($p['extension'])-1):'');
2265
+	$p['fond'] = ($f ?substr($f, 0, -strlen($p['extension']) - 1) : '');
2269 2266
 	return $p;
2270 2267
 }
2271 2268
 
2272
-function tester_url_ecrire($nom){
2273
-	static $exec=array();
2269
+function tester_url_ecrire($nom) {
2270
+	static $exec = array();
2274 2271
 	if (isset($exec[$nom])) return $exec[$nom];
2275 2272
 	// tester si c'est une page en squelette
2276 2273
 	if (trouver_fond($nom, 'prive/squelettes/contenu/'))
@@ -2279,12 +2276,12 @@  discard block
 block discarded – undo
2279 2276
 	elseif (trouver_fond($nom, 'prive/exec/'))
2280 2277
 		return $exec[$nom] = 'fond_monobloc';
2281 2278
 	// echafaudage d'un fond !
2282
-	elseif(include_spip('public/styliser_par_z') AND z_echafaudable($nom))
2279
+	elseif (include_spip('public/styliser_par_z') AND z_echafaudable($nom))
2283 2280
 		return $exec[$nom] = 'fond';
2284 2281
 	// attention, il ne faut pas inclure l'exec ici
2285 2282
 	// car sinon #URL_ECRIRE provoque des inclusions
2286 2283
 	// et des define intrusifs potentiels
2287
-	return $exec[$nom] = ((find_in_path("{$nom}.php",'exec/') OR charger_fonction($nom,'exec',true))?$nom:'');
2284
+	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') OR charger_fonction($nom, 'exec', true)) ? $nom : '');
2288 2285
 }
2289 2286
 
2290 2287
 // Charger dynamiquement une extension php
@@ -2293,7 +2290,7 @@  discard block
 block discarded – undo
2293 2290
 	if (extension_loaded($module)) {
2294 2291
 		return true;
2295 2292
 	} else {
2296
-		$charger_php_extension = charger_fonction('charger_php_extension','inc');
2293
+		$charger_php_extension = charger_fonction('charger_php_extension', 'inc');
2297 2294
 		return $charger_php_extension($module);
2298 2295
 	}
2299 2296
 }
@@ -2322,13 +2319,13 @@  discard block
 block discarded – undo
2322 2319
 
2323 2320
 // Fonction depreciee, cf. http://doc.spip.org/@sql_fetch
2324 2321
 // http://doc.spip.org/@spip_fetch_array
2325
-function spip_fetch_array($r, $t=NULL) {
2322
+function spip_fetch_array($r, $t = NULL) {
2326 2323
 	if (!isset($t)) {
2327 2324
 		if ($r) return sql_fetch($r);
2328 2325
 	} else {
2329
-		if ($t=='SPIP_NUM') $t = MYSQL_NUM;
2330
-		if ($t=='SPIP_BOTH') $t = MYSQL_BOTH;
2331
-		if ($t=='SPIP_ASSOC') $t = MYSQL_ASSOC;
2326
+		if ($t == 'SPIP_NUM') $t = MYSQL_NUM;
2327
+		if ($t == 'SPIP_BOTH') $t = MYSQL_BOTH;
2328
+		if ($t == 'SPIP_ASSOC') $t = MYSQL_ASSOC;
2332 2329
 		spip_log("appel deprecie de spip_fetch_array(..., $t)", 'vieilles_defs');
2333 2330
 		if ($r) return mysql_fetch_array($r, $t);
2334 2331
 	}
@@ -2344,7 +2341,7 @@  discard block
 block discarded – undo
2344 2341
  * @param string $message
2345 2342
  * @param string $statut
2346 2343
  */
2347
-function avertir_auteurs($nom,$message, $statut=''){
2344
+function avertir_auteurs($nom, $message, $statut = '') {
2348 2345
 	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
2349 2346
 	if (!$alertes
2350 2347
 		OR !is_array($alertes = unserialize($alertes)))
@@ -2353,6 +2350,6 @@  discard block
 block discarded – undo
2353 2350
 	if (!isset($alertes[$statut]))
2354 2351
 		$alertes[$statut] = array();
2355 2352
 	$alertes[$statut][$nom] = $message;
2356
-	ecrire_meta("message_alertes_auteurs",serialize($alertes));
2353
+	ecrire_meta("message_alertes_auteurs", serialize($alertes));
2357 2354
 }
2358 2355
 ?>
Please login to merge, or discard this patch.
ecrire/inc/texte.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  */
22 22
 
23 23
 // Raccourcis dependant du sens de la langue
24
-function definir_raccourcis_alineas(){
25
-	return array('','');
24
+function definir_raccourcis_alineas() {
25
+	return array('', '');
26 26
 }
27 27
 
28 28
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 // Traitement des listes (merci a Michael Parienti)
40 40
 //
41 41
 // http://doc.spip.org/@traiter_listes
42
-function traiter_listes ($texte) {
42
+function traiter_listes($texte) {
43 43
 	return $texte;
44 44
 }
45 45
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 // afficher joliment les <script>
67 67
 // http://doc.spip.org/@echappe_js
68
-function echappe_js($t,$class=' class="echappe-js"') {
68
+function echappe_js($t, $class = ' class="echappe-js"') {
69 69
 	if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER))
70 70
 	foreach ($r as $regs)
71 71
 		$t = str_replace($regs[0],
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  *     Code protégé
102 102
 **/
103
-function interdire_scripts($arg, $mode_filtre=null) {
103
+function interdire_scripts($arg, $mode_filtre = null) {
104 104
 	// on memorise le resultat sur les arguments non triviaux
105 105
 	static $dejavu = array();
106 106
 
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 
141 141
 	// Reinserer les echappements des modeles
142 142
 	if (defined('_PROTEGE_JS_MODELES'))
143
-		$t = echappe_retour($t,"javascript"._PROTEGE_JS_MODELES);
143
+		$t = echappe_retour($t, "javascript"._PROTEGE_JS_MODELES);
144 144
 	if (defined('_PROTEGE_PHP_MODELES'))
145
-		$t = echappe_retour($t,"php"._PROTEGE_PHP_MODELES);
145
+		$t = echappe_retour($t, "php"._PROTEGE_PHP_MODELES);
146 146
 
147 147
 	return $dejavu[$mode_filtre][$arg] = $t;
148 148
 }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 // avec protection prealable des balises HTML et SPIP
152 152
 
153 153
 // http://doc.spip.org/@typo
154
-function typo($letexte, $echapper=true, $connect=null, $env=array()) {
154
+function typo($letexte, $echapper = true, $connect = null, $env = array()) {
155 155
 	// Plus vite !
156 156
 	if (!$letexte) return $letexte;
157 157
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	// les appels dans les squelettes (de l'espace prive) fournissant un $connect
163 163
 	// ne seront pas perturbes
164 164
 	$interdire_script = false;
165
-	if (is_null($connect)){
165
+	if (is_null($connect)) {
166 166
 		$connect = '';
167 167
 		$interdire_script = true;
168 168
 		$env['espace_prive'] = 1;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
 	// Dans l'espace prive on se mefie de tout contenu dangereux
197 197
 	// https://core.spip.net/issues/3371
198
-	if (isset($env['espace_prive']) AND $env['espace_prive']){
198
+	if (isset($env['espace_prive']) AND $env['espace_prive']) {
199 199
 		$letexte = echapper_html_suspect($letexte);
200 200
 	}
201 201
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 define('_TYPO_BALISE', ",</?[a-z!][^<>]*[".preg_quote(_TYPO_PROTEGER)."][^<>]*>,imsS");
210 210
 
211 211
 // http://doc.spip.org/@corriger_typo
212
-function corriger_typo($letexte, $lang='') {
212
+function corriger_typo($letexte, $lang = '') {
213 213
 
214 214
 	// Plus vite !
215 215
 	if (!$letexte) return $letexte;
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 //
266 266
 // http://doc.spip.org/@paragrapher
267 267
 // /!\ appelee dans inc/filtres et public/composer
268
-function paragrapher($letexte, $forcer=true) {
268
+function paragrapher($letexte, $forcer = true) {
269 269
 	return $letexte;
270 270
 }
271 271
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 // Filtre a appliquer aux champs du type #TEXTE*
284 284
 // http://doc.spip.org/@propre
285
-function propre($t, $connect=null, $env=array()) {
285
+function propre($t, $connect = null, $env = array()) {
286 286
 	// les appels directs a cette fonction depuis le php de l'espace
287 287
 	// prive etant historiquement ecrits sans argment $connect
288 288
 	// on utilise la presence de celui-ci pour distinguer les cas
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	// les appels dans les squelettes (de l'espace prive) fournissant un $connect
291 291
 	// ne seront pas perturbes
292 292
 	$interdire_script = false;
293
-	if (is_null($connect)){
293
+	if (is_null($connect)) {
294 294
 		$connect = '';
295 295
 		$interdire_script = true;
296 296
 	}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	if (!$t) return strval($t);
299 299
 
300 300
 	$t = echappe_html($t);
301
-	$t = expanser_liens($t,$connect, $env);
301
+	$t = expanser_liens($t, $connect, $env);
302 302
 	$t = traiter_raccourcis($t);
303 303
 	$t = echappe_retour_modeles($t, $interdire_script);
304 304
 
Please login to merge, or discard this patch.
ecrire/inc/rechercher.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 // avec un poids pour le score
19 19
 // http://doc.spip.org/@liste_des_champs
20 20
 function liste_des_champs() {
21
-	static $liste=null;
21
+	static $liste = null;
22 22
 	if (is_null($liste)) {
23 23
 		$liste = array();
24 24
 		// recuperer les tables_objets_sql declarees
25 25
 		include_spip('base/objets');
26 26
 		$tables_objets = lister_tables_objets_sql();
27
-		foreach($tables_objets as $t=>$infos){
28
-			if ($infos['rechercher_champs']){
27
+		foreach ($tables_objets as $t=>$infos) {
28
+			if ($infos['rechercher_champs']) {
29 29
 				$liste[$infos['type']] = $infos['rechercher_champs'];
30 30
 			}
31 31
 		}
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 // en ne regardant que le titre ou le nom
41 41
 // http://doc.spip.org/@liste_des_jointures
42 42
 function liste_des_jointures() {
43
-	static $liste=null;
43
+	static $liste = null;
44 44
 	if (is_null($liste)) {
45 45
 		$liste = array();
46 46
 		// recuperer les tables_objets_sql declarees
47 47
 		include_spip('base/objets');
48 48
 		$tables_objets = lister_tables_objets_sql();
49
-		foreach($tables_objets as $t=>$infos){
50
-			if ($infos['rechercher_jointures']){
49
+		foreach ($tables_objets as $t=>$infos) {
50
+			if ($infos['rechercher_jointures']) {
51 51
 				$liste[$infos['type']] = $infos['rechercher_jointures'];
52 52
 			}
53 53
 		}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	if (substr($recherche, 0, 1) == '/' and substr($recherche, -1, 1) == '/' and strlen($recherche) > 2) {
78 78
 		// c'est une preg
79 79
 		$recherche_trans = translitteration($recherche);
80
-		$preg = $recherche_trans . $options['preg_flags'];
80
+		$preg = $recherche_trans.$options['preg_flags'];
81 81
 		$is_preg = true;
82 82
 	} else {
83 83
 		// s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP,
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		}
99 99
 
100
-		if (preg_match(",\s+," . $u, $recherche_mod)) {
100
+		if (preg_match(",\s+,".$u, $recherche_mod)) {
101 101
 			$is_preg = true;
102 102
 
103 103
 			$recherche_inter = '|';
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 			foreach ($recherche_mots as $mot) {
107 107
 				if (strlen($mot) >= $min_long) {
108 108
 					// echapper les caracteres de regexp qui sont eventuellement dans la recherche
109
-					$recherche_inter .= preg_quote($mot) . ' ';
109
+					$recherche_inter .= preg_quote($mot).' ';
110 110
 				}
111 111
 			}
112 112
 			$recherche_inter = str_replace("\x1", '\s', $recherche_inter);
113 113
 
114 114
 			// mais on cherche quand même l'expression complète, même si elle
115 115
 			// comporte des mots de moins de quatre lettres
116
-			$recherche = rtrim(preg_quote($recherche) . preg_replace(',\s+,' . $u, '|', $recherche_inter), '|');
116
+			$recherche = rtrim(preg_quote($recherche).preg_replace(',\s+,'.$u, '|', $recherche_inter), '|');
117 117
 			$recherche_trans = translitteration($recherche);
118 118
 		}
119 119
 
120
-		$preg = '/' . str_replace('/', '\\/', $recherche_trans) . '/' . $options['preg_flags'];
120
+		$preg = '/'.str_replace('/', '\\/', $recherche_trans).'/'.$options['preg_flags'];
121 121
 	}
122 122
 
123 123
 	// Si la chaine est inactive, on va utiliser LIKE pour aller plus vite
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 		}
157 157
 		$q = sql_quote(
158 158
 			"%"
159
-			. preg_replace(",\s+," . $u, "%", $q)
159
+			. preg_replace(",\s+,".$u, "%", $q)
160 160
 			. "%"
161 161
 		);
162 162
 
163
-		$preg = '/' . preg_replace(",\s+," . $u, ".+", trim($recherche_mod)) . '/' . $options['preg_flags'];
163
+		$preg = '/'.preg_replace(",\s+,".$u, ".+", trim($recherche_mod)).'/'.$options['preg_flags'];
164 164
 
165 165
 	} else {
166 166
 		$methode = 'REGEXP';
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 // - score pour retourner un score
208 208
 // On peut passer les tables, ou une chaine listant les tables souhaitees
209 209
 // http://doc.spip.org/@recherche_en_base
210
-function recherche_en_base($recherche='', $tables=NULL, $options=array(), $serveur='') {
210
+function recherche_en_base($recherche = '', $tables = NULL, $options = array(), $serveur = '') {
211 211
 	include_spip('base/abstract_sql');
212 212
 
213 213
 	if (!is_array($tables)) {
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		if (is_string($tables)
217 217
 		AND $tables != '') {
218 218
 			$toutes = array();
219
-			foreach(explode(',', $tables) as $t)
219
+			foreach (explode(',', $tables) as $t)
220 220
 				if (isset($liste[$t]))
221 221
 					$toutes[$t] = $liste[$t];
222 222
 			$tables = $toutes;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		##var_dump($results[$table]);
269 269
 
270 270
 
271
-		spip_log("recherche $table ($recherche) : ".count($results[$table])." resultats ".spip_timer('rech'),'recherche');
271
+		spip_log("recherche $table ($recherche) : ".count($results[$table])." resultats ".spip_timer('rech'), 'recherche');
272 272
 
273 273
 		if (isset($lock))
274 274
 			cache_unlock($lock);
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
 // Effectue une recherche sur toutes les tables de la base de donnees
282 282
 // http://doc.spip.org/@remplace_en_base
283
-function remplace_en_base($recherche='', $remplace=NULL, $tables=NULL, $options=array()) {
283
+function remplace_en_base($recherche = '', $remplace = NULL, $tables = NULL, $options = array()) {
284 284
 	include_spip('inc/modifier');
285 285
 
286 286
 	// options par defaut
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 
299 299
 	$results = recherche_en_base($recherche, $tables, $options);
300 300
 
301
-	$preg = '/'.str_replace('/', '\\/', $recherche).'/' . $options['preg_flags'];
301
+	$preg = '/'.str_replace('/', '\\/', $recherche).'/'.$options['preg_flags'];
302 302
 
303 303
 	foreach ($results as $table => $r) {
304 304
 		$_id_table = id_table_objet($table);
Please login to merge, or discard this patch.
ecrire/inc/presentation_mini.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
  * @return void
34 34
 **/
35 35
 function echo_log($f, $ret) {
36
-	spip_log("Page " . self() . " function $f: echo ".substr($ret,0,50)."...",'echo');
36
+	spip_log("Page ".self()." function $f: echo ".substr($ret, 0, 50)."...", 'echo');
37 37
 	echo
38
-	(_SIGNALER_ECHOS?"#Echo par $f#" :"")
38
+	(_SIGNALER_ECHOS ? "#Echo par $f#" : "")
39 39
 		. $ret;
40 40
 }
41 41
 
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
  * Retourne le code HTML d'un début de cadre pour le centre de page (haut de page)
44 44
  * @return string Code HTML
45 45
  */
46
-function debut_grand_cadre(){ return "\n<div class='table_page'>\n";}
46
+function debut_grand_cadre() { return "\n<div class='table_page'>\n"; }
47 47
 
48 48
 /**
49 49
  * Retourne le code HTML d'une fin de cadre pour le centre de page (haut de page)
50 50
  * @return string Code HTML
51 51
  */
52
-function fin_grand_cadre(){ return "\n</div>";}
52
+function fin_grand_cadre() { return "\n</div>"; }
53 53
 
54 54
 // Debut de la colonne de gauche
55 55
 // div navigation fermee par creer_colonne_droite qui ouvre
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
  * Retourne le code HTML du début de la colonne gauche
62 62
  * @return string Code HTML
63 63
  */
64
-function debut_gauche() {	return "<div id='conteneur' class=''>\n<div id='navigation' class='lat' role='contentinfo'>\n";}
64
+function debut_gauche() {	return "<div id='conteneur' class=''>\n<div id='navigation' class='lat' role='contentinfo'>\n"; }
65 65
 
66 66
 /**
67 67
  * Retourne le code HTML de la fin de la colonne
68 68
  * @return string Code HTML
69 69
  */
70
-function fin_gauche(){return "</div></div><br class='nettoyeur' />";}
70
+function fin_gauche() {return "</div></div><br class='nettoyeur' />"; }
71 71
 
72 72
 /**
73 73
  * Retourne le code HTML du changement de colonne (passer de la gauche à la droite)
74 74
  * @return string Code HTML
75 75
  */
76
-function creer_colonne_droite(){
76
+function creer_colonne_droite() {
77 77
 	static $deja_colonne_droite;
78
-	if ($GLOBALS['spip_ecran']!='large' OR $deja_colonne_droite) return '';
78
+	if ($GLOBALS['spip_ecran'] != 'large' OR $deja_colonne_droite) return '';
79 79
 	$deja_colonne_droite = true;
80 80
 	return "\n</div><div id='extra' class='lat' role='complementary'>";
81 81
 }
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
 }
93 93
 
94 94
 // http://doc.spip.org/@liste_articles_bloques
95
-function liste_objets_bloques($exec,$contexte=array(),$auteur=null){
95
+function liste_objets_bloques($exec, $contexte = array(), $auteur = null) {
96 96
 	$res = '';
97 97
 	if ($GLOBALS['meta']["articles_modif"] != "non") {
98 98
 		include_spip('inc/drapeau_edition');
99 99
 		if (is_null($auteur))
100 100
 			$auteur = $GLOBALS['visiteur_session'];
101
-		if ($en_cours=trouver_objet_exec($exec)
101
+		if ($en_cours = trouver_objet_exec($exec)
102 102
 			AND $en_cours['edition']
103 103
 			AND $type = $en_cours['type']
104 104
 		  AND ($id = $contexte[$en_cours['id_table_objet']] OR $id = _request($en_cours['id_table_objet']))) {
105 105
 			// marquer le fait que l'objet est ouvert en edition par toto
106 106
 			// a telle date ; une alerte sera donnee aux autres redacteurs
107
-			signale_edition ($id,  $auteur, $type);
107
+			signale_edition($id, $auteur, $type);
108 108
 		}
109 109
 
110 110
 		$objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
111 111
 		if (count($objets_ouverts)) {
112
-			$res .= recuperer_fond('prive/objets/liste/objets-en-edition',array(),array('ajax'=>true));
112
+			$res .= recuperer_fond('prive/objets/liste/objets-en-edition', array(), array('ajax'=>true));
113 113
 		}
114 114
 	}
115 115
 	return $res;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 // Fin de page de l'interface privee.
119 119
 // Elle comporte une image invisible declenchant une tache de fond
120 120
 // http://doc.spip.org/@fin_page
121
-function fin_page(){
121
+function fin_page() {
122 122
 	include_spip('inc/pipelines');
123 123
 	// avec &var_profile=1 on a le tableau de mesures SQL
124 124
 	$debug = ((_request('exec') !== 'valider_xml')
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 	. recuperer_fond('prive/squelettes/inclure/pied')
130 130
 	. "</div>"
131 131
 	. "</div></div>" // cf. div#page et div.largeur ouvertes dans conmmencer_page()
132
-	. ($debug?erreur_squelette():'')
132
+	. ($debug ?erreur_squelette() : '')
133 133
 	. "</body></html>\n";
134 134
 	return f_queue($t);
135 135
 }
136 136
 
137
-function html_tests_js(){
137
+function html_tests_js() {
138 138
 	if (_SPIP_AJAX AND !defined('_TESTER_NOSCRIPT')) {
139 139
 	  // pour le pied de page (deja defini si on est validation XML)
140 140
 		define('_TESTER_NOSCRIPT',
@@ -147,22 +147,22 @@  discard block
 block discarded – undo
147 147
 	. (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
148 148
 }
149 149
 
150
-function info_maj_spip(){
150
+function info_maj_spip() {
151 151
 
152 152
 	$maj = $GLOBALS['meta']['info_maj_spip'];
153 153
 	if (!$maj)
154 154
 		return "";
155 155
 
156
-	$maj = explode('|',$maj);
156
+	$maj = explode('|', $maj);
157 157
 	// c'est une ancienne notif, on a fait la maj depuis !
158
-	if ($GLOBALS['spip_version_branche']!==reset($maj))
158
+	if ($GLOBALS['spip_version_branche'] !== reset($maj))
159 159
 		return "";
160 160
 
161 161
 	if (!autoriser('webmestre'))
162 162
 		return "";
163 163
 
164 164
 	array_shift($maj);
165
-	$maj = implode('|',$maj);
165
+	$maj = implode('|', $maj);
166 166
 
167 167
 	return "$maj<br />";
168 168
 }
@@ -177,27 +177,27 @@  discard block
 block discarded – undo
177 177
 	// Mention, le cas echeant, de la revision SVN courante
178 178
 	//
179 179
 	if ($svn_revision = version_svn_courante(_DIR_RACINE)) {
180
-		$version .= ' ' . (($svn_revision < 0) ? 'SVN ':'')
180
+		$version .= ' '.(($svn_revision < 0) ? 'SVN ' : '')
181 181
 		. "[<a href='http://core.spip.net/projects/spip/repository/revisions/"
182
-		. abs($svn_revision) . "' target=\"_blank\" rel=\"noopener noreferrer\">"
183
-		. abs($svn_revision) . "</a>]";
182
+		. abs($svn_revision)."' target=\"_blank\" rel=\"noopener noreferrer\">"
183
+		. abs($svn_revision)."</a>]";
184 184
 	}
185 185
 
186 186
 	// et la version de l'ecran de securite
187 187
 	$secu = defined('_ECRAN_SECURITE')
188
-		? "<br />"._T('ecran_securite',array('version'=>_ECRAN_SECURITE))
188
+		? "<br />"._T('ecran_securite', array('version'=>_ECRAN_SECURITE))
189 189
 		: '';
190 190
 
191 191
 	return _T('info_copyright',
192 192
 		   array('spip' => "<b>SPIP $version</b> ",
193 193
 			 'lien_gpl' =>
194
-			 "<a href='". generer_url_ecrire("aide", "aide=licence&var_lang=$spip_lang") . "' onclick=\"window.open(this.href, 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580'); return false;\">" . _T('info_copyright_gpl')."</a>"))
194
+			 "<a href='".generer_url_ecrire("aide", "aide=licence&var_lang=$spip_lang")."' onclick=\"window.open(this.href, 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580'); return false;\">"._T('info_copyright_gpl')."</a>"))
195 195
 		. $secu;
196 196
 
197 197
 }
198 198
 
199 199
 // http://doc.spip.org/@formulaire_recherche
200
-function formulaire_recherche($page, $complement=""){
200
+function formulaire_recherche($page, $complement = "") {
201 201
 	$recherche = _request('recherche');
202 202
 	$recherche_aff = entites_html($recherche);
203 203
 	if (!strlen($recherche)) {
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 		$onfocus = " onfocus=\"this.value='';\"";
206 206
 	} else $onfocus = '';
207 207
 
208
-	$form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
209
-	$form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='"._T('info_rechercher')."' />";
210
-	return "<div class='spip_recherche'>".generer_form_ecrire($page, $form . $complement, " method='get'")."</div>";
208
+	$form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"'.$onfocus.' />';
209
+	$form .= "<input type='image' src='".chemin_image('rechercher-20.png')."' name='submit' class='submit' alt='"._T('info_rechercher')."' />";
210
+	return "<div class='spip_recherche'>".generer_form_ecrire($page, $form.$complement, " method='get'")."</div>";
211 211
 }
212 212
 
213 213
 ?>
Please login to merge, or discard this patch.
ecrire/inc/informer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 # Les information d'une rubrique selectionnee dans le mini navigateur
16 16
 
17 17
 // http://doc.spip.org/@inc_informer_dist
18
-function inc_informer_dist($id, $col, $exclus, $rac, $type, $do='aff')
18
+function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff')
19 19
 {
20 20
 	include_spip('inc/texte');
21 21
 	if ($type == "rubrique") {
22
-		$row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = " . intval($id));
22
+		$row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = ".intval($id));
23 23
 		if ($row) {
24 24
 			$titre = typo($row["titre"]);
25 25
 			$descriptif = propre($row["descriptif"]);
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	if ($type == "rubrique" AND $GLOBALS['spip_display'] != 1 AND isset($GLOBALS['meta']['image_process']))
34 34
 	  if ($GLOBALS['meta']['image_process'] != "non") {
35 35
 		$chercher_logo = charger_fonction('chercher_logo', 'inc');
36
-		if ($res = $chercher_logo($id, 'id_rubrique', 'on'))  {
36
+		if ($res = $chercher_logo($id, 'id_rubrique', 'on')) {
37 37
 			list($fid, $dir, $nom, $format) = $res;
38 38
 			include_spip('inc/filtres_images_mini');
39 39
 			$res = image_reduire("<img src='$fid' alt='' />", 100, 48);
40 40
 			if ($res)
41
-				$res =  "<div style='float: ".$GLOBALS['spip_lang_right']."; margin-".$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>";
41
+				$res = "<div style='float: ".$GLOBALS['spip_lang_right']."; margin-".$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>";
42 42
 		}
43 43
 	}
44 44
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			str_replace('"', "&#34;", textebrut($titre))),
53 53
 		       "\n\r", "  ");
54 54
 
55
-	$js_func = $do . '_selection_titre';
55
+	$js_func = $do.'_selection_titre';
56 56
 	return "<div style='display: none;'>"
57 57
 	. "<input type='text' id='".$rac."_sel' value='$id' />"
58 58
 	. "<input type='text' id='".$rac."_sel2' value=\""
Please login to merge, or discard this patch.
ecrire/inc/chercher_rubrique.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 //    n'importe ou (defaut), et les breves dans les secteurs.
24 24
 // $idem : en mode rubrique = la rubrique soi-meme
25 25
 // http://doc.spip.org/@inc_chercher_rubrique_dist
26
-function inc_chercher_rubrique_dist ($id_rubrique, $type, $restreint, $idem=0, $do='aff') {
27
-	if (sql_countsel('spip_rubriques')<1)
26
+function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
27
+	if (sql_countsel('spip_rubriques') < 1)
28 28
 		return '';
29 29
 
30 30
 	// Mode sans Ajax :
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
 	$espace = '';
50 50
 	if (preg_match(",mozilla,i", $browser_name)) {
51 51
 		$style = "padding-$spip_lang_left: 16px; "
52
-		. "margin-$spip_lang_left: ".(($i-1)*16)."px;";
52
+		. "margin-$spip_lang_left: ".(($i - 1) * 16)."px;";
53 53
 	} else {
54 54
 		$style = '';
55
-		for ($count = 0; $count <= $i; $count ++)
55
+		for ($count = 0; $count <= $i; $count++)
56 56
 			$espace .= "&nbsp;&nbsp;&nbsp;&nbsp;";
57 57
 	}
58
-	if ($i ==1)
59
-		$espace= "";
58
+	if ($i == 1)
59
+		$espace = "";
60 60
 	$class = "niveau_$i";
61
-	return array($class,$style,$espace);
61
+	return array($class, $style, $espace);
62 62
 }
63 63
 
64 64
 // http://doc.spip.org/@sous_menu_rubriques
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 	if (isset($enfants[$root]))
94 94
 		foreach ($enfants[$root] as $sousrub)
95 95
 			$sous .= sous_menu_rubriques($id_rubrique, $sousrub,
96
-				$niv+1, $data, $enfants, $exclus, $restreint, $type);
96
+				$niv + 1, $data, $enfants, $exclus, $restreint, $type);
97 97
 
98 98
 	// si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
99
-	if ($restreint AND $root!=$id_rubrique AND !autoriser('publierdans','rubrique',$root))
99
+	if ($restreint AND $root != $id_rubrique AND !autoriser('publierdans', 'rubrique', $root))
100 100
 		return $sous;
101 101
 
102 102
 	// et voila le travail
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 
106 106
 // Le selecteur de rubriques en mode classique (menu)
107 107
 // http://doc.spip.org/@selecteur_rubrique_html
108
-function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem=0) {
108
+function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) {
109 109
 	$data = array();
110
-	if ($type == 'rubrique' AND autoriser('publierdans','rubrique',0))
110
+	if ($type == 'rubrique' AND autoriser('publierdans', 'rubrique', 0))
111 111
 		$data[0] = _T('info_racine_site');
112 112
 	# premier choix = neant
113 113
 	# si auteur (rubriques restreintes)
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	//
121 121
 
122 122
 	include_spip('base/abstract_sql');
123
-	$q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", ($type == 'breve' ?  ' id_parent=0 ' : ''), '', "0+titre,titre");
123
+	$q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre");
124 124
 	while ($r = sql_fetch($q)) {
125
-		if (autoriser('voir','rubrique',$r['id_rubrique'])){
125
+		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
126 126
 			// titre largeur maxi a 50
127 127
 			$titre = couper(supprimer_tags(typo($r['titre']))." ", 50);
128 128
 			if ($GLOBALS['meta']['multi_rubriques'] == 'oui'
@@ -137,18 +137,18 @@  discard block
 block discarded – undo
137 137
 	// si une seule rubrique comme choix possible,
138 138
 	// inutile de mettre le selecteur sur un choix vide par defaut
139 139
 	// sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
140
-	if (count($data)==2
140
+	if (count($data) == 2
141 141
 	  AND isset($data[0])
142
-	  AND !in_array($type,array('auteur','rubrique'))
142
+	  AND !in_array($type, array('auteur', 'rubrique'))
143 143
 	  AND !$id_rubrique)
144 144
 		unset($data[0]);
145 145
 
146 146
 
147
-	$opt = sous_menu_rubriques($id_rubrique,0, 0,$data,$enfants,$idem, $restreint, $type);
147
+	$opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
148 148
 	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
149 149
 
150
-	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,',$opt,$r))
151
-	  $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2] ;
150
+	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r))
151
+	  $r = "<input$att type='hidden' value='".$r[1]."' />".$r[2];
152 152
 	else 
153 153
 	  $r = "<select".$att." size='1'>\n$opt</select>\n";
154 154
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
  * @param string $do
178 178
  * @return string
179 179
  */
180
-function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem=0, $do) {
180
+function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do) {
181 181
 
182 182
 	if ($id_rubrique) {
183 183
 		$titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique));
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 		$titre = _T('info_racine_site');
188 188
 
189 189
 	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
190
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
190
+	$init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'";
191 191
 
192
-	$url = generer_url_ecrire('selectionner',"id=$id_rubrique&type=$type&do=$do"
192
+	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
193 193
 	. (!$idem ? '' : "&exclus=$idem")
194 194
 	. ($restreint ? "" : "&racine=oui")
195 195
 	. (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 // getElement en mode Ajax est trop couteux).
206 206
 
207 207
 // http://doc.spip.org/@construire_selecteur
208
-function construire_selecteur($url, $js, $idom, $name, $init='', $id=0){
209
-	$icone = (strpos($idom, 'auteur')!==false) ? 'auteur-24.png' : 'rechercher-20.png';
208
+function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) {
209
+	$icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png';
210 210
 	return
211 211
 	"<div class='rubrique_actuelle'><a href='#' onclick=\""
212 212
 	.  $js
Please login to merge, or discard this patch.
ecrire/public/assembler.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 //
21 21
 
22 22
 // http://doc.spip.org/@assembler
23
-function assembler($fond, $connect='') {
23
+function assembler($fond, $connect = '') {
24 24
 
25 25
 	// flag_preserver est modifie ici, et utilise en globale
26 26
 	// use_cache sert a informer le bouton d'admin pr savoir s'il met un *
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
 	$contexte = calculer_contexte();
31 31
 	$page = array('contexte_implicite'=>calculer_contexte_implicite());
32
-	$page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']));
32
+	$page['contexte_implicite']['cache'] = $fond.preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']));
33 33
 	// Cette fonction est utilisee deux fois
34 34
 	$cacher = charger_fonction('cacher', 'public', true);
35 35
 	// Les quatre derniers parametres sont modifies par la fonction:
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	else
40 40
 		$use_cache = -1;
41 41
 	// Si un resultat est retourne, c'est un message d'impossibilite
42
-	if ($res) {return array('texte' => $res);}
42
+	if ($res) {return array('texte' => $res); }
43 43
 
44 44
 	if (!$chemin_cache || !$lastmodified) $lastmodified = time();
45 45
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	AND $chemin_cache
55 55
 	AND isset($page['entetes'])
56 56
 	AND isset($page['entetes']['Cache-Control'])
57
-	AND strstr($page['entetes']['Cache-Control'],'max-age=')
58
-	AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/')
57
+	AND strstr($page['entetes']['Cache-Control'], 'max-age=')
58
+	AND !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
59 59
 	) {
60 60
 		$since = preg_replace('/;.*/', '',
61 61
 			$_SERVER['HTTP_IF_MODIFIED_SINCE']);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		$page['texte'] = "";
74 74
 	} else {
75 75
 		// si la page est prise dans le cache
76
-		if (!$use_cache)  {
76
+		if (!$use_cache) {
77 77
 			// Informer les boutons d'admin du contexte
78 78
 			// (fourni par urls_decoder_url ci-dessous lors de la mise en cache)
79 79
 			$contexte = $page['contexte'];
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 			// et calculer la page
92 92
 			if (!test_espace_prive()) {
93 93
 				include_spip('inc/urls');
94
-				list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true);
94
+				list($fond, $contexte, $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $contexte, true);
95 95
 			}
96 96
 			// squelette par defaut
97 97
 			if (!strlen($fond))
98 98
 				$fond = 'sommaire';
99 99
 
100 100
 			// produire la page : peut mettre a jour $lastmodified
101
-			$produire_page = charger_fonction('produire_page','public');
101
+			$produire_page = charger_fonction('produire_page', 'public');
102 102
 			$page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, NULL, $page, $lastmodified, $connect);
103 103
 			if ($page === '') {
104 104
 				$erreur = _T('info_erreur_squelette2',
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		auto_content_type($page);
115 115
 
116
-		$flag_preserver |=  headers_sent();
116
+		$flag_preserver |= headers_sent();
117 117
 
118 118
 		// Definir les entetes si ce n'est fait 
119 119
 		if (!$flag_preserver) {
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				}
129 129
 				// pas de cache client en mode 'observation'
130 130
 				if (defined('_VAR_MODE') AND _VAR_MODE) {
131
-					$page['entetes']["Cache-Control"]= "no-cache,must-revalidate";
131
+					$page['entetes']["Cache-Control"] = "no-cache,must-revalidate";
132 132
 					$page['entetes']["Pragma"] = "no-cache";
133 133
 				}
134 134
 			}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	if ($lastmodified
142 142
 	AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
143 143
 	AND !isset($page['entetes']["Last-Modified"]))
144
-		$page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT";
144
+		$page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified)." GMT";
145 145
 
146 146
 	// fermer la connexion apres les headers si requete HEAD
147 147
 	if ($headers_only)
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 function calculer_contexte() {
162 162
 
163 163
 	$contexte = array();
164
-	foreach($_GET as $var => $val) {
165
-		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var))
164
+	foreach ($_GET as $var => $val) {
165
+		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var))
166 166
 			$contexte[$var] = $val;
167 167
 	}
168
-	foreach($_POST as $var => $val) {
169
-		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var))
168
+	foreach ($_POST as $var => $val) {
169
+		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var))
170 170
 			$contexte[$var] = $val;
171 171
 	}
172 172
 
@@ -180,18 +180,18 @@  discard block
 block discarded – undo
180 180
  * @staticvar string $notes
181 181
  * @return array
182 182
  */
183
-function calculer_contexte_implicite(){
183
+function calculer_contexte_implicite() {
184 184
 	static $notes = null;
185 185
 	if (is_null($notes))
186
-		$notes = charger_fonction('notes','inc',true);
186
+		$notes = charger_fonction('notes', 'inc', true);
187 187
 	$contexte_implicite = array(
188 188
 		'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ?
189 189
 		'host' => $_SERVER['HTTP_HOST'],
190 190
 		'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''),
191 191
 		'espace' => test_espace_prive(),
192
-		'marqueur' => (isset($GLOBALS['marqueur']) ?  $GLOBALS['marqueur'] : ''),
193
-		'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ?  $GLOBALS['marqueur_skel'] : ''),
194
-		'notes' => $notes?$notes('','contexter_cache'):'',
192
+		'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''),
193
+		'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''),
194
+		'notes' => $notes ? $notes('', 'contexter_cache') : '',
195 195
 		'spip_version_code' => $GLOBALS['spip_version_code'],
196 196
 	);
197 197
 	return $contexte_implicite;
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
 	global $flag_preserver;
208 208
 	if (!isset($flag_preserver))
209 209
 	  {
210
-	    $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type'])));
210
+	    $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx", $page['texte']) || (isset($page['entetes']['Content-Type'])));
211 211
 	  }
212 212
 }
213 213
 
214 214
 // http://doc.spip.org/@inclure_page
215
-function inclure_page($fond, $contexte, $connect='') {
215
+function inclure_page($fond, $contexte, $connect = '') {
216 216
 	static $cacher, $produire_page;
217 217
 	global $lastmodified;
218 218
 
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	else
232 232
 		$use_cache = -1;
233 233
 	// $res = message d'erreur : on sort de la
234
-	if ($res) {return array('texte' => $res);}
234
+	if ($res) {return array('texte' => $res); }
235 235
 
236 236
 	// Si use_cache ne vaut pas 0, la page doit etre calculee
237 237
 	// produire la page : peut mettre a jour $lastinclude
238 238
 	// le contexte_cache envoye a cacher() a ete conserve et est passe a produire
239 239
 	if ($use_cache) {
240 240
 		if (is_null($produire_page))
241
-			$produire_page = charger_fonction('produire_page','public');
241
+			$produire_page = charger_fonction('produire_page', 'public');
242 242
 		$page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect);
243 243
 	}
244 244
 	// dans tous les cas, mettre a jour $lastmodified
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
  * @param string $connect
262 262
  * @return array
263 263
  */
264
-function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){
265
-	static $parametrer,$cacher;
264
+function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect = '') {
265
+	static $parametrer, $cacher;
266 266
 	if (!$parametrer)
267 267
 		$parametrer = charger_fonction('parametrer', 'public');
268 268
 	$page = $parametrer($fond, $contexte, $chemin_cache, $connect);
269 269
 	// et on l'enregistre sur le disque
270 270
 	if ($chemin_cache
271
-	AND $use_cache>-1
271
+	AND $use_cache > -1
272 272
 	AND is_array($page)
273 273
 	AND count($page)
274
-	AND $page['entetes']['X-Spip-Cache'] > 0){
274
+	AND $page['entetes']['X-Spip-Cache'] > 0) {
275 275
 		if (is_null($cacher))
276 276
 			$cacher = charger_fonction('cacher', 'public', true);
277 277
 		$lastinclude = time();
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 // $echo = faut-il faire echo ou return
308 308
 
309 309
 // http://doc.spip.org/@inclure_balise_dynamique
310
-function inclure_balise_dynamique($texte, $echo=true, $contexte_compil=array())
310
+function inclure_balise_dynamique($texte, $echo = true, $contexte_compil = array())
311 311
 {
312 312
 	if (is_array($texte)) {
313 313
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL;
318 318
 		$GLOBALS['delais'] = $delainc;
319 319
 
320
-		$page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil));
320
+		$page = recuperer_fond($fond, $contexte_inclus, array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil));
321 321
 
322 322
 		$texte = $page['texte'];
323 323
 
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 				if (!is_array($GLOBALS['page']['entetes']))
332 332
 					$GLOBALS['page']['entetes'] = array();
333 333
 				$GLOBALS['page']['entetes'] = 
334
-					array_merge($GLOBALS['page']['entetes'],$page['entetes']);
334
+					array_merge($GLOBALS['page']['entetes'], $page['entetes']);
335 335
 			}
336 336
 		}
337 337
 		// _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines
338 338
 		if (isset($page['contexte']['_pipelines'])
339 339
 		  AND is_array($page['contexte']['_pipelines'])
340 340
 			AND count($page['contexte']['_pipelines'])) {
341
-			foreach($page['contexte']['_pipelines'] as $pipe=>$args){
341
+			foreach ($page['contexte']['_pipelines'] as $pipe=>$args) {
342 342
 				$args['contexte'] = $page['contexte'];
343 343
 				unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul
344 344
 				$texte = pipeline(
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
 	if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') {
357 357
 		// compatibilite : avant on donnait le numero de ligne ou rien.
358
-		$ligne =  intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil);
358
+		$ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil);
359 359
 		$GLOBALS['debug_objets']['resultat'][$ligne] = $texte;
360 360
 	}
361 361
 	if ($echo)
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 }
367 367
 
368 368
 // http://doc.spip.org/@message_page_indisponible
369
-function message_page_indisponible ($page, $contexte) {
369
+function message_page_indisponible($page, $contexte) {
370 370
 	static $deja = false;
371 371
 	if ($deja) return "erreur";
372 372
 	$codes = array(
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	$deja = true;
384 384
 	// passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent
385 385
 	// ex restriction d'acces => 401
386
-	$contexte = pipeline('page_indisponible',$contexte);
386
+	$contexte = pipeline('page_indisponible', $contexte);
387 387
 
388 388
 	// produire la page d'erreur
389 389
 	$page = inclure_page($contexte['fond'], $contexte);
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
 function creer_contexte_de_modele($args) {
401 401
 	$contexte = array();
402 402
 	foreach ($args as $var=>$val) {
403
-		if (is_int($var)){ // argument pas formate
403
+		if (is_int($var)) { // argument pas formate
404 404
 			if (in_array($val, array('left', 'right', 'center'))) {
405 405
 				$var = 'align';
406 406
 				$contexte[$var] = $val;
407 407
 			} else {
408 408
 				$args = explode('=', $val);
409
-				if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args
410
-					$contexte[trim($args[0])] = substr($val,strlen($args[0])+1);
409
+				if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args
410
+					$contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1);
411 411
 				else // notation abregee
412 412
 					$contexte[trim($val)] = trim($val);
413 413
 			}
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
 
422 422
 // Calcule le modele et retourne la mini-page ainsi calculee
423 423
 // http://doc.spip.org/@inclure_modele
424
-function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) {
424
+function inclure_modele($type, $id, $params, $lien, $connect = '', $env = array()) {
425 425
 
426 426
 	static $compteur;
427
-	if (++$compteur>10) return ''; # ne pas boucler indefiniment
427
+	if (++$compteur > 10) return ''; # ne pas boucler indefiniment
428 428
 
429 429
 	$type = strtolower($type);
430 430
 
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 				$class = $soustype;
447 447
 			}
448 448
 			// enlever le sous type des params
449
-			$params = array_diff($params,array($soustype));
449
+			$params = array_diff($params, array($soustype));
450 450
 		}
451 451
 	}
452 452
 
453 453
 	// Si ca marche pas en precisant le sous-type, prendre le type
454
-	if (!$fond AND !trouve_modele($fond = $type)){
455
-		spip_log("Modele $type introuvable",_LOG_INFO_IMPORTANTE);
454
+	if (!$fond AND !trouve_modele($fond = $type)) {
455
+		spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE);
456 456
 		return false;
457 457
 	}
458 458
 	$fond = 'modeles/'.$fond;
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 	// Si un lien a ete passe en parametre, ex: [<modele1>->url]
475 475
 	if ($lien) {
476 476
 		# un eventuel guillemet (") sera reechappe par #ENV
477
-		$contexte['lien'] = str_replace("&quot;",'"', $lien['href']);
477
+		$contexte['lien'] = str_replace("&quot;", '"', $lien['href']);
478 478
 		$contexte['lien_class'] = $lien['class'];
479 479
 		$contexte['lien_mime'] = $lien['mime'];
480 480
 		$contexte['lien_title'] = $lien['title'];
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	// par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en>
486 486
 	$arg_list = creer_contexte_de_modele($params);
487 487
 	$contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args
488
-	$contexte = array_merge($contexte,$arg_list);
488
+	$contexte = array_merge($contexte, $arg_list);
489 489
 
490 490
 
491 491
 	// Appliquer le modele avec le contexte
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	// Regarder si le modele tient compte des liens (il *doit* alors indiquer
496 496
 	// spip_lien_ok dans les classes de son conteneur de premier niveau ;
497 497
 	// sinon, s'il y a un lien, on l'ajoute classiquement
498
-	if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ',
498
+	if (strstr(' '.($classes = extraire_attribut($retour, 'class')).' ',
499 499
 	'spip_lien_ok')) {
500 500
 		$retour = inserer_attribut($retour, 'class',
501 501
 			trim(str_replace(' spip_lien_ok ', ' ', " $classes ")));
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 
505 505
 	$compteur--;
506 506
 
507
-	return  (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax')
508
-	? encoder_contexte_ajax($contexte,'',$retour)
507
+	return  (isset($arg_list['ajax']) AND $arg_list['ajax'] == 'ajax')
508
+	? encoder_contexte_ajax($contexte, '', $retour)
509 509
 	: $retour; 
510 510
 }
511 511
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 // pour recuperer $page complet, utiliser:
515 515
 // 	recuperer_fond($fond,$contexte,array('raw'=>true))
516 516
 // http://doc.spip.org/@evaluer_fond
517
-function evaluer_fond ($fond, $contexte=array(), $connect=null) {
517
+function evaluer_fond($fond, $contexte = array(), $connect = null) {
518 518
 
519 519
 	$page = inclure_page($fond, $contexte, $connect);
520 520
 
@@ -536,36 +536,36 @@  discard block
 block discarded – undo
536 536
 
537 537
 
538 538
 // http://doc.spip.org/@page_base_href
539
-function page_base_href(&$texte){
539
+function page_base_href(&$texte) {
540 540
 	static $set_html_base = null;
541
-	if (is_null($set_html_base)){
541
+	if (is_null($set_html_base)) {
542 542
 		if (!defined('_SET_HTML_BASE'))
543 543
 			// si la profondeur est superieure a 1
544 544
 			// est que ce n'est pas une url page ni une url action
545 545
 			// activer par defaut
546 546
 			$set_html_base = ((
547
-				$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2)
547
+				$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
548 548
 				AND _request(_SPIP_PAGE) !== 'login'
549
-				AND !_request('action'))?true:false);
549
+				AND !_request('action')) ?true:false);
550 550
 		else
551 551
 			$set_html_base = _SET_HTML_BASE;
552 552
 	}
553 553
 
554 554
 	if ($set_html_base
555 555
 	  AND isset($GLOBALS['html']) AND $GLOBALS['html']
556
-	  AND $GLOBALS['profondeur_url']>0
557
-	  AND ($poshead = strpos($texte,'</head>'))!==FALSE){
558
-		$head = substr($texte,0,$poshead);
556
+	  AND $GLOBALS['profondeur_url'] > 0
557
+	  AND ($poshead = strpos($texte, '</head>')) !== FALSE) {
558
+		$head = substr($texte, 0, $poshead);
559 559
 		$insert = false;
560
-		if (strpos($head, '<base')===false) 
560
+		if (strpos($head, '<base') === false) 
561 561
 			$insert = true;
562 562
 		else {
563 563
 			// si aucun <base ...> n'a de href c'est bon quand meme !
564 564
 			$insert = true;
565 565
 			include_spip('inc/filtres');
566
-			$bases = extraire_balises($head,'base');
566
+			$bases = extraire_balises($head, 'base');
567 567
 			foreach ($bases as $base)
568
-				if (extraire_attribut($base,'href'))
568
+				if (extraire_attribut($base, 'href'))
569 569
 					$insert = false;
570 570
 		}
571 571
 		if ($insert) {
@@ -574,21 +574,21 @@  discard block
 block discarded – undo
574 574
 			$base = url_absolue('./');
575 575
 			$bbase = "\n<base href=\"$base\" />";
576 576
 			if (($pos = strpos($head, '<head>')) !== false)
577
-				$head = substr_replace($head, $bbase, $pos+6, 0);
578
-			elseif(preg_match(",<head[^>]*>,i",$head,$r)){
577
+				$head = substr_replace($head, $bbase, $pos + 6, 0);
578
+			elseif (preg_match(",<head[^>]*>,i", $head, $r)) {
579 579
 				$head = str_replace($r[0], $r[0].$bbase, $head);
580 580
 			}
581
-			$texte = $head . substr($texte,$poshead);
581
+			$texte = $head.substr($texte, $poshead);
582 582
 			// gerer les ancres
583 583
 			$base = $_SERVER['REQUEST_URI'];
584 584
 			// pas de guillemets ni < dans l'URL qu'on insere dans le HTML
585
-			if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) {
586
-				$base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base);
585
+			if (strpos($base, "'") or strpos($base, '"') or strpos($base, '<')) {
586
+				$base = str_replace(array("'", '"', '<'), array("%27", '%22', '%3C'), $base);
587 587
 			}
588
-			if (strpos($texte,"href='#")!==false)
589
-				$texte = str_replace("href='#","href='$base#",$texte);
590
-			if (strpos($texte, "href=\"#")!==false)
591
-				$texte = str_replace("href=\"#","href=\"$base#",$texte);
588
+			if (strpos($texte, "href='#") !== false)
589
+				$texte = str_replace("href='#", "href='$base#", $texte);
590
+			if (strpos($texte, "href=\"#") !== false)
591
+				$texte = str_replace("href=\"#", "href=\"$base#", $texte);
592 592
 		}
593 593
 	}
594 594
 }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 function envoyer_entetes($entetes) {
601 601
 	foreach ($entetes as $k => $v)
602 602
 	#	if (strncmp($k, 'X-Spip-', 7))
603
-			@header(strlen($v)?"$k: $v":$k); 
603
+			@header(strlen($v) ? "$k: $v" : $k); 
604 604
 }
605 605
 
606 606
 ?>
Please login to merge, or discard this patch.
prive/formulaires/configurer_transcodeur.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) return;
14 14
 
15
-function formulaires_configurer_transcodeur_charger_dist(){
15
+function formulaires_configurer_transcodeur_charger_dist() {
16 16
 	$valeurs = array(
17 17
 		'charset' => $GLOBALS['meta']["charset"],
18 18
 	);
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
 	return $valeurs;
21 21
 }
22 22
 
23
-function formulaires_configurer_transcodeur_verifier_dist(){
23
+function formulaires_configurer_transcodeur_verifier_dist() {
24 24
 	include_spip('inc/charsets');
25 25
 	
26 26
 	$erreurs = array();
27
-	if (!$charset=_request('charset'))
27
+	if (!$charset = _request('charset'))
28 28
 		$erreurs['charset'] = _T('info_obligatoire');
29
-	elseif ($charset!='utf-8' AND !load_charset($charset))
29
+	elseif ($charset != 'utf-8' AND !load_charset($charset))
30 30
 		$erreurs['charset'] = _T('utf8_convert_erreur_orig', array('charset' => entites_html($charset)));
31 31
 
32 32
 	return $erreurs;
33 33
 }
34 34
 
35 35
 
36
-function formulaires_configurer_transcodeur_traiter_dist(){
36
+function formulaires_configurer_transcodeur_traiter_dist() {
37 37
 	$res = array('editable'=>true);
38 38
 	ecrire_meta('charset', _request('charset'));
39 39
 	$res['message_ok'] = _T('config_info_enregistree');
Please login to merge, or discard this patch.