Completed
Push — spip-3.0 ( 77f3d0...1797f4 )
by cam
17:20 queued 08:11
created
config/ecran_securite.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
  * var_isbot=1 peut etre utilise pour monitorer la disponibilite pour les bots (sujets a 503 de delestage si
24 24
  * le load depasse ECRAN_SECURITE_LOAD)
25 25
  */
26
-if (!defined('_IS_BOT') and isset($_GET['var_isbot'])){
26
+if (!defined('_IS_BOT') and isset($_GET['var_isbot'])) {
27 27
 	define('_IS_BOT', $_GET['var_isbot'] ? true : false);
28 28
 }
29 29
 
30 30
 /*
31 31
  * Détecteur de robot d'indexation
32 32
  */
33
-if (!defined('_IS_BOT')){
33
+if (!defined('_IS_BOT')) {
34 34
 	define('_IS_BOT',
35 35
 		isset($_SERVER['HTTP_USER_AGENT'])
36 36
 		and preg_match(
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 			. 'MSIE 6\.0|'
41 41
 			// UA plus cibles
42 42
 			. '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebookexternalhit|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MegaIndex|MetaURI|Moreover|Rambler|Scrapy|Scooter|ScrubbyBloglines|Yahoo|Yeti'
43
-			. ',i', (string)$_SERVER['HTTP_USER_AGENT'])
43
+			. ',i', (string) $_SERVER['HTTP_USER_AGENT'])
44 44
 	);
45 45
 }
46
-if (!defined('_IS_BOT_FRIEND')){
46
+if (!defined('_IS_BOT_FRIEND')) {
47 47
 	define('_IS_BOT_FRIEND',
48 48
 		isset($_SERVER['HTTP_USER_AGENT'])
49 49
 		and preg_match(','
50 50
 			// UA plus cibles
51 51
 			. 'facebookexternalhit'
52
-			. ',i', (string)$_SERVER['HTTP_USER_AGENT'])
52
+			. ',i', (string) $_SERVER['HTTP_USER_AGENT'])
53 53
 	);
54 54
 }
55 55
 
@@ -63,15 +63,15 @@  discard block
 block discarded – undo
63 63
 foreach ($_GET as $var => $val)
64 64
 	if ($_GET[$var] and strncmp($var, "id_", 3) == 0
65 65
 	and !in_array($var, array('id_table', 'id_base')))
66
-		$_GET[$var] = is_array($_GET[$var])?@array_map('intval', $_GET[$var]):intval($_GET[$var]);
66
+		$_GET[$var] = is_array($_GET[$var]) ? @array_map('intval', $_GET[$var]) : intval($_GET[$var]);
67 67
 foreach ($_POST as $var => $val)
68 68
 	if ($_POST[$var] and strncmp($var, "id_", 3) == 0
69 69
 	and !in_array($var, array('id_table', 'id_base')))
70
-		$_POST[$var] = is_array($_POST[$var])?@array_map('intval', $_POST[$var]):intval($_POST[$var]);
70
+		$_POST[$var] = is_array($_POST[$var]) ? @array_map('intval', $_POST[$var]) : intval($_POST[$var]);
71 71
 foreach ($GLOBALS as $var => $val)
72 72
 	if ($GLOBALS[$var] and strncmp($var, "id_", 3) == 0
73 73
 	and !in_array($var, array('id_table', 'id_base')))
74
-		$GLOBALS[$var] = is_array($GLOBALS[$var])?@array_map('intval', $GLOBALS[$var]):intval($GLOBALS[$var]);
74
+		$GLOBALS[$var] = is_array($GLOBALS[$var]) ? @array_map('intval', $GLOBALS[$var]) : intval($GLOBALS[$var]);
75 75
 
76 76
 /*
77 77
  * Interdit la variable $cjpeg_command, qui était utilisée sans
@@ -82,18 +82,18 @@  discard block
 block discarded – undo
82 82
 /*
83 83
  * Contrôle de quelques variables (XSS)
84 84
  */
85
-foreach(array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
85
+foreach (array('lang', 'var_recherche', 'aide', 'var_lang_r', 'lang_r', 'var_ajax_ancre', 'nom_fichier') as $var) {
86 86
 	if (isset($_GET[$var]))
87
-		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_GET[$var]);
87
+		$_REQUEST[$var] = $GLOBALS[$var] = $_GET[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string) $_GET[$var]);
88 88
 	if (isset($_POST[$var]))
89
-		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string)$_POST[$var]);
89
+		$_REQUEST[$var] = $GLOBALS[$var] = $_POST[$var] = preg_replace(',[^\w\,/#&;-]+,', ' ', (string) $_POST[$var]);
90 90
 }
91 91
 
92 92
 /*
93 93
  * Filtre l'accès à spip_acces_doc (injection SQL en 1.8.2x)
94 94
  */
95
-if (preg_match(',^(.*/)?spip_acces_doc\.,', (string)$_SERVER['REQUEST_URI'])) {
96
-	$file = addslashes((string)$_GET['file']);
95
+if (preg_match(',^(.*/)?spip_acces_doc\.,', (string) $_SERVER['REQUEST_URI'])) {
96
+	$file = addslashes((string) $_GET['file']);
97 97
 }
98 98
 
99 99
 /*
@@ -108,28 +108,28 @@  discard block
 block discarded – undo
108 108
  * Agenda joue à l'injection php
109 109
  */
110 110
 if (isset($_REQUEST['partie_cal'])
111
-and $_REQUEST['partie_cal'] !== htmlentities((string)$_REQUEST['partie_cal']))
111
+and $_REQUEST['partie_cal'] !== htmlentities((string) $_REQUEST['partie_cal']))
112 112
 	$ecran_securite_raison = "partie_cal";
113 113
 if (isset($_REQUEST['echelle'])
114
-and $_REQUEST['echelle'] !== htmlentities((string)$_REQUEST['echelle']))
114
+and $_REQUEST['echelle'] !== htmlentities((string) $_REQUEST['echelle']))
115 115
 	$ecran_securite_raison = "echelle";
116 116
 
117 117
 /*
118 118
  * Espace privé
119 119
  */
120 120
 if (isset($_REQUEST['exec'])
121
-and !preg_match(',^[\w-]+$,', (string)$_REQUEST['exec']))
121
+and !preg_match(',^[\w-]+$,', (string) $_REQUEST['exec']))
122 122
 	$ecran_securite_raison = "exec";
123 123
 if (isset($_REQUEST['cherche_auteur'])
124
-and preg_match(',[<],', (string)$_REQUEST['cherche_auteur']))
124
+and preg_match(',[<],', (string) $_REQUEST['cherche_auteur']))
125 125
 	$ecran_securite_raison = "cherche_auteur";
126 126
 if (isset($_REQUEST['exec'])
127 127
 and $_REQUEST['exec'] == 'auteurs'
128
-and preg_match(',[<],', (string)$_REQUEST['recherche']))
128
+and preg_match(',[<],', (string) $_REQUEST['recherche']))
129 129
 	$ecran_securite_raison = "recherche";
130 130
 if (isset($_REQUEST['exec'])
131 131
 and $_REQUEST['exec'] == 'info_plugin'
132
-and preg_match(',[<],', (string)$_REQUEST['plugin']))
132
+and preg_match(',[<],', (string) $_REQUEST['plugin']))
133 133
 	$ecran_securite_raison = "plugin";
134 134
 if (isset($_REQUEST['exec'])
135 135
 and $_REQUEST['exec'] == 'puce_statut'
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	or @file_exists('ecrire/inc_version.php')) {
143 143
 		function action_configurer() {
144 144
 			include_spip('inc/autoriser');
145
-			if(!autoriser('configurer', _request('configuration'))) {
145
+			if (!autoriser('configurer', _request('configuration'))) {
146 146
 				include_spip('inc/minipres');
147 147
 				echo minipres(_T('info_acces_interdit'));
148 148
 				exit;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
  */
184 184
 if (_IS_BOT and (
185 185
 	(isset($_REQUEST['echelle']) and isset($_REQUEST['partie_cal']) and isset($_REQUEST['type']))
186
-	or (strpos((string)$_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string)$_SERVER['REQUEST_URI']))
186
+	or (strpos((string) $_SERVER['REQUEST_URI'], 'debut_') and preg_match(',[?&]debut_.*&debut_,', (string) $_SERVER['REQUEST_URI']))
187 187
 )
188 188
 )
189 189
 	$ecran_securite_raison = "robot agenda/double pagination";
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 if (isset($_REQUEST['page'])) {
196 196
 	if ($_REQUEST['page'] == 'test_cfg')
197 197
 		$ecran_securite_raison = "test_cfg";
198
-	if ($_REQUEST['page'] !== htmlspecialchars((string)$_REQUEST['page']))
198
+	if ($_REQUEST['page'] !== htmlspecialchars((string) $_REQUEST['page']))
199 199
 		$ecran_securite_raison = "xsspage";
200 200
 	if ($_REQUEST['page'] == '404'
201 201
 	and isset($_REQUEST['erreur']))
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 /*
234 234
  * Outils XML mal sécurisés again
235 235
  */
236
-if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec']=='valider_xml'){
236
+if (isset($_REQUEST['var_url']) and $_REQUEST['var_url'] and isset($_REQUEST['exec']) and $_REQUEST['exec'] == 'valider_xml') {
237 237
 	$url = trim($_REQUEST['var_url']);
238
-	if (strncmp($url,'/',1)==0
239
-	  or (($p=strpos($url,'..'))!==false AND strpos($url,'..',$p+3)!==false)
240
-		or (strpos($url,'://')!==false or strpos($url,':\\')!==false)) {
238
+	if (strncmp($url, '/', 1) == 0
239
+	  or (($p = strpos($url, '..')) !== false AND strpos($url, '..', $p + 3) !== false)
240
+		or (strpos($url, '://') !== false or strpos($url, ':\\') !== false)) {
241 241
 		$ecran_securite_raison = 'URL interdite pour var_url';
242 242
 	}
243 243
 }
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
  * Sauvegarde mal securisée < 2.0.9
247 247
  */
248 248
 if (isset($_REQUEST['nom_sauvegarde'])
249
-and strstr((string)$_REQUEST['nom_sauvegarde'], '/'))
249
+and strstr((string) $_REQUEST['nom_sauvegarde'], '/'))
250 250
 	$ecran_securite_raison = 'nom_sauvegarde manipulee';
251 251
 if (isset($_REQUEST['znom_sauvegarde'])
252
-and strstr((string)$_REQUEST['znom_sauvegarde'], '/'))
252
+and strstr((string) $_REQUEST['znom_sauvegarde'], '/'))
253 253
 	$ecran_securite_raison = 'znom_sauvegarde manipulee';
254 254
 
255 255
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 /*
265 265
  * Forms & Table ne se méfiait pas assez des uploads de fichiers
266 266
  */
267
-if (count($_FILES)){
268
-	foreach($_FILES as $k => $v){
267
+if (count($_FILES)) {
268
+	foreach ($_FILES as $k => $v) {
269 269
 		 if (preg_match(',^fichier_\d+$,', $k)
270 270
 		 and preg_match(',\.php,i', $v['name']))
271 271
 		 	unset($_FILES[$k]);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
  * et Contact trop laxiste avec une variable externe
276 276
  * on bloque pas le post pour eviter de perdre des donnees mais on unset la variable et c'est tout
277 277
  */
278
-if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']){
278
+if (isset($_REQUEST['pj_enregistrees_nom']) and $_REQUEST['pj_enregistrees_nom']) {
279 279
 	unset($_REQUEST['pj_enregistrees_nom']);
280 280
 	unset($_GET['pj_enregistrees_nom']);
281 281
 	unset($_POST['pj_enregistrees_nom']);
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 /*
306 306
  * Réinjection des clés en html dans l'admin r19561
307 307
  */
308
-if (strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false){
308
+if (strpos($_SERVER['REQUEST_URI'], "ecrire/") !== false) {
309 309
 	$zzzz = implode("", array_keys($_REQUEST));
310 310
 	if (strlen($zzzz) != strcspn($zzzz, '<>"\''))
311 311
 		$ecran_securite_raison = 'Cle incorrecte en $_REQUEST';
Please login to merge, or discard this patch.
ecrire/public/decompiler.php 1 patch
Spacing   +54 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP
16 16
 
17
-function decompiler_boucle($struct, $fmt='', $prof=0)
17
+function decompiler_boucle($struct, $fmt = '', $prof = 0)
18 18
 {
19 19
 	$nom = $struct->id_boucle;
20 20
 	$avant = decompiler_($struct->avant, $fmt, $prof);
@@ -23,98 +23,96 @@  discard block
 block discarded – undo
23 23
 	$milieu = decompiler_($struct->milieu, $fmt, $prof);
24 24
 
25 25
 	$type = $struct->sql_serveur ? "$struct->sql_serveur:" : '';
26
-	$type .= ($struct->type_requete ? $struct->type_requete :
27
-			    $struct->table_optionnelle);
26
+	$type .= ($struct->type_requete ? $struct->type_requete : $struct->table_optionnelle);
28 27
 
29 28
 	if ($struct->jointures_explicites)
30
-	  $type .= " " . $struct->jointures_explicites;
29
+	  $type .= " ".$struct->jointures_explicites;
31 30
 	if ($struct->table_optionnelle)
32 31
 	  $type .= "?";
33 32
 	// Revoir le cas de la boucle recursive
34 33
 
35 34
 	$crit = $struct->param;
36 35
 	if ($crit AND !is_array($crit[0])) {
37
-		$type = strtolower($type) . array_shift($crit);
36
+		$type = strtolower($type).array_shift($crit);
38 37
 	}
39
-	$crit = decompiler_criteres($struct, $fmt, $prof) ;
38
+	$crit = decompiler_criteres($struct, $fmt, $prof);
40 39
 
41
-	$f = 'format_boucle_' . $fmt;
40
+	$f = 'format_boucle_'.$fmt;
42 41
 	return $f($avant, $nom, $type, $crit, $milieu, $apres, $altern, $prof);
43 42
 }
44 43
 	
45
-function decompiler_include($struct, $fmt='', $prof=0)
44
+function decompiler_include($struct, $fmt = '', $prof = 0)
46 45
 {
47 46
 	$res = array();
48
-	foreach($struct->param ? $struct->param : array() as $couple) {
47
+	foreach ($struct->param ? $struct->param : array() as $couple) {
49 48
 		array_shift($couple);
50
-		foreach($couple as $v) {
51
-			$res[]= decompiler_($v, $fmt, $prof);
49
+		foreach ($couple as $v) {
50
+			$res[] = decompiler_($v, $fmt, $prof);
52 51
 		}
53 52
 	}
54
-	$file = is_string($struct->texte) ? $struct->texte :
55
-		decompiler_($struct->texte, $fmt, $prof);
56
-	$f = 'format_inclure_' . $fmt;
53
+	$file = is_string($struct->texte) ? $struct->texte : decompiler_($struct->texte, $fmt, $prof);
54
+	$f = 'format_inclure_'.$fmt;
57 55
 	return $f($file, $res, $prof);
58 56
 }
59 57
 
60
-function decompiler_texte($struct, $fmt='', $prof=0)
58
+function decompiler_texte($struct, $fmt = '', $prof = 0)
61 59
 {
62
-	$f = 'format_texte_' . $fmt;
60
+	$f = 'format_texte_'.$fmt;
63 61
 	return strlen($struct->texte) ? $f($struct->texte, $prof) : '';
64 62
 }
65 63
 
66
-function decompiler_polyglotte($struct, $fmt='', $prof=0)
64
+function decompiler_polyglotte($struct, $fmt = '', $prof = 0)
67 65
 {
68
-	$f = 'format_polyglotte_' . $fmt;
66
+	$f = 'format_polyglotte_'.$fmt;
69 67
 	return $f($struct->traductions, $prof);
70 68
 }
71 69
 
72
-function decompiler_idiome($struct, $fmt='', $prof=0)
70
+function decompiler_idiome($struct, $fmt = '', $prof = 0)
73 71
 {
74 72
 	$args = array();
75 73
 	foreach ($struct->arg as $k => $v) {
76
-		$args[$k]= public_decompiler($v, $fmt, $prof);
74
+		$args[$k] = public_decompiler($v, $fmt, $prof);
77 75
 	}
78 76
 
79
-	$filtres =  decompiler_liste($struct->param, $fmt, $prof);
77
+	$filtres = decompiler_liste($struct->param, $fmt, $prof);
80 78
 
81
-	$f = 'format_idiome_' . $fmt;
79
+	$f = 'format_idiome_'.$fmt;
82 80
 	return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof);
83 81
 }
84 82
 
85
-function decompiler_champ($struct, $fmt='', $prof=0)
83
+function decompiler_champ($struct, $fmt = '', $prof = 0)
86 84
 {
87 85
 	$avant = decompiler_($struct->avant, $fmt, $prof);
88 86
 	$apres = decompiler_($struct->apres, $fmt, $prof);
89 87
 	$args = $filtres = '';
90 88
 	if ($p = $struct->param) {
91
-		if ($p[0][0]==='')
89
+		if ($p[0][0] === '')
92 90
 		  $args = decompiler_liste(array(array_shift($p)), $fmt, $prof);
93 91
 		$filtres = decompiler_liste($p, $fmt, $prof);
94 92
 	}
95
-	$f = 'format_champ_' . $fmt;
93
+	$f = 'format_champ_'.$fmt;
96 94
 	return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof);
97 95
 }
98 96
 
99
-function decompiler_liste($sources, $fmt='', $prof=0) {
97
+function decompiler_liste($sources, $fmt = '', $prof = 0) {
100 98
 	if (!is_array($sources)) return '';
101
-	$f = 'format_liste_' . $fmt;
99
+	$f = 'format_liste_'.$fmt;
102 100
 	$res = '';
103
-	foreach($sources as $arg) {
104
-		if (!is_array($arg))  {
101
+	foreach ($sources as $arg) {
102
+		if (!is_array($arg)) {
105 103
 		  continue; // ne devrait pas arriver.
106
-		} else {$r = array_shift($arg);}
104
+		} else {$r = array_shift($arg); }
107 105
 		$args = array();
108
-		foreach($arg as $v) {
106
+		foreach ($arg as $v) {
109 107
 		  // cas des arguments entoures de ' ou "
110 108
 			if ((count($v) == 1) 
111
-			AND $v[0]->type=='texte'
109
+			AND $v[0]->type == 'texte'
112 110
 			AND (strlen($v[0]->apres) == 1)
113 111
 			AND $v[0]->apres == $v[0]->avant)
114
-			  $args[]= $v[0]->avant . $v[0]->texte . $v[0]->apres;
115
-			else $args[]= decompiler_($v, $fmt, 0-$prof);
112
+			  $args[] = $v[0]->avant.$v[0]->texte.$v[0]->apres;
113
+			else $args[] = decompiler_($v, $fmt, 0 - $prof);
116 114
 		}
117
-		if (($r!=='') OR $args) $res .= $f($r, $args, $prof);
115
+		if (($r !== '') OR $args) $res .= $f($r, $args, $prof);
118 116
 	}
119 117
 	return $res;
120 118
 }
@@ -123,30 +121,30 @@  discard block
 block discarded – undo
123 121
 // - le phraseur fournit un bout du source en plus de la compil
124 122
 // - le champ apres signale le critere {"separateur"} ou {'separateur'}
125 123
 // - les champs sont implicitement etendus (crochets implicites mais interdits)
126
-function decompiler_criteres($boucle, $fmt='', $prof=0) {
124
+function decompiler_criteres($boucle, $fmt = '', $prof = 0) {
127 125
 	$sources = $boucle->param;
128 126
 	if (!is_array($sources)) return '';
129 127
 	$res = '';
130
-	$f = 'format_critere_' . $fmt;
131
-	foreach($sources as $crit) {
128
+	$f = 'format_critere_'.$fmt;
129
+	foreach ($sources as $crit) {
132 130
 		if (!is_array($crit)) continue; // boucle recursive
133 131
 		array_shift($crit);
134 132
 		$args = array();
135
-		foreach($crit as $i => $v) {
133
+		foreach ($crit as $i => $v) {
136 134
 		  if ((count($v) == 1) 
137
-		      AND $v[0]->type=='texte'
135
+		      AND $v[0]->type == 'texte'
138 136
 		      AND $v[0]->apres)
139
-		    $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres)));
137
+		    $args[] = array(array('texte', ($v[0]->apres.$v[0]->texte.$v[0]->apres)));
140 138
 		  else {
141 139
 		    $res2 = array();
142
-		    foreach($v as $k => $p) {
140
+		    foreach ($v as $k => $p) {
143 141
 			if (isset($p->type)
144
-			AND function_exists($d = 'decompiler_' . $p->type)) {
145
-				$r = $d($p, $fmt, (0-$prof), @$v[$k+1]);
146
-				$res2[]= array($p->type, $r);
142
+			AND function_exists($d = 'decompiler_'.$p->type)) {
143
+				$r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]);
144
+				$res2[] = array($p->type, $r);
147 145
 			} else spip_log("critere $i / $k mal forme");
148 146
 		    }
149
-		    $args[]= $res2;
147
+		    $args[] = $res2;
150 148
 		  }
151 149
 		}
152 150
 		$res .= $f($args);
@@ -155,15 +153,15 @@  discard block
 block discarded – undo
155 153
 }
156 154
 
157 155
 
158
-function decompiler_($liste, $fmt='', $prof=0)
156
+function decompiler_($liste, $fmt = '', $prof = 0)
159 157
 {
160 158
 	if (!is_array($liste))  return '';
161
-	$prof2 = ($prof < 0) ? ($prof-1) : ($prof+1);
159
+	$prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1);
162 160
 	$contenu = array();
163
-	foreach($liste as $k => $p) {
161
+	foreach ($liste as $k => $p) {
164 162
 	    if (!isset($p->type)) continue; #??????
165
-	    $d = 'decompiler_' . $p->type;
166
-	    $next = isset($liste[$k+1]) ? $liste[$k+1] : false;
163
+	    $d = 'decompiler_'.$p->type;
164
+	    $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false;
167 165
 	  // Forcer le champ etendu si son source (pas les reecritures)
168 166
 	  // contenait des args et s'il est suivi d'espaces, 
169 167
 	  // le champ simple les eliminant est un bug helas perenne.
@@ -175,7 +173,7 @@  discard block
 block discarded – undo
175 173
 		AND !$p->avant
176 174
 		AND $p->fonctions) {
177 175
 	      $n = strlen($next->texte) - strlen(ltrim($next->texte));
178
-	      if ($n)  {
176
+	      if ($n) {
179 177
 			$champ = new Texte;
180 178
 			$champ->texte = substr($next->texte, 0, $n);
181 179
 			$champ->ligne = $p->ligne;
@@ -186,14 +184,14 @@  discard block
 block discarded – undo
186 184
 	    $contenu[] = array($d($p, $fmt, $prof2), $p->type);
187 185
 
188 186
 	}
189
-	$f = 'format_suite_' . $fmt;
187
+	$f = 'format_suite_'.$fmt;
190 188
 	return $f($contenu);
191 189
 }
192 190
 
193
-function public_decompiler($liste, $fmt='', $prof=0, $quoi='') 
191
+function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') 
194 192
 {
195
-	if (!include_spip('public/format_' . $fmt)) return "'$fmt'?";
196
-	$f = 'decompiler_' . $quoi;
193
+	if (!include_spip('public/format_'.$fmt)) return "'$fmt'?";
194
+	$f = 'decompiler_'.$quoi;
197 195
 	return $f($liste, $fmt, $prof);
198 196
 }
199 197
 ?>
Please login to merge, or discard this patch.
ecrire/public/evaluer_page.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -45,55 +45,55 @@
 block discarded – undo
45 45
 	// restaurer l'etat des notes avant calcul
46 46
 	if (isset($page['notes'])
47 47
 		AND $page['notes']
48
-		AND $notes = charger_fonction("notes","inc",true)){
49
-		$notes($page['notes'],'restaurer_etat');
48
+		AND $notes = charger_fonction("notes", "inc", true)) {
49
+		$notes($page['notes'], 'restaurer_etat');
50 50
 	}
51 51
 	ob_start();
52
-	if (strpos($page['texte'],'?xml')!==false)
52
+	if (strpos($page['texte'], '?xml') !== false)
53 53
 		$page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']);
54 54
 
55 55
 	try {
56
-		$res = eval('?' . '>' . $page['texte']);
56
+		$res = eval('?'.'>'.$page['texte']);
57 57
 		// error catching 5.2<=PHP<7
58 58
 		if ($res === false
59 59
 		  and function_exists('error_get_last')
60
-		  and ($erreur = error_get_last()) ) {
60
+		  and ($erreur = error_get_last())) {
61 61
 			$code = $page['texte'];
62 62
 			$GLOBALS['numero_ligne_php'] = 1;
63
-			if (!function_exists('numerote_ligne_php')){
64
-				function numerote_ligne_php($match){
63
+			if (!function_exists('numerote_ligne_php')) {
64
+				function numerote_ligne_php($match) {
65 65
 					$GLOBALS['numero_ligne_php']++;
66
-					return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/";
66
+					return "\n/*".str_pad($GLOBALS['numero_ligne_php'], 3, "0", STR_PAD_LEFT)."*/";
67 67
 				}
68 68
 			}
69
-			$code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
70
-			$code = trim(highlight_string($code,true));
71
-			erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang']));
69
+			$code = "/*001*/".preg_replace_callback(",\n,", "numerote_ligne_php", $code);
70
+			$code = trim(highlight_string($code, true));
71
+			erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code, array($page['source'], '', $erreur['file'], '', $GLOBALS['spip_lang']));
72 72
 			$page['texte'] = "<!-- Erreur -->";
73 73
 		}
74 74
 		else {
75 75
 			$page['texte'] = ob_get_contents();
76 76
 		}
77 77
 	}
78
-	catch (Exception $e){
78
+	catch (Exception $e) {
79 79
 		$code = $page['texte'];
80 80
 		$GLOBALS['numero_ligne_php'] = 1;
81
-		if (!function_exists('numerote_ligne_php')){
82
-			function numerote_ligne_php($match){
81
+		if (!function_exists('numerote_ligne_php')) {
82
+			function numerote_ligne_php($match) {
83 83
 				$GLOBALS['numero_ligne_php']++;
84
-				return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/";
84
+				return "\n/*".str_pad($GLOBALS['numero_ligne_php'], 3, "0", STR_PAD_LEFT)."*/";
85 85
 			}
86 86
 		}
87
-		$code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
88
-		$code = trim(highlight_string($code,true));
89
-		erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']));
87
+		$code = "/*001*/".preg_replace_callback(",\n,", "numerote_ligne_php", $code);
88
+		$code = trim(highlight_string($code, true));
89
+		erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code, array($page['source'], '', $e->getFile(), '', $GLOBALS['spip_lang']));
90 90
 		$page['texte'] = "<!-- Erreur -->";
91 91
 	}
92 92
 	ob_end_clean();
93 93
 
94 94
 	$page['process_ins'] = 'html';
95 95
 
96
-	if (strpos($page['texte'],'?xml')!==false)
96
+	if (strpos($page['texte'], '?xml') !== false)
97 97
 		$page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']);
98 98
 }
99 99
 
Please login to merge, or discard this patch.
ecrire/public/references.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
  * @param Object $p
28 28
  * @return string
29 29
  */
30
-function index_boucle($p){
30
+function index_boucle($p) {
31 31
 
32 32
 	$idb = $p->id_boucle;
33 33
 	$explicite = $p->nom_boucle;
34 34
 
35 35
 	if (strlen($explicite)) {
36 36
 		// Recherche d'un champ dans un etage superieur
37
-	  while (($idb !== $explicite) && ($idb !=='')) {
37
+	  while (($idb !== $explicite) && ($idb !== '')) {
38 38
 			$idb = $p->boucles[$idb]->id_parent;
39 39
 		}
40 40
 	}
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
  *   permettre de remonter la pile des boucles ou non (dans ce cas on ne cherche que ds la 1ere boucle englobante)
65 65
  * @return string
66 66
  */
67
-function index_pile($idb, $nom_champ, &$boucles, $explicite='', $defaut=null, $remonte_pile=true) {
67
+function index_pile($idb, $nom_champ, &$boucles, $explicite = '', $defaut = null, $remonte_pile = true) {
68 68
 	if (!is_string($defaut))
69
-		$defaut = '@$Pile[0][\''. strtolower($nom_champ) . '\']';
69
+		$defaut = '@$Pile[0][\''.strtolower($nom_champ).'\']';
70 70
 
71 71
 	$i = 0;
72 72
 	if (strlen($explicite)) {
73 73
 		// Recherche d'un champ dans un etage superieur
74
-	  while (($idb !== $explicite) && ($idb !=='')) {
74
+	  while (($idb !== $explicite) && ($idb !== '')) {
75 75
 			#	spip_log("Cherchexpl: $nom_champ '$explicite' '$idb' '$i'");
76 76
 			$i++;
77 77
 			$idb = $boucles[$idb]->id_parent;
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 			if (!in_array($t, $boucles[$idb]->select)) {
91 91
 				$boucles[$idb]->select[] = $t;
92 92
 			}
93
-			$champ = '$Pile[$SP' . ($i ? "-$i" : "") . '][\'' . $c . '\']';
93
+			$champ = '$Pile[$SP'.($i ? "-$i" : "").'][\''.$c.'\']';
94 94
 			if (!$joker)
95
-				return index_compose($conditionnel,$champ);
95
+				return index_compose($conditionnel, $champ);
96 96
 
97 97
 			$conditionnel[] = "isset($champ)?$champ";
98 98
 		}
99 99
 
100
-		if ($remonte_pile){
100
+		if ($remonte_pile) {
101 101
 			#	spip_log("On remonte vers $i");
102 102
 			// Sinon on remonte d'un cran
103 103
 			$idb = $boucles[$idb]->id_parent;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	#	spip_log("Pas vu $nom_champ");
111 111
 	// esperons qu'il y sera
112 112
 	// on qu'on a fourni une valeur par "defaut" plus pertinent
113
-	return index_compose($conditionnel,$defaut);
113
+	return index_compose($conditionnel, $defaut);
114 114
 }
115 115
 
116 116
 /**
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
  * @param string $defaut
123 123
  * @return string
124 124
  */
125
-function index_compose($conditionnel,$defaut){
125
+function index_compose($conditionnel, $defaut) {
126 126
 	while ($c = array_pop($conditionnel))
127 127
 		// si on passe defaut = '', ne pas générer d'erreur de compilation.
128
-		$defaut = "($c:(".($defaut?$defaut:"''")."))";
128
+		$defaut = "($c:(".($defaut ? $defaut : "''")."))";
129 129
 	return $defaut;
130 130
 }
131 131
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	if (!$r) {
140 140
 		$joker = false; // indiquer a l'appelant
141 141
 		# continuer pour chercher l'erreur suivante
142
-		return  array("'#" . $r . ':' . $nom_champ . "'",'');
142
+		return  array("'#".$r.':'.$nom_champ."'", '');
143 143
 	}
144 144
 
145 145
 	$desc = $boucles[$idb]->show;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 					       $nom_champ,
174 174
 					       array($t[1]['id_table'], $nom_champ));
175 175
 		  }
176
-			return array('','');
176
+			return array('', '');
177 177
 		}
178 178
 	}
179 179
 }
@@ -192,24 +192,24 @@  discard block
 block discarded – undo
192 192
 	if (is_array($excep)) {
193 193
 		// permettre aux plugins de gerer eux meme des jointures derogatoire ingerables
194 194
 		$t = NULL;
195
-		if (count($excep)==3){
195
+		if (count($excep) == 3) {
196 196
 			$index_exception_derogatoire = array_pop($excep);
197 197
 			$t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep);
198 198
 		}
199 199
 		if ($t == NULL) {
200
-			list($e, $x) = $excep;	#PHP4 affecte de gauche a droite
201
-			$excep = $x;		#PHP5 de droite a gauche !
200
+			list($e, $x) = $excep; #PHP4 affecte de gauche a droite
201
+			$excep = $x; #PHP5 de droite a gauche !
202 202
 			$j = $trouver_table($e, $boucle->sql_serveur);
203
-			if (!$j) return array('','');
203
+			if (!$j) return array('', '');
204 204
 			$e = $j['table'];
205 205
 			if (!$t = array_search($e, $boucle->from)) {
206 206
 				$k = $j['key']['PRIMARY KEY'];
207
-				if (strpos($k,',')) {
207
+				if (strpos($k, ',')) {
208 208
 					$l = (preg_split('/\s*,\s*/', $k));
209 209
 					$k = $desc['key']['PRIMARY KEY'];
210 210
 					if (!in_array($k, $l)) {
211
-						spip_log("jointure impossible $e " . join(',', $l));
212
-						return array('','');
211
+						spip_log("jointure impossible $e ".join(',', $l));
212
+						return array('', '');
213 213
 					}
214 214
 				}
215 215
 				$k = array($boucle->id_table, array($e), $k);
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	else $t = $boucle->id_table;
222 222
 	// demander a SQL de gerer le synonyme
223 223
 	// ca permet que excep soit dynamique (Cedric, 2/3/06)
224
-	if ($excep != $nom_champ) $excep .= ' AS '. $nom_champ;
224
+	if ($excep != $nom_champ) $excep .= ' AS '.$nom_champ;
225 225
 	return array("$t.$excep", $nom_champ);
226 226
 }
227 227
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
 	// Certaines des balises comportant un _ sont generiques
276 276
 	if ($f = strpos($nom, '_')
277
-	AND $f = charger_fonction(substr($nom,0,$f+1), 'balise', true)) {
277
+	AND $f = charger_fonction(substr($nom, 0, $f + 1), 'balise', true)) {
278 278
 		$res = $f($p);
279 279
 		if ($res !== NULL)
280 280
 			return $res;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	array(%s%s))");
333 333
 
334 334
 // http://doc.spip.org/@calculer_balise_dynamique
335
-function calculer_balise_dynamique($p, $nom, $l, $supp=array()) {
335
+function calculer_balise_dynamique($p, $nom, $l, $supp = array()) {
336 336
 
337 337
 	if (!balise_distante_interdite($p)) {
338 338
 		$p->code = "''";
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 
355 355
 	$p->code = sprintf(CODE_EXECUTER_BALISE, $nom,
356 356
 		join(',', $collecte),
357
-		($collecte ? $param : substr($param,1)), # virer la virgule
357
+		($collecte ? $param : substr($param, 1)), # virer la virgule
358 358
 		memoriser_contexte_compil($p),
359
-		(!$supp ? '' : (', ' . join(',', $supp))));
359
+		(!$supp ? '' : (', '.join(',', $supp))));
360 360
 
361 361
 	$p->interdire_scripts = false;
362 362
 	return $p;
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 // http://doc.spip.org/@collecter_balise_dynamique
372 372
 function collecter_balise_dynamique($l, &$p, $nom) {
373 373
 	$args = array();
374
-	foreach($l as $c) { $x = calculer_balise($c, $p); $args[] = $x->code;}
374
+	foreach ($l as $c) { $x = calculer_balise($c, $p); $args[] = $x->code; }
375 375
 	return $args;
376 376
 }
377 377
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		$s = $p->boucles[$nom]->sql_serveur;
396 396
 		if (strlen($s)
397 397
 			AND strlen($serveur = strtolower($s))
398
-			AND !in_array($serveur,$GLOBALS['exception_des_connect'])) {
398
+			AND !in_array($serveur, $GLOBALS['exception_des_connect'])) {
399 399
 				return $serveur;
400 400
 		}
401 401
 	}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	$nom = $p->id_boucle;
426 426
 
427 427
 	if ($nom AND trouver_nom_serveur_distant($p)) {
428
-		spip_log( $nom .':' . $p->nom_champ .' '._T('zbug_distant_interdit'));
428
+		spip_log($nom.':'.$p->nom_champ.' '._T('zbug_distant_interdit'));
429 429
 		return false;
430 430
 	}
431 431
 	return true;
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 // definis par $table_des_traitements, cf. ecrire/public/interfaces
438 438
 //
439 439
 // http://doc.spip.org/@champs_traitements
440
-function champs_traitements ($p) {
440
+function champs_traitements($p) {
441 441
 	global $table_des_traitements;
442 442
 
443 443
 	if (isset($table_des_traitements[$p->nom_champ]))
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 		$idb = index_boucle($p);
458 458
 		// mais on peut aussi etre hors boucle. Se mefier.
459 459
 		$type_requete = isset($p->boucles[$idb]->type_requete) ? $p->boucles[$idb]->type_requete : false;
460
-		$table_sql = isset($p->boucles[$idb]->show['table_sql'])?$p->boucles[$idb]->show['table_sql']:false;
460
+		$table_sql = isset($p->boucles[$idb]->show['table_sql']) ? $p->boucles[$idb]->show['table_sql'] : false;
461 461
 
462 462
 		// le traitement peut n'etre defini que pour une table en particulier "spip_articles"
463 463
 		if ($table_sql AND isset($ps[$table_sql]))
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
 		elseif ($type_requete AND isset($ps[$type_requete]))
467 467
 			$ps = $ps[$type_requete];
468 468
 		// ou pour indiferrement quelle que soit la boucle
469
-		elseif(isset($ps[0]))
469
+		elseif (isset($ps[0]))
470 470
 			$ps = $ps[0];
471 471
 		else
472
-			$ps=false;
472
+			$ps = false;
473 473
 	}
474 474
 
475 475
 	if (!$ps) return $p->code;
@@ -484,9 +484,9 @@  discard block
 block discarded – undo
484 484
 	AND 
485 485
 	  $p->descr['documents']
486 486
 	AND (
487
-		(strpos($ps,'propre') !== false)
487
+		(strpos($ps, 'propre') !== false)
488 488
 		OR
489
-		(strpos($ps,'typo') !== false)
489
+		(strpos($ps, 'typo') !== false)
490 490
 	))
491 491
 		$ps = 'traiter_doublons_documents($doublons, '.$ps.')';
492 492
 
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
 function compose_filtres(&$p, $code) {
532 532
 
533 533
 	$image_miette = false;
534
-	foreach($p->param as $filtre) {
534
+	foreach ($p->param as $filtre) {
535 535
 		$fonc = array_shift($filtre);
536 536
 		if (!$fonc) continue; // normalement qu'au premier tour.
537
-		$is_filtre_image = ((substr($fonc,0,6)=='image_') AND $fonc!='image_graver');
538
-		if ($image_miette AND !$is_filtre_image){
537
+		$is_filtre_image = ((substr($fonc, 0, 6) == 'image_') AND $fonc != 'image_graver');
538
+		if ($image_miette AND !$is_filtre_image) {
539 539
 	// il faut graver maintenant car apres le filtre en cours
540 540
 	// on est pas sur d'avoir encore le nom du fichier dans le pipe
541 541
 			$code = "filtrer('image_graver', $code)";
@@ -548,14 +548,14 @@  discard block
 block discarded – undo
548 548
 		} else {$sep = ':';
549 549
 			// |?{a,b} *doit* avoir exactement 2 arguments ; on les force
550 550
 			if (count($filtre) != 2)
551
-				$filtre = array(isset($filtre[0])?$filtre[0]:"", isset($filtre[1])?$filtre[1]:"");
551
+				$filtre = array(isset($filtre[0]) ? $filtre[0] : "", isset($filtre[1]) ? $filtre[1] : "");
552 552
 		}
553 553
 		$arglist = compose_filtres_args($p, $filtre, $sep);
554
-		$logique = filtre_logique($fonc, $code, substr($arglist,1));
554
+		$logique = filtre_logique($fonc, $code, substr($arglist, 1));
555 555
 		if ($logique)
556 556
 			$code = $logique;
557 557
 		else {
558
-			$code = sandbox_composer_filtre($fonc,$code,$arglist,$p);
558
+			$code = sandbox_composer_filtre($fonc, $code, $arglist, $p);
559 559
 			if ($is_filtre_image) $image_miette = true;
560 560
 		}
561 561
 	}
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 {
596 596
 	$arglist = "";
597 597
 	foreach ($args as $arg) {
598
-		$arglist .= $sep . 
598
+		$arglist .= $sep. 
599 599
 		  calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle);
600 600
 	}
601 601
 	return $arglist;
@@ -607,17 +607,17 @@  discard block
 block discarded – undo
607 607
 // ET chez sa maman
608 608
 // 
609 609
 // http://doc.spip.org/@calculer_argument_precedent
610
-function calculer_argument_precedent($idb, $nom_champ, &$boucles, $defaut=null) {
610
+function calculer_argument_precedent($idb, $nom_champ, &$boucles, $defaut = null) {
611 611
 
612 612
 	// si recursif, forcer l'extraction du champ SQL mais ignorer le code
613 613
 	if ($boucles[$idb]->externe) {
614
-		index_pile ($idb, $nom_champ, $boucles,'', $defaut);
614
+		index_pile($idb, $nom_champ, $boucles, '', $defaut);
615 615
 		// retourner $Pile[$SP] et pas $Pile[0] si recursion en 1ere boucle
616 616
 		// on ignore le defaut fourni dans ce cas
617 617
 		$defaut = "@\$Pile[\$SP]['$nom_champ']";
618 618
 	}
619 619
 
620
-	return index_pile($boucles[$idb]->id_parent, $nom_champ, $boucles,'', $defaut);
620
+	return index_pile($boucles[$idb]->id_parent, $nom_champ, $boucles, '', $defaut);
621 621
 }
622 622
 
623 623
 //
@@ -637,9 +637,9 @@  discard block
 block discarded – undo
637 637
 	$b = $p->id_boucle;
638 638
 	$p->code = '';
639 639
 	while ($b != '') {
640
-		foreach($p->boucles[$b]->criteres as $critere) {
640
+		foreach ($p->boucles[$b]->criteres as $critere) {
641 641
 			if ($critere->op == $motif) {
642
-				$p->code = '$Pile[$SP' . (($n==0) ? "" : "-$n") .
642
+				$p->code = '$Pile[$SP'.(($n == 0) ? "" : "-$n").
643 643
 					"]['$champ']";
644 644
 				$b = '';
645 645
 				break 2;
Please login to merge, or discard this patch.
ecrire/public/styliser_par_z.php 1 patch
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
  * @param array $flux
20 20
  * @return array
21 21
  */
22
-function public_styliser_par_z_dist($flux){
23
-	static $prefix_path=null;
22
+function public_styliser_par_z_dist($flux) {
23
+	static $prefix_path = null;
24 24
 	static $prefix_length;
25 25
 	static $z_blocs;
26 26
 	static $apl_constant;
@@ -31,52 +31,52 @@  discard block
 block discarded – undo
31 31
 
32 32
 	if (!isset($prefix_path)) {
33 33
 		$z_blocs = z_blocs(test_espace_prive());
34
-		if (test_espace_prive ()){
34
+		if (test_espace_prive()) {
35 35
 			$prefix_path = "prive/squelettes/";
36 36
 			$prefix_length = strlen($prefix_path);
37 37
 			$apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD';
38 38
 			$page = 'exec';
39
-			$echafauder = charger_fonction('echafauder','prive',true);
40
-			define('_ZCORE_EXCLURE_PATH','');
39
+			$echafauder = charger_fonction('echafauder', 'prive', true);
40
+			define('_ZCORE_EXCLURE_PATH', '');
41 41
 		}
42 42
 		else {
43 43
 			$prefix_path = "";
44 44
 			$prefix_length = 0;
45 45
 			$apl_constant = '_Z_AJAX_PARALLEL_LOAD';
46 46
 			$page = _SPIP_PAGE;
47
-			$echafauder = charger_fonction('echafauder','public',true);
48
-			define('_ZCORE_EXCLURE_PATH','\bprive|\bsquelettes-dist'.(defined('_DIR_PLUGIN_DIST')?'|\b'.rtrim(_DIR_PLUGIN_DIST,'/'):''));
47
+			$echafauder = charger_fonction('echafauder', 'public', true);
48
+			define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist'.(defined('_DIR_PLUGIN_DIST') ? '|\b'.rtrim(_DIR_PLUGIN_DIST, '/') : ''));
49 49
 		}
50
-	  $prepend = (defined('_Z_PREPEND_PATH')?_Z_PREPEND_PATH:"");
50
+	  $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : "");
51 51
 	}
52 52
 	$z_contenu = reset($z_blocs); // contenu par defaut
53 53
 
54 54
 	$fond = $flux['args']['fond'];
55 55
 
56
-	if ($prepend OR strncmp($fond,$prefix_path,$prefix_length)==0) {
56
+	if ($prepend OR strncmp($fond, $prefix_path, $prefix_length) == 0) {
57 57
 		$fond = substr($fond, $prefix_length);
58 58
 		$squelette = $flux['data'];
59 59
 		$ext = $flux['args']['ext'];
60 60
 		// Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax
61 61
 		if (defined('_Z_AJAX_PARALLEL_LOAD_OK')
62
-			AND $dir = explode('/',$fond)
63
-			AND count($dir)==2 // pas un sous repertoire
62
+			AND $dir = explode('/', $fond)
63
+			AND count($dir) == 2 // pas un sous repertoire
64 64
 			AND $dir = reset($dir)
65
-			AND in_array($dir,$z_blocs) // verifier deja qu'on est dans un bloc Z
65
+			AND in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z
66 66
 			AND defined($apl_constant)
67
-			AND in_array($dir,explode(',',constant($apl_constant))) // et dans un demande en APL
68
-			AND $pipe = z_trouver_bloc($prefix_path.$prepend,$dir,'z_apl',$ext) // et qui contient le squelette APL
69
-			){
67
+			AND in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL
68
+			AND $pipe = z_trouver_bloc($prefix_path.$prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL
69
+			) {
70 70
 			$flux['data'] = $pipe;
71 71
 			return $flux;
72 72
 		}
73 73
 
74 74
 		// surcharger aussi les squelettes venant de squelettes-dist/
75
-		if ($squelette AND !z_fond_valide($squelette)){
75
+		if ($squelette AND !z_fond_valide($squelette)) {
76 76
 			$squelette = "";
77 77
 		  $echafauder = "";
78 78
 		}
79
-	  if ($prepend){
79
+	  if ($prepend) {
80 80
 		  $squelette = substr(find_in_path($prefix_path.$prepend."$fond.$ext"), 0, - strlen(".$ext"));
81 81
 	    if ($squelette)
82 82
 		    $flux['data'] = $squelette;
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 		// gerer les squelettes non trouves
86 86
 		// -> router vers les /dist.html
87 87
 		// ou scaffolding ou page automatique les contenus
88
-		if (!$squelette){
88
+		if (!$squelette) {
89 89
 
90 90
 			// si on est sur un ?page=XX non trouve
91 91
 			if ($flux['args']['contexte'][$page] == $fond 
92 92
 				OR $flux['args']['contexte']['type-page'] == $fond
93
-				OR ($fond=='sommaire' AND !$flux['args']['contexte'][$page])) {
93
+				OR ($fond == 'sommaire' AND !$flux['args']['contexte'][$page])) {
94 94
 
95 95
 				// si on est sur un ?page=XX non trouve
96 96
 				// se brancher sur contenu/xx si il existe
97 97
 				// ou si c'est un objet spip, associe a une table, utiliser le fond homonyme
98 98
 				if (!isset($disponible[$fond]))
99
-					$disponible[$fond] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$fond,$ext,$echafauder);
99
+					$disponible[$fond] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $fond, $ext, $echafauder);
100 100
 
101 101
 				if ($disponible[$fond])
102 102
 					$flux['data'] = substr(find_in_path($prefix_path."page.$ext"), 0, - strlen(".$ext"));
@@ -105,43 +105,43 @@  discard block
 block discarded – undo
105 105
 			// echafaudage :
106 106
 			// si c'est un fond de contenu d'un objet en base
107 107
 			// generer un fond automatique a la volee pour les webmestres
108
-			elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu)+1)==0){
109
-				$type = substr($fond,strlen($z_contenu)+1);
110
-				if (($type=='page') AND isset($flux['args']['contexte'][$page]))
108
+			elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) {
109
+				$type = substr($fond, strlen($z_contenu) + 1);
110
+				if (($type == 'page') AND isset($flux['args']['contexte'][$page]))
111 111
 					$type = $flux['args']['contexte'][$page];
112 112
 				if (!isset($disponible[$type]))
113
-					$disponible[$type] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$type,$ext,$echafauder);
113
+					$disponible[$type] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $type, $ext, $echafauder);
114 114
 				if (is_string($disponible[$type])) {
115 115
 					$flux['data'] = $disponible[$type];
116 116
 				}
117 117
 				elseif ($echafauder
118 118
 					AND include_spip('inc/autoriser')
119 119
 					AND isset($GLOBALS['visiteur_session']['statut']) // performance
120
-					AND autoriser('echafauder',$type)
120
+					AND autoriser('echafauder', $type)
121 121
 					AND $is = $disponible[$type]
122 122
 					AND is_array($is)) {
123
-					$flux['data'] = $echafauder($type,$is[0],$is[1],$is[2],$ext);
123
+					$flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext);
124 124
 				}
125
-				else{
126
-					$flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,'404',$ext,$echafauder));
125
+				else {
126
+					$flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, '404', $ext, $echafauder));
127 127
 				}
128 128
 			}
129 129
 
130 130
 			// sinon, si on demande un fond non trouve dans un des autres blocs
131 131
 			// et si il y a bien un contenu correspondant ou echafaudable
132 132
 			// se rabbatre sur le dist.html du bloc concerne
133
-			else{
134
-				if ( $dir = explode('/',$fond)
133
+			else {
134
+				if ($dir = explode('/', $fond)
135 135
 					AND $dir = reset($dir)
136 136
 					AND $dir !== $z_contenu
137
-					AND in_array($dir,$z_blocs)){
138
-					$type = substr($fond,strlen("$dir/"));
139
-					if (($type=='page') AND isset($flux['args']['contexte'][$page]))
137
+					AND in_array($dir, $z_blocs)) {
138
+					$type = substr($fond, strlen("$dir/"));
139
+					if (($type == 'page') AND isset($flux['args']['contexte'][$page]))
140 140
 						$type = $flux['args']['contexte'][$page];
141
-					if ($type!=='page' AND !isset($disponible[$type]))
142
-						$disponible[$type] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$type,$ext,$echafauder);
143
-					if ($type=='page' OR $disponible[$type])
144
-						$flux['data'] = z_trouver_bloc($prefix_path.$prepend,$dir,'dist',$ext);
141
+					if ($type !== 'page' AND !isset($disponible[$type]))
142
+						$disponible[$type] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $type, $ext, $echafauder);
143
+					if ($type == 'page' OR $disponible[$type])
144
+						$flux['data'] = z_trouver_bloc($prefix_path.$prepend, $dir, 'dist', $ext);
145 145
 				}
146 146
 			}
147 147
 			$squelette = $flux['data'];
@@ -151,30 +151,30 @@  discard block
 block discarded – undo
151 151
 		// body-sommaire.html
152 152
 		// pour des raisons de perfo, les declinaisons doivent etre dans le
153 153
 		// meme dossier que body.html
154
-		if ($fond=='body' AND substr($squelette,-strlen($fond))==$fond){
154
+		if ($fond == 'body' AND substr($squelette, -strlen($fond)) == $fond) {
155 155
 			if (isset($flux['args']['contexte']['type-page'])
156 156
 				AND (
157 157
 					(isset($flux['args']['contexte']['composition'])
158
-					AND file_exists(($f=$squelette."-".$flux['args']['contexte']['type-page']."-".$flux['args']['contexte']['composition']).".$ext"))
158
+					AND file_exists(($f = $squelette."-".$flux['args']['contexte']['type-page']."-".$flux['args']['contexte']['composition']).".$ext"))
159 159
 					OR
160
-					file_exists(($f=$squelette."-".$flux['args']['contexte']['type-page']).".$ext")
160
+					file_exists(($f = $squelette."-".$flux['args']['contexte']['type-page']).".$ext")
161 161
 					))
162 162
 				$flux['data'] = $f;
163 163
 		}
164
-		elseif ($fond=='structure' 
164
+		elseif ($fond == 'structure' 
165 165
 			AND z_sanitize_var_zajax()
166 166
 			AND $f = find_in_path($prefix_path.$prepend.'ajax'.".$ext")) {
167
-			$flux['data'] = substr($f,0,-strlen(".$ext"));
167
+			$flux['data'] = substr($f, 0, -strlen(".$ext"));
168 168
 		}
169 169
 		// chercher le fond correspondant a la composition
170 170
 		elseif (isset($flux['args']['contexte']['composition'])
171
-			AND (basename($fond)=='page' OR ($squelette AND substr($squelette,-strlen($fond))==$fond))
172
-			AND $dir = substr($fond,$prefix_length)
173
-			AND $dir = explode('/',$dir)
171
+			AND (basename($fond) == 'page' OR ($squelette AND substr($squelette, -strlen($fond)) == $fond))
172
+			AND $dir = substr($fond, $prefix_length)
173
+			AND $dir = explode('/', $dir)
174 174
 			AND $dir = reset($dir)
175
-			AND in_array($dir,$z_blocs)
176
-			AND $f=find_in_path($prefix_path.$prepend.$fond."-".$flux['args']['contexte']['composition'].".$ext")){
177
-			$flux['data'] = substr($f,0,-strlen(".$ext"));
175
+			AND in_array($dir, $z_blocs)
176
+			AND $f = find_in_path($prefix_path.$prepend.$fond."-".$flux['args']['contexte']['composition'].".$ext")) {
177
+			$flux['data'] = substr($f, 0, -strlen(".$ext"));
178 178
 		}
179 179
 	}
180 180
 	return $flux;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
  * @param bool $espace_prive
187 187
  * @return array
188 188
  */
189
-function z_blocs($espace_prive=false) {
189
+function z_blocs($espace_prive = false) {
190 190
 	if ($espace_prive)
191
-		return (isset($GLOBALS['z_blocs_ecrire'])?$GLOBALS['z_blocs_ecrire']:array('contenu','navigation','extra','head','hierarchie','top'));
192
-	return (isset($GLOBALS['z_blocs'])?$GLOBALS['z_blocs']:array('contenu'));
191
+		return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array('contenu', 'navigation', 'extra', 'head', 'hierarchie', 'top'));
192
+	return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu'));
193 193
 }
194 194
 
195 195
 /**
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
  * @param bool $echafauder
204 204
  * @return mixed
205 205
  */
206
-function z_contenu_disponible($prefix_path,$z_contenu,$type,$ext,$echafauder=true){
207
-	if ($d = z_trouver_bloc($prefix_path,$z_contenu,$type,$ext))
206
+function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) {
207
+	if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext))
208 208
 		return $d;
209
-	return $echafauder?z_echafaudable($type):false;
209
+	return $echafauder ? z_echafaudable($type) : false;
210 210
 }
211 211
 
212
-function z_fond_valide($squelette){
212
+function z_fond_valide($squelette) {
213 213
 	if (!_ZCORE_EXCLURE_PATH
214
-		OR !preg_match(',('._ZCORE_EXCLURE_PATH.')/,',$squelette))
214
+		OR !preg_match(',('._ZCORE_EXCLURE_PATH.')/,', $squelette))
215 215
 		return true;
216 216
   return false;
217 217
 }
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
  *	extension du squelette
233 233
  * @return string
234 234
  */
235
-function z_trouver_bloc($prefix_path,$bloc,$fond,$ext){
235
+function z_trouver_bloc($prefix_path, $bloc, $fond, $ext) {
236 236
 	if (
237 237
 		(defined('_ZCORE_BLOC_PREFIX_SKEL') AND $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") AND z_fond_valide($f))
238 238
 		OR ($f = find_in_path("$prefix_path$bloc/$fond.$ext") AND z_fond_valide($f))
239
-		){
239
+		) {
240 240
 		return substr($f, 0, - strlen(".$ext"));
241 241
 	}
242 242
 	return "";
@@ -249,25 +249,25 @@  discard block
 block discarded – undo
249 249
  * @param string $type
250 250
  * @return bool
251 251
  */
252
-function z_echafaudable($type){
252
+function z_echafaudable($type) {
253 253
 	static $pages = null;
254 254
 	static $echafaudable = array();
255 255
 	if (isset($echafaudable[$type]))
256 256
 		return $echafaudable[$type];
257
-	if (preg_match(',[^\w],',$type))
257
+	if (preg_match(',[^\w],', $type))
258 258
 		return $echafaudable[$type] = false;
259 259
 
260
-	if (test_espace_prive()){
260
+	if (test_espace_prive()) {
261 261
 		if (!function_exists('trouver_objet_exec'))
262 262
 			include_spip('inc/pipelines_ecrire');
263
-		if ($e=trouver_objet_exec($type)){
264
-			return $echafaudable[$type] = array($e['table'],$e['table_objet_sql'],$e);
263
+		if ($e = trouver_objet_exec($type)) {
264
+			return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e);
265 265
 		}
266 266
 		else {
267 267
 			// peut etre c'est un exec=types qui liste tous les objets "type"
268
-			if (($t=objet_type($type,false))!==$type
269
-			  AND $e=trouver_objet_exec($t)){
270
-				return $echafaudable[$type] = array($e['table'],$e['table_objet_sql'],$t);
268
+			if (($t = objet_type($type, false)) !== $type
269
+			  AND $e = trouver_objet_exec($t)) {
270
+				return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t);
271 271
 			}
272 272
 		}
273 273
 	}
@@ -275,13 +275,13 @@  discard block
 block discarded – undo
275 275
 		if (is_null($pages)) {
276 276
 			$pages = array();
277 277
 			$liste = lister_tables_objets_sql();
278
-			foreach($liste as $t=>$d)
279
-				if ($d['page']) $pages[$d['page']] = array($d['table_objet'],$t);
278
+			foreach ($liste as $t=>$d)
279
+				if ($d['page']) $pages[$d['page']] = array($d['table_objet'], $t);
280 280
 		}
281 281
 		if (!isset($pages[$type]))
282 282
 			return $echafaudable[$type] = false;
283
-		if (count($pages[$type])==2){
284
-			$trouver_table = charger_fonction('trouver_table','base');
283
+		if (count($pages[$type]) == 2) {
284
+			$trouver_table = charger_fonction('trouver_table', 'base');
285 285
 			$pages[$type][] = $trouver_table(reset($pages[$type]));
286 286
 		}
287 287
 		return $echafaudable[$type] = $pages[$type];
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
  * @param string $ext
303 303
  * @return string
304 304
  */
305
-function prive_echafauder_dist($exec,$table,$table_sql,$desc_exec,$ext){
305
+function prive_echafauder_dist($exec, $table, $table_sql, $desc_exec, $ext) {
306 306
 	$scaffold = "";
307 307
 
308 308
 	// page objet ou objet_edit
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 		$type = $desc_exec['type'];
311 311
 		$primary = $desc_exec['id_table_objet'];
312 312
 
313
-		if ($desc_exec['edition']===false)
313
+		if ($desc_exec['edition'] === false)
314 314
 			$fond = "objet";
315 315
 		else {
316
-			$trouver_table = charger_fonction('trouver_table','base');
316
+			$trouver_table = charger_fonction('trouver_table', 'base');
317 317
 			$desc = $trouver_table($table_sql);
318 318
 			if (isset($desc['field']['id_rubrique']))
319 319
 				$fond = 'objet_edit';
@@ -325,22 +325,22 @@  discard block
 block discarded – undo
325 325
 		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/".$fond.",objet=".$type.",id_objet=#".strtoupper($primary).",env}>";
326 326
 	}
327 327
 	// page objets
328
-	elseif($type = $desc_exec AND strpos($type,"/")===false){
328
+	elseif ($type = $desc_exec AND strpos($type, "/") === false) {
329 329
 		$dir = z_blocs(test_espace_prive());
330 330
 		$dir = reset($dir);
331 331
 		$scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=".$type.",env} />";
332 332
 	}
333 333
 	// morceau d'objet : on fournit le fond de sibstitution dans $desc_exec
334 334
 	// et objet et tire de $table
335
-	elseif($fond = $desc_exec){
335
+	elseif ($fond = $desc_exec) {
336 336
 		$dir = md5(dirname($fond));
337 337
 		$scaffold = "<INCLURE{fond=$fond,objet=".objet_type($table).",env} />";
338 338
 	}
339 339
 
340
-	$base_dir = sous_repertoire(_DIR_CACHE,"scaffold",false);
341
-	$base_dir = sous_repertoire($base_dir,$dir,false);
340
+	$base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false);
341
+	$base_dir = sous_repertoire($base_dir, $dir, false);
342 342
 	$f = $base_dir."$exec";
343
-	ecrire_fichier("$f.$ext",$scaffold);
343
+	ecrire_fichier("$f.$ext", $scaffold);
344 344
 	return $f;
345 345
 }
346 346
 
@@ -348,11 +348,11 @@  discard block
 block discarded – undo
348 348
  * Recuperer et verifier var_zajax si demande dans l'url
349 349
  * @return bool|string
350 350
  */
351
-function z_sanitize_var_zajax(){
351
+function z_sanitize_var_zajax() {
352 352
 	$z_ajax = _request('var_zajax');
353 353
 	if (!$z_ajax) return false;
354 354
 	if (!$z_blocs = z_blocs(test_espace_prive())
355
-	  OR !in_array($z_ajax,$z_blocs)) {
355
+	  OR !in_array($z_ajax, $z_blocs)) {
356 356
 		set_request('var_zajax'); // enlever cette demande incongrue
357 357
 		$z_ajax = false;
358 358
 	}
Please login to merge, or discard this patch.
ecrire/public/format_html.php 1 patch
Spacing   +34 added lines, -34 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 format_boucle_html ($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof)
15
+function format_boucle_html($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof)
16 16
 {
17 17
 	$avant = $avant ? "<B$nom>$avant" : "";
18 18
 	$apres = $apres ? "$apres</B$nom>" : "";
@@ -21,36 +21,36 @@  discard block
 block discarded – undo
21 21
 	return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern";
22 22
 }
23 23
 
24
-function format_inclure_html ($file, $args, $prof)
24
+function format_inclure_html($file, $args, $prof)
25 25
 {
26
-	if (strpos($file, '#')===false)
27
-	 	$t = $file ? ("(" . $file . ")") : "" ;
26
+	if (strpos($file, '#') === false)
27
+	 	$t = $file ? ("(".$file.")") : "";
28 28
 	else {
29
-		$t = "{fond=" . $file . '}';
29
+		$t = "{fond=".$file.'}';
30 30
 	}
31
-	$args = !$args ? '' : ("{" . join(", ",$args) . "}");
32
-	return ("<INCLURE" . $t . $args  . ">");
31
+	$args = !$args ? '' : ("{".join(", ", $args)."}");
32
+	return ("<INCLURE".$t.$args.">");
33 33
 }
34 34
 
35
-function format_polyglotte_html ($args, $prof)
35
+function format_polyglotte_html($args, $prof)
36 36
 {
37 37
 	$contenu = array(); 
38
-	foreach($args as $l=>$t)
39
-		$contenu[]= ($l ? "[$l]" : '') . $t;
40
-	return ("<multi>" . join(" ", $contenu) . "</multi>");
38
+	foreach ($args as $l=>$t)
39
+		$contenu[] = ($l ? "[$l]" : '').$t;
40
+	return ("<multi>".join(" ", $contenu)."</multi>");
41 41
 }
42 42
 
43
-function format_idiome_html ($nom, $module, $args, $filtres, $prof)
43
+function format_idiome_html($nom, $module, $args, $filtres, $prof)
44 44
 {
45 45
 	foreach ($args as $k => $v) $args[$k] = "$k=$v";
46
-	$args = (!$args ? '' : ('{' . join(',', $args) . '}'));
47
-	return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>");
46
+	$args = (!$args ? '' : ('{'.join(',', $args).'}'));
47
+	return ("<:".($module ? "$module:" : "").$nom.$args.$filtres.":>");
48 48
 }
49 49
 
50
-function format_champ_html ($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof)
50
+function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof)
51 51
 {
52 52
 	$nom = "#"
53
-	. ($boucle ? ($boucle . ":") : "")
53
+	. ($boucle ? ($boucle.":") : "")
54 54
 	. $nom
55 55
 	. $etoile
56 56
 	. $args
@@ -59,62 +59,62 @@  discard block
 block discarded – undo
59 59
 	// Determiner si c'est un champ etendu, 
60 60
 
61 61
 	$s = ($avant OR $apres OR $filtres
62
-	      OR (strpos($args, '(#') !==false));
62
+	      OR (strpos($args, '(#') !== false));
63 63
 
64 64
 	return ($s ? "[$avant($nom)$apres]" : $nom);
65 65
 }
66 66
 
67
-function format_critere_html ($critere)
67
+function format_critere_html($critere)
68 68
 {
69 69
 	foreach ($critere as $k => $crit) {
70 70
 		$crit_s = '';
71 71
 		foreach ($crit as $operande) {
72 72
 			list($type, $valeur) = $operande;
73
-			if ($type == 'champ' AND $valeur[0]=='[') {
74
-			  $valeur = substr($valeur,1,-1);
73
+			if ($type == 'champ' AND $valeur[0] == '[') {
74
+			  $valeur = substr($valeur, 1, -1);
75 75
 			  if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur))
76
-				$valeur = substr($valeur,1,-1);
76
+				$valeur = substr($valeur, 1, -1);
77 77
 			}
78 78
 			$crit_s .= $valeur;
79 79
 		}
80 80
 		$critere[$k] = $crit_s;
81 81
 	}
82
-	return (!$critere ? "" : ("{" . join(",", $critere) . "}"));
82
+	return (!$critere ? "" : ("{".join(",", $critere)."}"));
83 83
 }
84 84
 
85
-function format_liste_html ($fonc, $args, $prof)
85
+function format_liste_html($fonc, $args, $prof)
86 86
 {
87
-	return ((($fonc!=='') ? "|$fonc" : $fonc)
88
-	. (!$args ? "" : ("{" . join(",", $args) . "}")));
87
+	return ((($fonc !== '') ? "|$fonc" : $fonc)
88
+	. (!$args ? "" : ("{".join(",", $args)."}")));
89 89
 }
90 90
 
91 91
 // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes
92
-function format_suite_html ($args)
92
+function format_suite_html($args)
93 93
 {
94
-	for($i=0; $i < count($args)-1; $i++) {
94
+	for ($i = 0; $i < count($args) - 1; $i++) {
95 95
 		list($texte, $type) = $args[$i];
96
-		list($texte2, $type2) = $args[$i+1];
96
+		list($texte2, $type2) = $args[$i + 1];
97 97
 		if (!$texte OR !$texte2) continue; 
98
-		$c1 = substr($texte,-1);
98
+		$c1 = substr($texte, -1);
99 99
 		if ($type2 !== 'texte') {
100 100
 		  // si un texte se termine par ( et est suivi d'un champ
101 101
 		  // ou assimiles, forcer la notation pleine
102
-			if ($c1 == '(' AND substr($texte2,0,1) == '#')
103
-				$args[$i+1][0] = '[(' . $texte2 . ')]';
102
+			if ($c1 == '(' AND substr($texte2, 0, 1) == '#')
103
+				$args[$i + 1][0] = '[('.$texte2.')]';
104 104
 		} else {
105 105
 			if ($type == 'texte') continue;
106 106
 			// si un champ ou assimiles est suivi d'un texte
107 107
 			// et si celui-ci commence par un caractere de champ
108 108
 			// forcer la notation pleine
109
-			if (($c1 == '}' AND substr(ltrim($texte2),0,1) == '|')
109
+			if (($c1 == '}' AND substr(ltrim($texte2), 0, 1) == '|')
110 110
 			OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2)))
111
-				$args[$i][0] = '[(' . $texte . ')]';
111
+				$args[$i][0] = '[('.$texte.')]';
112 112
 		}
113 113
 	}
114 114
 	return join("", array_map('array_shift', $args));
115 115
 }
116 116
 
117
-function format_texte_html ($texte)
117
+function format_texte_html($texte)
118 118
 {
119 119
 	return $texte;
120 120
 }
Please login to merge, or discard this patch.
ecrire/public/compiler.php 1 patch
Spacing   +167 added lines, -175 removed lines patch added patch discarded remove patch
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
 
58 58
 
59 59
 // http://doc.spip.org/@argumenter_inclure
60
-function argumenter_inclure($params, $rejet_filtres, $p, &$boucles, $id_boucle, $echap=true, $lang = '', $fond1=false){
60
+function argumenter_inclure($params, $rejet_filtres, $p, &$boucles, $id_boucle, $echap = true, $lang = '', $fond1 = false) {
61 61
 	$l = array();
62 62
 	$erreur_p_i_i = '';
63 63
 	if (!is_array($params)) return $l;
64
-	foreach($params as $k => $couple) {
64
+	foreach ($params as $k => $couple) {
65 65
 	// la liste d'arguments d'inclusion peut se terminer par un filtre
66 66
 		$filtre = array_shift($couple);
67 67
 		if ($filtre) break;
68
-		foreach($couple as $n => $val) {
68
+		foreach ($couple as $n => $val) {
69 69
 			$var = $val[0];
70 70
 			if ($var->type != 'texte') {
71 71
 			  if ($n OR $k OR $fond1) {
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 			  }
77 77
 			  else $l[1] = calculer_liste($val, $p->descr, $boucles, $id_boucle);
78 78
 			} else {
79
-				preg_match(",^([^=]*)(=?)(.*)$,m", $var->texte,$m);
79
+				preg_match(",^([^=]*)(=?)(.*)$,m", $var->texte, $m);
80 80
 				$var = $m[1];
81
-				$auto = false;;
81
+				$auto = false; ;
82 82
 				if ($m[2]) {
83 83
 				  $v = $m[3];
84 84
 				  if (preg_match(',^[\'"](.*)[\'"]$,', $v, $m)) $v = $m[1];
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 				    ? index_pile($id_boucle, $var, $boucles)
98 98
 				    : calculer_liste($val, $p->descr, $boucles, $id_boucle);
99 99
 				  if ($var !== 1)
100
-				    $val = ($echap?"\'$var\' => ' . argumenter_squelette(":"'$var' => ")
101
-				    . $val . ($echap? ") . '":" ");
100
+				    $val = ($echap ? "\'$var\' => ' . argumenter_squelette(" : "'$var' => ")
101
+				    . $val.($echap ? ") . '" : " ");
102 102
 				  else $val = $echap ? "'.$val.'" : $val;
103 103
 				  $l[$var] = $val;
104 104
 				}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	// sauf si on n'en veut pas 
112 112
 	if ($lang === false) return $l;
113 113
 	if (!$lang) $lang = '$GLOBALS["spip_lang"]';
114
-	$l['lang'] = ($echap?"\'lang\' => ' . argumenter_squelette(":"'lang' => ")  . $lang . ($echap?") . '":" ");
114
+	$l['lang'] = ($echap ? "\'lang\' => ' . argumenter_squelette(" : "'lang' => ").$lang.($echap ? ") . '" : " ");
115 115
 
116 116
 	return $l;
117 117
 }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	$_contexte = argumenter_inclure($p->param, false, $p, $boucles, $id_boucle, true, '', true);
141 141
 	if (is_string($p->texte)) {
142 142
 		$fichier = $p->texte;
143
-		$code = "\"".str_replace('"','\"',$fichier)."\"";
143
+		$code = "\"".str_replace('"', '\"', $fichier)."\"";
144 144
 
145 145
 	} else {
146 146
 		$code = calculer_liste($p->texte, $p->descr, $boucles, $id_boucle);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 	if (is_array($_contexte)) {
160 160
 		// Critere d'inclusion {env} (et {self} pour compatibilite ascendante)
161
-		if ($env = (isset($_contexte['env'])|| isset($_contexte['self']))) {
161
+		if ($env = (isset($_contexte['env']) || isset($_contexte['self']))) {
162 162
 			unset($_contexte['env']);
163 163
 		}
164 164
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 			$_contexte['doublons'] = "\\'doublons\\' => '.var_export(\$doublons,true).'";
168 168
 		}
169 169
 
170
-		if ($ajax = isset($_contexte['ajax'])){
171
-			$ajax = preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']);
170
+		if ($ajax = isset($_contexte['ajax'])) {
171
+			$ajax = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
172 172
 			unset($_contexte['ajax']);
173 173
 		}
174 174
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	else
178 178
 		return false; // j'aurais voulu toucher le fond ...
179 179
 		
180
-	$contexte = 'array(' . $_contexte  .')';
180
+	$contexte = 'array('.$_contexte.')';
181 181
 
182 182
 	if ($env) {
183 183
 		$contexte = "array_merge('.var_export(\$Pile[0],1).',$contexte)";
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 	// s'il y a une extension .php, ce n'est pas un squelette
187 187
 	if ($fichier and preg_match('/^.+[.]php$/s', $fichier)) {
188 188
 		$code = sandbox_composer_inclure_php($fichier, $p, $contexte);
189
-	} else 	{
189
+	} else {
190 190
 		$_options[] = "\"compil\"=>array($compil)";
191 191
 		if ($ajax)
192 192
 			$_options[] = $ajax;
193 193
 		$code = " ' . argumenter_squelette($code) . '"; 
194
-		$code = "echo " . sprintf(CODE_RECUPERER_FOND, $code, $contexte, implode(',',$_options), "_request(\"connect\")") . ';';
194
+		$code = "echo ".sprintf(CODE_RECUPERER_FOND, $code, $contexte, implode(',', $_options), "_request(\"connect\")").';';
195 195
 	}
196 196
 
197
-	return	"\n'<'.'".	"?php ". $code . "\n?'." . "'>'";
197
+	return	"\n'<'.'"."?php ".$code."\n?'."."'>'";
198 198
 }
199 199
 
200 200
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
  * @param bool $ignore_previsu
212 212
  *     true pour ne tester que le cas publie et ignorer l'eventuel var_mode=preview de la page
213 213
  */
214
-function instituer_boucle(&$boucle, $echapper=true, $ignore_previsu=false){
214
+function instituer_boucle(&$boucle, $echapper = true, $ignore_previsu = false) {
215 215
 	/*
216 216
 	$show['statut'][] = array(
217 217
 		'champ'=>'statut',  // champ de la table sur lequel porte le filtrage par le statut
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 */
239 239
 	$id_table = $boucle->id_table;
240 240
 	$show = $boucle->show;
241
-	if (isset($show['statut']) AND $show['statut']){
242
-		foreach($show['statut'] as $k=>$s){
241
+	if (isset($show['statut']) AND $show['statut']) {
242
+		foreach ($show['statut'] as $k=>$s) {
243 243
 			// Restreindre aux elements publies si pas de {statut} ou autre dans les criteres
244 244
 			$filtrer = true;
245 245
 			if (isset($s['exception'])) {
246
-				foreach(is_array($s['exception'])?$s['exception']:array($s['exception']) as $m) {
246
+				foreach (is_array($s['exception']) ? $s['exception'] : array($s['exception']) as $m) {
247 247
 					if (isset($boucle->modificateur[$m]) OR isset($boucle->modificateur['criteres'][$m])) {
248 248
 						$filtrer = false;
249 249
 						break;
@@ -252,19 +252,19 @@  discard block
 block discarded – undo
252 252
 			}
253 253
 
254 254
 			if ($filtrer) {
255
-				if (is_array($s['champ'])){
256
-					$statut = preg_replace(',\W,','',array_pop($s['champ'])); // securite
255
+				if (is_array($s['champ'])) {
256
+					$statut = preg_replace(',\W,', '', array_pop($s['champ'])); // securite
257 257
 					$jointures = array();
258 258
 					// indiquer la description de chaque table dans le tableau de jointures,
259 259
 					// ce qui permet d'eviter certains GROUP BY inutiles.
260 260
 					$trouver_table = charger_fonction('trouver_table', 'base');
261
-					foreach($s['champ'] as $j) {
261
+					foreach ($s['champ'] as $j) {
262 262
 						$id = reset($j);
263 263
 						$def = $trouver_table($id);
264
-						$jointures[] = array('',array($id,$def),end($j));
264
+						$jointures[] = array('', array($id, $def), end($j));
265 265
 					}
266 266
 					$jointures[0][0] = $id_table;
267
-					if (!array_search($id, $boucle->from)){
267
+					if (!array_search($id, $boucle->from)) {
268 268
 						include_spip('public/jointures');
269 269
 						fabrique_jointures($boucle, $jointures, true, $boucle->show, $id_table, '', $echapper);
270 270
 					}
@@ -273,20 +273,20 @@  discard block
 block discarded – undo
273 273
 				}
274 274
 				else {
275 275
 					$id = $id_table;
276
-					$statut = preg_replace(',\W,','',$s['champ']); // securite
276
+					$statut = preg_replace(',\W,', '', $s['champ']); // securite
277 277
 				}
278
-				$mstatut = $id .'.'.$statut;
278
+				$mstatut = $id.'.'.$statut;
279 279
 
280
-				$arg_ignore_previsu=($ignore_previsu?",true":'');
280
+				$arg_ignore_previsu = ($ignore_previsu ? ",true" : '');
281 281
 				include_spip('public/quete');
282 282
 				if (isset($s['post_date']) AND $s['post_date']
283
-					AND $GLOBALS['meta']["post_dates"] == 'non'){
284
-					$date = $id.'.'.preg_replace(',\W,','',$s['post_date']); // securite
283
+					AND $GLOBALS['meta']["post_dates"] == 'non') {
284
+					$date = $id.'.'.preg_replace(',\W,', '', $s['post_date']); // securite
285 285
 					array_unshift($boucle->where,
286 286
 						$echapper ?
287 287
 							"\nquete_condition_postdates('$date',"._q($boucle->sql_serveur)."$arg_ignore_previsu)"
288 288
 						:
289
-							quete_condition_postdates($date,$boucle->sql_serveur,$ignore_previsu)
289
+							quete_condition_postdates($date, $boucle->sql_serveur, $ignore_previsu)
290 290
 					);
291 291
 				}
292 292
 				array_unshift($boucle->where,
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 							._q($s['publie']).","
297 297
 							._q($boucle->sql_serveur)."$arg_ignore_previsu)"
298 298
 					:
299
-						quete_condition_statut($mstatut,$s['previsu'],$s['publie'],$boucle->sql_serveur,$ignore_previsu)
299
+						quete_condition_statut($mstatut, $s['previsu'], $s['publie'], $boucle->sql_serveur, $ignore_previsu)
300 300
 				);
301 301
 			}
302 302
 		}
@@ -325,10 +325,10 @@  discard block
 block discarded – undo
325 325
 
326 326
 	// en mode debug memoriser les premiers passages dans la boucle,
327 327
 	// mais pas tous, sinon ca pete.
328
-	if  (_request('var_mode_affiche') != 'resultat') 
328
+	if (_request('var_mode_affiche') != 'resultat') 
329 329
 		$trace = '';
330 330
 	else {
331
-		$trace = $boucles[$id_boucle]->descr['nom'] . $id_boucle;
331
+		$trace = $boucles[$id_boucle]->descr['nom'].$id_boucle;
332 332
 		$trace = "if (count(@\$GLOBALS['debug_objets']['resultat']['$trace'])<3)
333 333
 	    \$GLOBALS['debug_objets']['resultat']['$trace'][] = \$t0;";
334 334
 	}
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	return
362 362
 	  // Numrows[$nom] peut ne pas être encore defini
363 363
 	  "\n\t\$save_numrows = (isset(\$Numrows['$nom']) ? \$Numrows['$nom'] : array());"
364
-	. "\n\t\$t0 = " . $boucles[$id_boucle]->return . ";"
364
+	. "\n\t\$t0 = ".$boucles[$id_boucle]->return.";"
365 365
 	. "\n\t\$Numrows['$nom'] = (\$save_numrows);"
366 366
 	. $trace
367 367
 	. "\n\treturn \$t0;";
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
 	$return = $boucle->return;
422 422
 	$type_boucle = $boucle->type_requete;
423 423
 	$primary = $boucle->primary;
424
-	$constant = preg_match(CODE_MONOTONE, str_replace("\\'",'', $return));
425
-	$flag_cpt = $boucle->mode_partie ||$boucle->cptrows;
424
+	$constant = preg_match(CODE_MONOTONE, str_replace("\\'", '', $return));
425
+	$flag_cpt = $boucle->mode_partie || $boucle->cptrows;
426 426
 	$corps = '';
427 427
 
428 428
 	// faudrait expanser le foreach a la compil, car y en a souvent qu'un 
429 429
 	// et puis faire un [] plutot qu'un "','."
430 430
 	if ($boucle->doublons)
431
-		$corps .= "\n\t\t\tforeach(" . $boucle->doublons . ' as $k) $doublons[$k] .= "," . ' .
431
+		$corps .= "\n\t\t\tforeach(".$boucle->doublons.' as $k) $doublons[$k] .= "," . '.
432 432
 		index_pile($id_boucle, $primary, $boucles)
433 433
 		. "; // doublons\n";
434 434
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	//    (sauf si forcer_lang==true ou si le titre contient <multi>).
438 438
 	// - a moins d'une demande explicite via {!lang_select}
439 439
 	if (!$constant && $boucle->lang_select != 'non' &&
440
-	    (($boucle->lang_select == 'oui')  ||
440
+	    (($boucle->lang_select == 'oui') ||
441 441
 		    in_array($type_boucle, array(
442 442
 		    	'articles', 'rubriques', 'hierarchie', 'breves'
443 443
 			)))
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 		if (strpos($return, '?php') === false
466 466
 		AND preg_match_all("/\W(_T[(]'[^']*'[)])/", $return, $r)) {
467 467
 			$i = 1;
468
-			foreach($r[1] as $t) {
468
+			foreach ($r[1] as $t) {
469 469
 				$init_lang .= "\n\t\$l$i = $t;";
470 470
 				$return = str_replace($t, "\$l$i", $return);
471 471
 				$i++;
@@ -475,19 +475,15 @@  discard block
 block discarded – undo
475 475
 
476 476
 	// gestion optimale des separateurs et des boucles constantes
477 477
 	if (count($boucle->separateur))
478
-	  $code_sep = ("'" . str_replace("'","\'",join('',$boucle->separateur)) . "'");
478
+	  $code_sep = ("'".str_replace("'", "\'", join('', $boucle->separateur))."'");
479 479
 
480 480
 	$corps .= 
481 481
 		((!$boucle->separateur) ? 
482
-			(($constant && !$corps && !$flag_cpt) ? $return :
483
-			 (($return==="''") ? '' :
484
-			  ("\n\t\t" . '$t0 .= ' . $return . ";"))) :
485
-		 ("\n\t\t\$t1 " .
482
+			(($constant && !$corps && !$flag_cpt) ? $return : (($return === "''") ? '' : ("\n\t\t".'$t0 .= '.$return.";"))) : ("\n\t\t\$t1 ".
486 483
 			((strpos($return, '$t1.') === 0) ? 
487
-			 (".=" . substr($return,4)) :
488
-			 ('= ' . $return)) .
489
-		  ";\n\t\t" .
490
-		  '$t0 .= ((strlen($t1) && strlen($t0)) ? ' . $code_sep . " : '') . \$t1;"));
484
+			 (".=".substr($return, 4)) : ('= '.$return)).
485
+		  ";\n\t\t".
486
+		  '$t0 .= ((strlen($t1) && strlen($t0)) ? '.$code_sep." : '') . \$t1;"));
491 487
      
492 488
 	// Calculer les invalideurs si c'est une boucle non constante et si on
493 489
 	// souhaite invalider ces elements
@@ -510,7 +506,7 @@  discard block
 block discarded – undo
510 506
 
511 507
 	// si le corps est une constante, ne pas appeler le serveur N fois!
512 508
 
513
-	if (preg_match(CODE_MONOTONE,str_replace("\\'",'',$corps), $r)) {
509
+	if (preg_match(CODE_MONOTONE, str_replace("\\'", '', $corps), $r)) {
514 510
 		if (!isset($r[2]) OR (!$r[2])) {
515 511
 			if (!$boucle->numrows)
516 512
 				return "\n\t\$t0 = '';";
@@ -527,7 +523,7 @@  discard block
 block discarded – undo
527 523
 		if (!$boucle->numrows OR $boucle->limit OR $boucle->mode_partie OR $boucle->group)
528 524
 			$count = '1';
529 525
 		else $count = 'count(*)';
530
-		$boucles[$id_boucle]->select[]= $count; 
526
+		$boucles[$id_boucle]->select[] = $count; 
531 527
 	}
532 528
 
533 529
 	if ($flag_cpt)
@@ -560,7 +556,7 @@  discard block
 block discarded – undo
560 556
 		$corps,
561 557
 		$fin_lang,
562 558
 		$trace,
563
-		'BOUCLE'.$id_boucle .' @ '.($boucle->descr['sourcefile'])
559
+		'BOUCLE'.$id_boucle.' @ '.($boucle->descr['sourcefile'])
564 560
 	);
565 561
 
566 562
 #	var_dump($a);exit;
@@ -582,14 +578,14 @@  discard block
 block discarded – undo
582 578
 function calculer_requete_sql($boucle)
583 579
 {
584 580
 	$init = array();
585
-	$init[] = calculer_dec('table',  "'" . $boucle->id_table ."'");
586
-	$init[] = calculer_dec('id', "'" . $boucle->id_boucle ."'");
581
+	$init[] = calculer_dec('table', "'".$boucle->id_table."'");
582
+	$init[] = calculer_dec('id', "'".$boucle->id_boucle."'");
587 583
 	# En absence de champ c'est un decompte :
588
-	$init[] = calculer_dec('from',  calculer_from($boucle));
584
+	$init[] = calculer_dec('from', calculer_from($boucle));
589 585
 	$init[] = calculer_dec('type', calculer_from_type($boucle));
590
-	$init[] = calculer_dec('groupby', 'array(' . (($g=join("\",\n\t\t\"",$boucle->group))?'"'.$g.'"':'') . ")");
591
-	$init[] = calculer_dec('select', 'array("' . join("\",\n\t\t\"", $boucle->select).  "\")");
592
-	$init[] = calculer_dec('orderby', 'array(' . calculer_order($boucle) .	")");
586
+	$init[] = calculer_dec('groupby', 'array('.(($g = join("\",\n\t\t\"", $boucle->group)) ? '"'.$g.'"' : '').")");
587
+	$init[] = calculer_dec('select', 'array("'.join("\",\n\t\t\"", $boucle->select)."\")");
588
+	$init[] = calculer_dec('orderby', 'array('.calculer_order($boucle).")");
593 589
 	$init[] = calculer_dec('where', calculer_dump_array($boucle->where));
594 590
 	$init[] = calculer_dec('join', calculer_dump_join($boucle->join));
595 591
 	$init[] = calculer_dec('limit',
@@ -599,7 +595,7 @@  discard block
 block discarded – undo
599 595
 				  $boucle->limit));
600 596
 	$init[] = calculer_dec('having', calculer_dump_array($boucle->having));
601 597
 	$s = $d = "";
602
-	foreach ($init as $i){
598
+	foreach ($init as $i) {
603 599
 		if (reset($i))
604 600
 			$s .= "\n\t\t".end($i);
605 601
 		else
@@ -683,22 +679,22 @@  discard block
 block discarded – undo
683 679
 	)
684 680
 		$static = "";
685 681
 
686
-	return array($static,'$command[\''.$nom.'\'] = ' . $val . ';');
682
+	return array($static, '$command[\''.$nom.'\'] = '.$val.';');
687 683
 }
688 684
 
689 685
 // http://doc.spip.org/@calculer_dump_array
690 686
 function calculer_dump_array($a)
691 687
 {
692
-  if (!is_array($a)) return $a ;
688
+  if (!is_array($a)) return $a;
693 689
   $res = "";
694 690
   if ($a AND $a[0] == "'?'") 
695
-    return ("(" . calculer_dump_array($a[1]) .
696
-	    " ? " . calculer_dump_array($a[2]) .
697
-	    " : " . calculer_dump_array($a[3]) .
691
+    return ("(".calculer_dump_array($a[1]).
692
+	    " ? ".calculer_dump_array($a[2]).
693
+	    " : ".calculer_dump_array($a[3]).
698 694
 	    ")");
699 695
   else {
700
-    foreach($a as $v) $res .= ", " . calculer_dump_array($v);
701
-    return "\n\t\t\tarray(" . substr($res,2) . ')';
696
+    foreach ($a as $v) $res .= ", ".calculer_dump_array($v);
697
+    return "\n\t\t\tarray(".substr($res, 2).')';
702 698
   }
703 699
 }
704 700
 
@@ -706,25 +702,25 @@  discard block
 block discarded – undo
706 702
 function calculer_dump_join($a)
707 703
 {
708 704
   $res = "";
709
-  foreach($a as $k => $v) 
710
-		$res .= ", '$k' => array(".implode(',',$v).")";
711
-  return 'array(' . substr($res,2) . ')';
705
+  foreach ($a as $k => $v) 
706
+		$res .= ", '$k' => array(".implode(',', $v).")";
707
+  return 'array('.substr($res, 2).')';
712 708
 }
713 709
 
714 710
 // http://doc.spip.org/@calculer_from
715 711
 function calculer_from(&$boucle)
716 712
 {
717 713
   $res = "";
718
-  foreach($boucle->from as $k => $v) $res .= ",'$k' => '$v'";
719
-  return 'array(' . substr($res,1) . ')';
714
+  foreach ($boucle->from as $k => $v) $res .= ",'$k' => '$v'";
715
+  return 'array('.substr($res, 1).')';
720 716
 }
721 717
 
722 718
 // http://doc.spip.org/@calculer_from_type
723 719
 function calculer_from_type(&$boucle)
724 720
 {
725 721
   $res = "";
726
-  foreach($boucle->from_type as $k => $v) $res .= ",'$k' => '$v'";
727
-  return 'array(' . substr($res,1) . ')';
722
+  foreach ($boucle->from_type as $k => $v) $res .= ",'$k' => '$v'";
723
+  return 'array('.substr($res, 1).')';
728 724
 }
729 725
 
730 726
 // http://doc.spip.org/@calculer_order
@@ -749,7 +745,7 @@  discard block
 block discarded – undo
749 745
 // (qui sera argument d'un Return ou la partie droite d'une affectation).
750 746
 
751 747
 // http://doc.spip.org/@calculer_liste
752
-function calculer_liste($tableau, $descr, &$boucles, $id_boucle='') {
748
+function calculer_liste($tableau, $descr, &$boucles, $id_boucle = '') {
753 749
 	if (!$tableau) return "''";
754 750
 	if (!isset($descr['niv'])) $descr['niv'] = 0;
755 751
 	$codes = compile_cas($tableau, $descr, $boucles, $id_boucle);
@@ -758,28 +754,28 @@  discard block
 block discarded – undo
758 754
 	if (!$n) return "''";
759 755
 	$tab = str_repeat("\t", $descr['niv']);
760 756
 	if (_request('var_mode_affiche') != 'validation') {
761
-		if ($n==1) 
757
+		if ($n == 1) 
762 758
 			return $codes[0];
763 759
 		else {
764 760
 			$res = '';
765
-			foreach($codes as $code) {
761
+			foreach ($codes as $code) {
766 762
 				if (!preg_match("/^'[^']*'$/", $code)
767
-				OR substr($res,-1,1)!=="'")
768
-				  $res .=  " .\n$tab$code";
763
+				OR substr($res, -1, 1) !== "'")
764
+				  $res .= " .\n$tab$code";
769 765
 				else {
770
-				  $res = substr($res,0,-1) . substr($code,1);
766
+				  $res = substr($res, 0, -1).substr($code, 1);
771 767
 				}
772 768
 			}
773
-			return '(' . substr($res,2+$descr['niv']) . ')';
769
+			return '('.substr($res, 2 + $descr['niv']).')';
774 770
 		}
775 771
 	} else {
776
-	  $nom = $descr['nom'] . $id_boucle .  ($descr['niv']?$descr['niv']:'');
777
-	  return "join('', array_map('array_shift', \$GLOBALS['debug_objets']['sequence']['$nom'] = array(" .  join(" ,\n$tab", $codes) . ")))";
772
+	  $nom = $descr['nom'].$id_boucle.($descr['niv'] ? $descr['niv'] : '');
773
+	  return "join('', array_map('array_shift', \$GLOBALS['debug_objets']['sequence']['$nom'] = array(".join(" ,\n$tab", $codes).")))";
778 774
 	}
779 775
 }
780 776
 
781
-define('_REGEXP_COND_VIDE_NONVIDE',"/^[(](.*)[?]\s*''\s*:\s*('[^']+')\s*[)]$/");
782
-define('_REGEXP_COND_NONVIDE_VIDE',"/^[(](.*)[?]\s*('[^']+')\s*:\s*''\s*[)]$/");
777
+define('_REGEXP_COND_VIDE_NONVIDE', "/^[(](.*)[?]\s*''\s*:\s*('[^']+')\s*[)]$/");
778
+define('_REGEXP_COND_NONVIDE_VIDE', "/^[(](.*)[?]\s*('[^']+')\s*:\s*''\s*[)]$/");
783 779
 define('_REGEXP_CONCAT_NON_VIDE', "/^(.*)[.]\s*'[^']+'\s*$/");
784 780
 
785 781
 // http://doc.spip.org/@compile_cas
@@ -797,31 +793,31 @@  discard block
 block discarded – undo
797 793
 	// par un caractere distinguant le cas, pour exploitation par debug.
798 794
 	foreach ($tableau as $p) {
799 795
 
800
-		switch($p->type) {
796
+		switch ($p->type) {
801 797
 		// texte seul
802 798
 		case 'texte':
803 799
 			$code = sandbox_composer_texte($p->texte, $p);
804
-			$commentaire= strlen($p->texte) . " signes";
805
-			$avant='';
806
-			$apres='';
800
+			$commentaire = strlen($p->texte)." signes";
801
+			$avant = '';
802
+			$apres = '';
807 803
 			$altern = "''";
808 804
 			break;
809 805
 
810 806
 		case 'polyglotte':
811 807
 			$code = "";
812
-			foreach($p->traductions as $k => $v) {
813
-			  $code .= ",'" .
814
-			    str_replace(array("\\","'"),array("\\\\","\\'"), $k) .
815
-			    "' => '" .
816
-			    str_replace(array("\\","'"),array("\\\\","\\'"), $v) .
808
+			foreach ($p->traductions as $k => $v) {
809
+			  $code .= ",'".
810
+			    str_replace(array("\\", "'"), array("\\\\", "\\'"), $k).
811
+			    "' => '".
812
+			    str_replace(array("\\", "'"), array("\\\\", "\\'"), $v).
817 813
 			    "'";
818 814
 			}
819
-			$code = "choisir_traduction(array(" .
820
- 			  substr($code,1) .
815
+			$code = "choisir_traduction(array(".
816
+ 			  substr($code, 1).
821 817
 			  "))";
822
-			$commentaire= '&';
823
-			$avant='';
824
-			$apres='';
818
+			$commentaire = '&';
819
+			$avant = '';
820
+			$apres = '';
825 821
 			$altern = "''";
826 822
 			break;
827 823
 
@@ -833,9 +829,9 @@  discard block
 block discarded – undo
833 829
 				$err_e_c = true;
834 830
 				$code = "''";
835 831
 			} else {
836
-				$commentaire = '<INCLURE ' . addslashes(str_replace("\n", ' ', $code)) . '>';
837
-				$avant='';
838
-				$apres='';
832
+				$commentaire = '<INCLURE '.addslashes(str_replace("\n", ' ', $code)).'>';
833
+				$avant = '';
834
+				$apres = '';
839 835
 				$altern = "''";
840 836
 			}
841 837
 			break;
@@ -857,14 +853,14 @@  discard block
 block discarded – undo
857 853
 				$err_e_c = true;
858 854
 				$code = "''";
859 855
 			} else {
860
-				$code = 'BOUCLE' .
861
-				  str_replace("-","_", $nom) . $descr['nom'] .
856
+				$code = 'BOUCLE'.
857
+				  str_replace("-", "_", $nom).$descr['nom'].
862 858
 				  '($Cache, $Pile, $doublons, $Numrows, $SP)';
863
-				$commentaire= "?$nom";
859
+				$commentaire = "?$nom";
864 860
 				if (!$boucles[$nom]->milieu
865 861
 				AND $boucles[$nom]->type_requete <> TYPE_RECURSIF) {
866 862
 					if ($altern != "''") $code .= "\n. $altern";
867
-					if ($avant<>"''" OR $apres<>"''")
863
+					if ($avant <> "''" OR $apres <> "''")
868 864
 					  spip_log("boucle $nom toujours vide, code superflu dans $id");
869 865
 					$avant = $apres = $altern = "''";
870 866
 				} else if ($altern != "''") $altern = "($altern)";
@@ -877,23 +873,21 @@  discard block
 block discarded – undo
877 873
 			foreach ($p->arg as $k => $v) {
878 874
 			  	$_v = calculer_liste($v, $descr, $boucles, $id_boucle);
879 875
 				if ($k) {
880
-					$l[] = _q($k) . ' => ' . $_v;
876
+					$l[] = _q($k).' => '.$_v;
881 877
 				} else {
882 878
 					$code = $_v;
883 879
 				}
884 880
 			}
885 881
 			// Si le module n'est pas fourni, l'expliciter sauf si calculé
886 882
 			if ($p->module) {
887
-				$m = $p->module .':'.$p->nom_champ;
883
+				$m = $p->module.':'.$p->nom_champ;
888 884
 			} elseif ($p->nom_champ) {
889
-				$m = MODULES_IDIOMES .':'.$p->nom_champ;
885
+				$m = MODULES_IDIOMES.':'.$p->nom_champ;
890 886
 			} else {
891 887
 				$m = '';
892 888
 			}
893
-			$code = (!$code ? "'$m'" :
894
-						($m ? "'$m' . $code" :
895
-							("(strpos(\$x=$code, ':') ? \$x : ('" . MODULES_IDIOMES . ":' . \$x))")))
896
-					. (!$l ? '' : (", array(" . implode(",\n", $l) . ")"));
889
+			$code = (!$code ? "'$m'" : ($m ? "'$m' . $code" : ("(strpos(\$x=$code, ':') ? \$x : ('".MODULES_IDIOMES.":' . \$x))")))
890
+					. (!$l ? '' : (", array(".implode(",\n", $l).")"));
897 891
 			$code = "_T($code)";
898 892
 			if ($p->param) {
899 893
 				$p->id_boucle = $id_boucle;
@@ -901,8 +895,8 @@  discard block
 block discarded – undo
901 895
 				$code = compose_filtres($p, $code);
902 896
 			}
903 897
 			$commentaire = ":";
904
-			$avant='';
905
-			$apres='';
898
+			$avant = '';
899
+			$apres = '';
906 900
 			$altern = "''";
907 901
 			break;
908 902
 
@@ -916,7 +910,7 @@  discard block
 block discarded – undo
916 910
 			$p->type_requete = $type;
917 911
 
918 912
 			$code = calculer_champ($p);
919
-			$commentaire = '#' . $p->nom_champ . $p->etoile;
913
+			$commentaire = '#'.$p->nom_champ.$p->etoile;
920 914
 			$avant = calculer_liste($p->avant,
921 915
 				$descr, $boucles, $id_boucle);
922 916
 			$apres = calculer_liste($p->apres,
@@ -926,7 +920,7 @@  discard block
 block discarded – undo
926 920
 			// forcer la conversion en une chaine par strval
927 921
 			// si ca peut etre autre chose qu'une chaine
928 922
 			if (($avant != "''" OR $apres != "''")
929
-			AND $code[0]!= "'"
923
+			AND $code[0] != "'"
930 924
 #			AND (strpos($code,'interdire_scripts') !== 0)
931 925
 			AND !preg_match(_REGEXP_COND_VIDE_NONVIDE, $code)
932 926
 			AND !preg_match(_REGEXP_COND_NONVIDE_VIDE, $code)
@@ -944,11 +938,10 @@  discard block
 block discarded – undo
944 938
 
945 939
 		if ($code != "''") {
946 940
 			$code = compile_retour($code, $avant, $apres, $altern, $tab, $descr['niv']);
947
-			$codes[]= (($mode == 'validation') ?
948
-				"array($code, '$commentaire', " . $p->ligne . ")"
941
+			$codes[] = (($mode == 'validation') ?
942
+				"array($code, '$commentaire', ".$p->ligne.")"
949 943
 				: (($mode == 'code') ?
950
-				"\n// $commentaire\n$code" :
951
-				$code));
944
+				"\n// $commentaire\n$code" : $code));
952 945
 		}
953 946
 	} // foreach
954 947
 
@@ -964,24 +957,24 @@  discard block
 block discarded – undo
964 957
 {
965 958
 	if ($avant == "''") $avant = '';
966 959
 	if ($apres == "''") $apres = '';
967
-	if (!$avant AND !$apres AND ($altern==="''")) return $code;
960
+	if (!$avant AND !$apres AND ($altern === "''")) return $code;
968 961
 
969 962
 	if (preg_match(_REGEXP_CONCAT_NON_VIDE, $code)) {
970 963
 		$t = $code;
971 964
 		$cond = '';
972
-	} elseif (preg_match(_REGEXP_COND_VIDE_NONVIDE,$code, $r)) {
965
+	} elseif (preg_match(_REGEXP_COND_VIDE_NONVIDE, $code, $r)) {
973 966
 		$t = $r[2];
974
-		$cond =  '!' . $r[1];
975
-	} else if  (preg_match(_REGEXP_COND_NONVIDE_VIDE,$code, $r)) {
967
+		$cond = '!'.$r[1];
968
+	} else if (preg_match(_REGEXP_COND_NONVIDE_VIDE, $code, $r)) {
976 969
 		$t = $r[2];
977 970
 		$cond = $r[1];
978 971
 	} else {
979
-		$t = '$t' . $n;
972
+		$t = '$t'.$n;
980 973
 		$cond = "($t = $code)!==''";
981 974
 	}
982 975
 
983
-	$res = (!$avant ? "" : "$avant . ") . 
984
-		$t .
976
+	$res = (!$avant ? "" : "$avant . "). 
977
+		$t.
985 978
 		(!$apres ? "" : " . $apres");
986 979
 
987 980
 	if ($res !== $t) $res = "($res)";
@@ -991,9 +984,9 @@  discard block
 block discarded – undo
991 984
 
992 985
 function compile_inclure_doublons($lexemes)
993 986
 {
994
-	foreach($lexemes as $v)
995
-	  if($v->type === 'include' AND $v->param) 
996
-	    foreach($v->param as $r) 
987
+	foreach ($lexemes as $v)
988
+	  if ($v->type === 'include' AND $v->param) 
989
+	    foreach ($v->param as $r) 
997 990
 	      if (trim($r[0]) === 'doublons') 
998 991
 		return true;
999 992
 	return false;
@@ -1015,7 +1008,7 @@  discard block
 block discarded – undo
1015 1008
 // En cas d'erreur, elle retournera un tableau des 2 premiers elements seulement
1016 1009
 
1017 1010
 // http://doc.spip.org/@public_compiler_dist
1018
-function public_compiler_dist($squelette, $nom, $gram, $sourcefile, $connect=''){
1011
+function public_compiler_dist($squelette, $nom, $gram, $sourcefile, $connect = '') {
1019 1012
 	// Pre-traitement : reperer le charset du squelette, et le convertir
1020 1013
 	// Bonus : supprime le BOM
1021 1014
 	include_spip('inc/charsets');
@@ -1023,7 +1016,7 @@  discard block
 block discarded – undo
1023 1016
 
1024 1017
 	// rendre inertes les echappements de #[](){}<>
1025 1018
 	$i = 0;
1026
-	while(false !== strpos($squelette, $inerte = '-INERTE'.$i)) $i++;
1019
+	while (false !== strpos($squelette, $inerte = '-INERTE'.$i)) $i++;
1027 1020
 	$squelette = preg_replace_callback(',\\\\([#[()\]{}<>]),',
1028 1021
 		create_function('$a', "return '$inerte-'.ord(\$a[1]).'-';"), $squelette, -1, $esc);
1029 1022
 
@@ -1035,14 +1028,14 @@  discard block
 block discarded – undo
1035 1028
 	// Phraser le squelette, selon sa grammaire
1036 1029
 
1037 1030
 	$boucles = array();
1038
-	$f = charger_fonction('phraser_' . $gram, 'public');
1031
+	$f = charger_fonction('phraser_'.$gram, 'public');
1039 1032
 
1040 1033
 	$squelette = $f($squelette, '', $boucles, $descr);
1041 1034
 	$boucles = compiler_squelette($squelette, $boucles, $nom, $descr, $sourcefile, $connect);
1042 1035
 
1043 1036
 	// restituer les echappements
1044 1037
 	if ($esc)
1045
-		foreach($boucles as $i=>$boucle) {
1038
+		foreach ($boucles as $i=>$boucle) {
1046 1039
 			$boucles[$i]->return = preg_replace_callback(",$inerte-(\d+)-,", create_function('$a', 'return chr($a[1]);'),
1047 1040
 				$boucle->return);
1048 1041
 			$boucles[$i]->descr['squelette'] = preg_replace_callback(",$inerte-(\d+)-,", create_function('$a', 'return "\\\\".chr($a[1]);'),
@@ -1052,17 +1045,17 @@  discard block
 block discarded – undo
1052 1045
 	$debug = ($boucles AND defined('_VAR_MODE') AND _VAR_MODE == 'debug');
1053 1046
 	if ($debug) {
1054 1047
 		include_spip('public/decompiler');
1055
-		foreach($boucles as $id => $boucle) {
1048
+		foreach ($boucles as $id => $boucle) {
1056 1049
 			if ($id)
1057
-			  $decomp = "\n/* BOUCLE " .
1058
-			    $boucle->type_requete .
1059
-			    " " .
1060
-			    str_replace('*/', '* /', public_decompiler($boucle, $gram, 0, 'criteres')) .
1050
+			  $decomp = "\n/* BOUCLE ".
1051
+			    $boucle->type_requete.
1052
+			    " ".
1053
+			    str_replace('*/', '* /', public_decompiler($boucle, $gram, 0, 'criteres')).
1061 1054
 			    " */\n";
1062
-			else $decomp = ("\n/*\n" . 
1055
+			else $decomp = ("\n/*\n". 
1063 1056
 				 str_replace('*/', '* /', public_decompiler($squelette, $gram)) 
1064 1057
 				 . "\n*/");
1065
-			$boucles[$id]->return = $decomp .$boucle->return; 
1058
+			$boucles[$id]->return = $decomp.$boucle->return; 
1066 1059
 			$GLOBALS['debug_objets']['code'][$nom.$id] = $boucle->return;
1067 1060
 		}
1068 1061
 	}
@@ -1073,7 +1066,7 @@  discard block
 block discarded – undo
1073 1066
 // Point d'entree pour arbre de syntaxe abstraite fourni en premier argument
1074 1067
 // Autres specifications comme ci-dessus
1075 1068
 
1076
-function compiler_squelette($squelette, $boucles, $nom, $descr, $sourcefile, $connect=''){
1069
+function compiler_squelette($squelette, $boucles, $nom, $descr, $sourcefile, $connect = '') {
1077 1070
 	static $trouver_table;
1078 1071
 	spip_timer('calcul_skel');
1079 1072
 
@@ -1096,7 +1089,7 @@  discard block
 block discarded – undo
1096 1089
 	if (!$trouver_table)
1097 1090
 		$trouver_table = charger_fonction('trouver_table', 'base');
1098 1091
 
1099
-	foreach($boucles as $id => $boucle) {
1092
+	foreach ($boucles as $id => $boucle) {
1100 1093
 		if (!($type = $boucle->type_requete)) continue;
1101 1094
 		if (!$descr['documents'] AND (
1102 1095
 			(($type == 'documents') AND $boucle->doublons) OR
@@ -1127,14 +1120,14 @@  discard block
 block discarded – undo
1127 1120
 				// c'est peut etre une table qui necessite son connecteur dedie fourni
1128 1121
 				// permet une ecriture allegee (GEO) -> (geo:GEO)
1129 1122
 				if (!$show
1130
-				AND $show=$trouver_table($type, strtolower($type))) {
1123
+				AND $show = $trouver_table($type, strtolower($type))) {
1131 1124
 					$boucles[$id]->sql_serveur = strtolower($type);
1132 1125
 				}
1133 1126
 				if ($show) {
1134 1127
 					$boucles[$id]->show = $show;
1135 1128
 					// recopie les infos les plus importantes
1136 1129
 					$boucles[$id]->primary = $show['key']["PRIMARY KEY"];
1137
-					$boucles[$id]->id_table = $x = preg_replace(",^spip_,","",$show['id_table']);
1130
+					$boucles[$id]->id_table = $x = preg_replace(",^spip_,", "", $show['id_table']);
1138 1131
 					$boucles[$id]->from[$x] = $nom_table = $show['table'];
1139 1132
 					$boucles[$id]->iterateur = 'SQL';
1140 1133
 
@@ -1143,20 +1136,19 @@  discard block
 block discarded – undo
1143 1136
 					    AND is_array($show['tables_jointures'])
1144 1137
 					        AND count($x = $show['tables_jointures']))
1145 1138
 						$boucles[$id]->jointures = $x;
1146
-					if ($boucles[$id]->jointures_explicites){
1147
-						$jointures = preg_split("/\s+/",$boucles[$id]->jointures_explicites);
1148
-						while ($j=array_pop($jointures))
1149
-							array_unshift($boucles[$id]->jointures,$j);
1139
+					if ($boucles[$id]->jointures_explicites) {
1140
+						$jointures = preg_split("/\s+/", $boucles[$id]->jointures_explicites);
1141
+						while ($j = array_pop($jointures))
1142
+							array_unshift($boucles[$id]->jointures, $j);
1150 1143
 					}
1151 1144
 				} else {
1152 1145
 					// Pas une erreur si la table est optionnelle
1153 1146
 					if ($boucles[$id]->table_optionnelle)
1154 1147
 						$boucles[$id]->type_requete = '';
1155
-					else  {
1148
+					else {
1156 1149
 						$boucles[$id]->type_requete = false;
1157 1150
 						$boucle = $boucles[$id];
1158
-						$x = (!$boucle->sql_serveur ? '' :
1159
-							($boucle->sql_serveur . ":")) .
1151
+						$x = (!$boucle->sql_serveur ? '' : ($boucle->sql_serveur.":")).
1160 1152
 						     $type;
1161 1153
 						$msg = array('zbug_table_inconnue',
1162 1154
 						             array('table' => $x));
@@ -1169,7 +1161,7 @@  discard block
 block discarded – undo
1169 1161
 
1170 1162
 	// Commencer par reperer les boucles appelees explicitement 
1171 1163
 	// car elles indexent les arguments de maniere derogatoire
1172
-	foreach($boucles as $id => $boucle) {
1164
+	foreach ($boucles as $id => $boucle) {
1173 1165
 		if ($boucle->type_requete == TYPE_RECURSIF AND $boucle->param) {
1174 1166
 			$boucles[$id]->descr = &$descr;
1175 1167
 			$rec = &$boucles[$boucle->param[0]];
@@ -1189,7 +1181,7 @@  discard block
 block discarded – undo
1189 1181
 			}
1190 1182
 		}
1191 1183
 	}
1192
-	foreach($boucles as $id => $boucle) { 
1184
+	foreach ($boucles as $id => $boucle) { 
1193 1185
 		$id = strval($id); // attention au type dans index_pile
1194 1186
 		$type = $boucle->type_requete;
1195 1187
 		if ($type AND $type != TYPE_RECURSIF) {
@@ -1223,9 +1215,9 @@  discard block
 block discarded – undo
1223 1215
 	// en particulier les requetes SQL et TOTAL_BOUCLE
1224 1216
 	// de'terminables seulement maintenant
1225 1217
 
1226
-	foreach($boucles as $id => $boucle) {
1218
+	foreach ($boucles as $id => $boucle) {
1227 1219
 		$boucle = $boucles[$id] = pipeline('pre_boucle', $boucle);
1228
-		if ($boucle->return === false) {$corps = false; continue;}
1220
+		if ($boucle->return === false) {$corps = false; continue; }
1229 1221
 		// appeler la fonction de definition de la boucle
1230 1222
 
1231 1223
 		if ($req = $boucle->type_requete) {
@@ -1242,25 +1234,25 @@  discard block
 block discarded – undo
1242 1234
 				// fonction de boucle avec table
1243 1235
 				AND (!function_exists($f = "boucle_".$table))
1244 1236
 					AND (!function_exists($f = $f."_dist"))
1245
-			){
1237
+			) {
1246 1238
 				// fonction de boucle standard 
1247 1239
 				if (!function_exists($f = 'boucle_DEFAUT')) {
1248 1240
 					$f = 'boucle_DEFAUT_dist';
1249 1241
 				}
1250 1242
 			}
1251 1243
 
1252
-			$req = "\n\n\tstatic \$command = array();\n\t" .
1253
-					"static \$connect;\n\t" .
1254
-					"\$command['connect'] = \$connect = " .
1255
-				_q($boucle->sql_serveur) .
1256
-				";" .
1244
+			$req = "\n\n\tstatic \$command = array();\n\t".
1245
+					"static \$connect;\n\t".
1246
+					"\$command['connect'] = \$connect = ".
1247
+				_q($boucle->sql_serveur).
1248
+				";".
1257 1249
 				$f($id, $boucles);
1258 1250
 		} else $req = ("\n\treturn '';");
1259 1251
 
1260 1252
 		$boucles[$id]->return = 
1261
-			"\n\nfunction BOUCLE" . strtr($id,"-","_") . $nom .
1262
-			'(&$Cache, &$Pile, &$doublons, &$Numrows, $SP) {' .
1263
-			$req .
1253
+			"\n\nfunction BOUCLE".strtr($id, "-", "_").$nom.
1254
+			'(&$Cache, &$Pile, &$doublons, &$Numrows, $SP) {'.
1255
+			$req.
1264 1256
 			"\n}\n";
1265 1257
 	}
1266 1258
 
@@ -1268,7 +1260,7 @@  discard block
 block discarded – undo
1268 1260
 	// retourner False, sinon inserer leur decompilation
1269 1261
 	if (is_bool($corps)) return false;
1270 1262
 
1271
-	$principal = "\nfunction " . $nom . '($Cache, $Pile, $doublons=array(), $Numrows=array(), $SP=0) {
1263
+	$principal = "\nfunction ".$nom.'($Cache, $Pile, $doublons=array(), $Numrows=array(), $SP=0) {
1272 1264
 '
1273 1265
 	// reporter de maniere securisee les doublons inclus
1274 1266
 .'
@@ -1276,15 +1268,15 @@  discard block
 block discarded – undo
1276 1268
 		$doublons = nettoyer_env_doublons($Pile[0]["doublons"]);
1277 1269
 
1278 1270
 	$connect = ' .
1279
-	_q($connect) . ';
1271
+	_q($connect).';
1280 1272
 	$page = ' .
1281 1273
 	// ATTENTION, le calcul de l'expression $corps affectera $Cache
1282 1274
 	// c'est pourquoi on l'affecte a la variable auxiliaire $page. 
1283 1275
 	// avant de referencer $Cache
1284
-	$corps . ";
1276
+	$corps.";
1285 1277
 
1286
-	return analyse_resultat_skel(".var_export($nom,true)
1287
-		.", \$Cache, \$page, ".var_export($sourcefile,true).");
1278
+	return analyse_resultat_skel(".var_export($nom, true)
1279
+		.", \$Cache, \$page, ".var_export($sourcefile, true).");
1288 1280
 }";
1289 1281
 
1290 1282
 	$secondes = spip_timer('calcul_skel');
@@ -1298,10 +1290,10 @@  discard block
 block discarded – undo
1298 1290
 	$code->return = '
1299 1291
 //
1300 1292
 // Fonction principale du squelette ' . 
1301
-	$sourcefile . 
1302
-	($connect ? " pour $connect" : '') . 
1303
-	(!CODE_COMMENTE ? '' : "\n// Temps de compilation total: $secondes") .
1304
-	"\n//\n" .
1293
+	$sourcefile. 
1294
+	($connect ? " pour $connect" : ''). 
1295
+	(!CODE_COMMENTE ? '' : "\n// Temps de compilation total: $secondes").
1296
+	"\n//\n".
1305 1297
 	$principal;
1306 1298
 
1307 1299
 	$boucles[''] = $code;
@@ -1350,7 +1342,7 @@  discard block
 block discarded – undo
1350 1342
 **/
1351 1343
 function requeteur_data_dist(&$boucles, &$boucle, &$id) {
1352 1344
 	include_spip('iterateur/data');
1353
-	if ($h = charger_fonction($boucle->type_requete . '_to_array' , 'inc', true)) {
1345
+	if ($h = charger_fonction($boucle->type_requete.'_to_array', 'inc', true)) {
1354 1346
 		$g = charger_fonction('data', 'iterateur');
1355 1347
 		$boucles[$id] = $g($boucle);
1356 1348
 		// from[0] stocke le type de data (rss, yql, ...)
Please login to merge, or discard this patch.
ecrire/public/composer.php 1 patch
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 # Toutefois pour 2. et 3. preferer la technique de la surcharge
32 32
 
33 33
 // http://doc.spip.org/@public_composer_dist
34
-function public_composer_dist($squelette, $mime_type, $gram, $source, $connect='') {
34
+function public_composer_dist($squelette, $mime_type, $gram, $source, $connect = '') {
35 35
 
36 36
 	$nom = calculer_nom_fonction_squel($squelette, $mime_type, $connect);
37 37
 
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 	if (defined('_VAR_MODE') AND _VAR_MODE == 'debug')
42 42
 		$GLOBALS['debug_objets']['courant'] = $nom;
43 43
 
44
-	$phpfile = sous_repertoire(_DIR_SKELS,'',false,true) . $nom . '.php';
44
+	$phpfile = sous_repertoire(_DIR_SKELS, '', false, true).$nom.'.php';
45 45
 
46 46
 	// si squelette est deja compile et perenne, le charger
47
-	if (!squelette_obsolete($phpfile, $source)){
47
+	if (!squelette_obsolete($phpfile, $source)) {
48 48
 		include_once $phpfile;
49 49
 		#if (!squelette_obsolete($phpfile, $source)
50 50
 		#  AND lire_fichier ($phpfile, $skel_code,
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		#}
55 55
 	}
56 56
 
57
-	if (file_exists($lib = $squelette . '_fonctions'.'.php')){
57
+	if (file_exists($lib = $squelette.'_fonctions'.'.php')) {
58 58
 		include_once $lib;
59 59
 	}
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	if (function_exists($nom)) return $nom;
64 64
 
65 65
 	// charger le source, si possible, et compiler 
66
-	if (lire_fichier ($source, $skel)) {
66
+	if (lire_fichier($source, $skel)) {
67 67
 		$compiler = charger_fonction('compiler', 'public');
68 68
 		$skel_code = $compiler($skel, $nom, $gram, $source, $connect);
69 69
 	}
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 	// Ne plus rien faire si le compilateur n'a pas pu operer.
72 72
 	if (!$skel_code) return false;
73 73
 
74
-	foreach($skel_code as $id => $boucle) {
74
+	foreach ($skel_code as $id => $boucle) {
75 75
 		$f = $boucle->return;
76
-		if (@eval("return true; $f ;") ===  false) {
76
+		if (@eval("return true; $f ;") === false) {
77 77
 		// Code syntaxiquement faux (critere etc mal programme')
78 78
 			$msg = _T('zbug_erreur_compilation');
79 79
 			erreur_squelette($msg, $boucle);
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') {
103 103
 
104 104
 		// Tracer ce qui vient d'etre compile
105
-		$GLOBALS['debug_objets']['code'][$nom . 'tout'] = $code;
105
+		$GLOBALS['debug_objets']['code'][$nom.'tout'] = $code;
106 106
 
107 107
 		// si c'est ce que demande le debusqueur, lui passer la main
108 108
 		if ($GLOBALS['debug_objets']['sourcefile']
109 109
 		AND (_request('var_mode_objet') == $nom)
110
-		AND (_request('var_mode_affiche') == 'code')  )
110
+		AND (_request('var_mode_affiche') == 'code'))
111 111
 			erreur_squelette();
112 112
 	}
113 113
 	return $nom ? $nom : false;
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
 {
118 118
 
119 119
 	// Le dernier index est '' (fonction principale)
120
-	$noms = substr(join (', ', array_keys($boucles)), 0, -2);
120
+	$noms = substr(join(', ', array_keys($boucles)), 0, -2);
121 121
 	if (CODE_COMMENTE)
122 122
 	$code = "
123 123
 /*
124 124
  * Squelette : $sourcefile
125 125
  * Date :      ".gmdate("D, d M Y H:i:s", @filemtime($sourcefile))." GMT
126 126
  * Compile :   ".gmdate("D, d M Y H:i:s", time())." GMT
127
- * " . (!$boucles ?  "Pas de boucle" :	("Boucles :   " . $noms)) ."
127
+ * " . (!$boucles ? "Pas de boucle" : ("Boucles :   ".$noms))."
128 128
  */ " ;
129 129
 
130
-	$code = '<'. "?php\n" . $code . join('', $boucles)  . "\n?" .'>';
130
+	$code = '<'."?php\n".$code.join('', $boucles)."\n?".'>';
131 131
 	if (!defined('_VAR_NOCACHE') OR !_VAR_NOCACHE)
132 132
 		ecrire_fichier($phpfile, $code);
133 133
 	return $code;
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
 	static $date_change = null;
140 140
 	// ne verifier la date de mes_fonctions et mes_options qu'une seule fois
141 141
 	// par hit
142
-	if (is_null($date_change)){
142
+	if (is_null($date_change)) {
143 143
 		if (@file_exists($fonc = 'mes_fonctions.php'))
144 144
 			$date_change = @filemtime($fonc); # compatibilite
145 145
 		if (defined('_FILE_OPTIONS'))
146
-			$date_change = max($date_change,@filemtime(_FILE_OPTIONS));
146
+			$date_change = max($date_change, @filemtime(_FILE_OPTIONS));
147 147
 	}
148 148
 	return (
149
-		(defined('_VAR_MODE') AND in_array(_VAR_MODE, array('recalcul','preview','debug')))
149
+		(defined('_VAR_MODE') AND in_array(_VAR_MODE, array('recalcul', 'preview', 'debug')))
150 150
 		OR !@file_exists($skel)
151
-		OR ((@file_exists($squelette)?@filemtime($squelette):0)
151
+		OR ((@file_exists($squelette) ? @filemtime($squelette) : 0)
152 152
 			> ($date = @filemtime($skel)))
153 153
 		OR ($date_change > $date)
154 154
 	);
@@ -156,41 +156,41 @@  discard block
 block discarded – undo
156 156
 
157 157
 // Activer l'invalideur de session
158 158
 // http://doc.spip.org/@invalideur_session
159
-function invalideur_session(&$Cache, $code=NULL) {
160
-	$Cache['session']=spip_session();
159
+function invalideur_session(&$Cache, $code = NULL) {
160
+	$Cache['session'] = spip_session();
161 161
 	return $code;
162 162
 }
163 163
 
164 164
 
165 165
 // http://doc.spip.org/@analyse_resultat_skel
166
-function analyse_resultat_skel($nom, $cache, $corps, $source='') {
166
+function analyse_resultat_skel($nom, $cache, $corps, $source = '') {
167 167
 	static $filtres = array();
168 168
 	$headers = array();
169 169
 
170 170
 	// Recupere les < ?php header('Xx: y'); ? > pour $page['headers']
171 171
 	// note: on essaie d'attrapper aussi certains de ces entetes codes
172 172
 	// "a la main" dans les squelettes, mais evidemment sans exhaustivite
173
-	if (stripos($corps,'header')!==false
173
+	if (stripos($corps, 'header') !== false
174 174
 		AND preg_match_all(
175 175
 	'/(<[?]php\s+)@?header\s*\(\s*.([^:\'"]*):?\s*([^)]*)[^)]\s*\)\s*[;]?\s*[?]>/ims',
176
-	$corps, $regs, PREG_SET_ORDER)){
176
+	$corps, $regs, PREG_SET_ORDER)) {
177 177
 		foreach ($regs as $r) {
178 178
 			$corps = str_replace($r[0], '', $corps);
179 179
 			# $j = Content-Type, et pas content-TYPE.
180 180
 			$j = join('-', array_map('ucwords', explode('-', strtolower($r[2]))));
181 181
 
182
-			if ($j=='X-Spip-Filtre' AND isset($headers[$j]))
183
-				$headers[$j].="|".$r[3];
182
+			if ($j == 'X-Spip-Filtre' AND isset($headers[$j]))
183
+				$headers[$j] .= "|".$r[3];
184 184
 			else
185 185
 				$headers[$j] = $r[3];
186 186
 		}
187 187
 	}
188 188
 	// S'agit-il d'un resultat constant ou contenant du code php
189 189
 	$process_ins = (
190
-		strpos($corps,'<'.'?') === false
190
+		strpos($corps, '<'.'?') === false
191 191
 		OR
192
-		 (strpos($corps,'<'.'?xml')!==false AND
193
-		  strpos(str_replace('<'.'?xml', '', $corps),'<'.'?') === false)
192
+		 (strpos($corps, '<'.'?xml') !== false AND
193
+		  strpos(str_replace('<'.'?xml', '', $corps), '<'.'?') === false)
194 194
 	)
195 195
 		? 'html'
196 196
 		: 'php';
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 
207 207
 	// traiter #FILTRE{} et filtres
208 208
   if (!isset($filtres[$nom])) {
209
-	  $filtres[$nom] = pipeline('declarer_filtres_squelettes',array('args'=>$skel,'data'=>array()));
209
+	  $filtres[$nom] = pipeline('declarer_filtres_squelettes', array('args'=>$skel, 'data'=>array()));
210 210
   }
211 211
 	if (count($filtres[$nom]) OR (isset($headers['X-Spip-Filtre']) AND strlen($headers['X-Spip-Filtre']))) {
212 212
 		include_spip('public/sandbox');
213
-		$corps = sandbox_filtrer_squelette($skel,$corps,strlen($headers['X-Spip-Filtre'])?explode('|', $headers['X-Spip-Filtre']):array(),$filtres[$nom]);
213
+		$corps = sandbox_filtrer_squelette($skel, $corps, strlen($headers['X-Spip-Filtre']) ? explode('|', $headers['X-Spip-Filtre']) : array(), $filtres[$nom]);
214 214
 		unset($headers['X-Spip-Filtre']);
215 215
 	}
216 216
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 function filtre_introduction_dist($descriptif, $texte, $longueur, $connect) {
239 239
 	// Si un descriptif est envoye, on l'utilise directement
240 240
 	if (strlen($descriptif))
241
-		return propre($descriptif,$connect);
241
+		return propre($descriptif, $connect);
242 242
 
243 243
 	// De preference ce qui est marque <intro>...</intro>
244 244
 	$intro = '';
@@ -266,22 +266,22 @@  discard block
 block discarded – undo
266 266
 		$texte = $intro;
267 267
 
268 268
 	else
269
-	if (strpos("\n".$texte, "\n|")===false
270
-	  AND strlen($texte) > 2.5*$longueur){
271
-		if (strpos($texte,"<multi")!==false)
269
+	if (strpos("\n".$texte, "\n|") === false
270
+	  AND strlen($texte) > 2.5 * $longueur) {
271
+		if (strpos($texte, "<multi") !== false)
272 272
 			$texte = extraire_multi($texte);
273
-		$texte = couper($texte, 2*$longueur);
273
+		$texte = couper($texte, 2 * $longueur);
274 274
 	}
275 275
 
276 276
 	// ne pas tenir compte des notes
277 277
 	if ($notes = charger_fonction('notes', 'inc', true))
278
-		$notes('','empiler');
278
+		$notes('', 'empiler');
279 279
 	// Supprimer les modèles avant le propre afin d'éviter qu'ils n'ajoutent du texte indésirable
280 280
 	// dans l'introduction.
281 281
 	$texte = supprime_img($texte, '');
282
-	$texte = propre($texte,$connect);
282
+	$texte = propre($texte, $connect);
283 283
 	if ($notes)
284
-		$notes('','depiler');
284
+		$notes('', 'depiler');
285 285
 
286 286
 	if (!defined('_INTRODUCTION_SUITE')) define('_INTRODUCTION_SUITE', '&nbsp;(...)');
287 287
 	$texte = couper($texte, $longueur, _INTRODUCTION_SUITE);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 // elles sont traitees comme des inclusions
302 302
 // http://doc.spip.org/@synthetiser_balise_dynamique
303 303
 
304
-define('CODE_INCLURE_BALISE', '<' . '?php 
304
+define('CODE_INCLURE_BALISE', '<'.'?php 
305 305
 include_once("./" . _DIR_RACINE . "%s");
306 306
 if ($lang_select = "%s") $lang_select = lang_select($lang_select);
307 307
 inserer_balise_dynamique(balise_%s_dyn(%s), array(%s));
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 function synthetiser_balise_dynamique($nom, $args, $file, $context_compil) {
314 314
 	$r = sprintf(CODE_INCLURE_BALISE,
315 315
 	       $file,
316
-	       $context_compil[4]?$context_compil[4]:'',
316
+	       $context_compil[4] ? $context_compil[4] : '',
317 317
 	       $nom,
318 318
 	       join(', ', array_map('argumenter_squelette', $args)),
319 319
 	       join(', ', array_map('_q', $context_compil)));
@@ -324,38 +324,38 @@  discard block
 block discarded – undo
324 324
 function argumenter_squelette($v) {
325 325
 
326 326
 	if (!is_array($v))
327
-		return "'" . texte_script($v) . "'";
327
+		return "'".texte_script($v)."'";
328 328
 	else {
329 329
 		$out = array();
330
-		foreach($v as $k=>$val) 
331
-			$out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val);
332
-	  return 'array(' . join(", ", $out) . ')';
330
+		foreach ($v as $k=>$val) 
331
+			$out [] = argumenter_squelette($k).'=>'.argumenter_squelette($val);
332
+	  return 'array('.join(", ", $out).')';
333 333
 	}
334 334
 }
335 335
 
336 336
 // verifier leurs arguments et filtres, et calculer le code a inclure
337 337
 // http://doc.spip.org/@executer_balise_dynamique
338 338
 function executer_balise_dynamique($nom, $args, $context_compil) {
339
-	$p = strpos($nom,"_");
339
+	$p = strpos($nom, "_");
340 340
 	$nomfonction = $nom;
341
-	$nomfonction_generique = substr($nom,0,$p+1);
342
-	if (!$file = include_spip("balise/". strtolower($nomfonction))) {
341
+	$nomfonction_generique = substr($nom, 0, $p + 1);
342
+	if (!$file = include_spip("balise/".strtolower($nomfonction))) {
343 343
 		// pas de fichier associe, passer au traitement generique
344
-		$file = include_spip("balise/" .strtolower($nomfonction_generique));
344
+		$file = include_spip("balise/".strtolower($nomfonction_generique));
345 345
 		if ($file) {
346 346
 			// et injecter en premier arg le nom de la balise 
347
-			array_unshift($args,$nom);
347
+			array_unshift($args, $nom);
348 348
 			// et passer sur la fonction generique pour la suite
349 349
 			$nomfonction = $nomfonction_generique;
350 350
 		}
351 351
 		else {
352
-			$msg = array('zbug_balise_inexistante',array('from'=>'CVT','balise'=>$nom));
352
+			$msg = array('zbug_balise_inexistante', array('from'=>'CVT', 'balise'=>$nom));
353 353
 			erreur_squelette($msg, $context_compil);
354 354
 			return '';
355 355
 		}
356 356
 	}
357 357
 	// Y a-t-il une fonction de traitement des arguments ?
358
-	$f = 'balise_' . $nomfonction . '_stat';
358
+	$f = 'balise_'.$nomfonction.'_stat';
359 359
 
360 360
 	$r = !function_exists($f) ? $args : $f($args, $context_compil); 
361 361
 
@@ -363,61 +363,61 @@  discard block
 block discarded – undo
363 363
 
364 364
 	// verifier que la fonction dyn est la, 
365 365
 	// sinon se replier sur la generique si elle existe
366
-	if (!function_exists('balise_' . $nomfonction . '_dyn')) {
367
-		$file = include_spip("balise/" .strtolower($nomfonction_generique));
368
-		if (function_exists('balise_' . $nomfonction_generique . '_dyn')) {
366
+	if (!function_exists('balise_'.$nomfonction.'_dyn')) {
367
+		$file = include_spip("balise/".strtolower($nomfonction_generique));
368
+		if (function_exists('balise_'.$nomfonction_generique.'_dyn')) {
369 369
 			// et lui injecter en premier arg le nom de la balise 
370
-			array_unshift($r,$nom);
370
+			array_unshift($r, $nom);
371 371
 			$nomfonction = $nomfonction_generique;
372 372
 		} else {
373
-			$msg = array('zbug_balise_inexistante',array('from'=>'CVT','balise'=>$nom));
373
+			$msg = array('zbug_balise_inexistante', array('from'=>'CVT', 'balise'=>$nom));
374 374
 			erreur_squelette($msg, $context_compil);
375 375
 			return '';
376 376
 		}
377 377
 	}
378 378
 
379 379
 	if (!_DIR_RESTREINT) 
380
-		$file = _DIR_RESTREINT_ABS . $file;
380
+		$file = _DIR_RESTREINT_ABS.$file;
381 381
 	return synthetiser_balise_dynamique($nomfonction, $r, $file, $context_compil);
382 382
 }
383 383
 
384 384
 // http://doc.spip.org/@lister_objets_avec_logos
385
-function lister_objets_avec_logos ($type) {
385
+function lister_objets_avec_logos($type) {
386 386
 	global $formats_logos;
387 387
 	$logos = array();
388 388
 	$chercher_logo = charger_fonction('chercher_logo', 'inc');
389 389
 	$type = '/'
390 390
 	. type_du_logo($type)
391 391
 	. "on(\d+)\.("
392
-	. join('|',$formats_logos)
392
+	. join('|', $formats_logos)
393 393
 	. ")$/";
394 394
 
395 395
 	if ($d = @opendir(_DIR_LOGOS)) {
396
-		while($f = readdir($d)) {
396
+		while ($f = readdir($d)) {
397 397
 			if (preg_match($type, $f, $r))
398 398
 				$logos[] = $r[1];
399 399
 		}
400 400
 	}
401 401
 	@closedir($d);
402
-	return join(',',$logos);
402
+	return join(',', $logos);
403 403
 }
404 404
 
405 405
 // fonction appelee par la balise #NOTES
406 406
 // Renvoyer l'etat courant des notes, le purger et en preparer un nouveau
407 407
 // http://doc.spip.org/@calculer_notes
408 408
 function calculer_notes() {
409
-	$r='';
409
+	$r = '';
410 410
 	if ($notes = charger_fonction('notes', 'inc', true)) {
411 411
 		$r = $notes(array());
412
-		$notes('','depiler');
413
-		$notes('','empiler');
412
+		$notes('', 'depiler');
413
+		$notes('', 'empiler');
414 414
 	}
415 415
 	return $r;
416 416
 }
417 417
 
418 418
 // Selectionner la langue de l'objet dans la boucle, sauf dans les
419 419
 // cas ou il ne le faut pas :-)
420
-function lang_select_public($lang, $lang_select, $titre=null) {
420
+function lang_select_public($lang, $lang_select, $titre = null) {
421 421
 	// Cas 1. forcer_lang = true et pas de critere {lang_select}
422 422
 	if (isset($GLOBALS['forcer_lang']) AND $GLOBALS['forcer_lang']
423 423
 	AND $lang_select !== 'oui')
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 function nettoyer_env_doublons($envd) {
448 448
 	foreach ($envd as $table => $liste) {
449 449
 		$n = '';
450
-		foreach(explode(',',$liste) as $val) {
450
+		foreach (explode(',', $liste) as $val) {
451 451
 			if ($a = intval($val) AND $val === strval($a))
452
-				$n.= ','.$val;
452
+				$n .= ','.$val;
453 453
 		}
454 454
 		if (strlen($n))
455 455
 			$envd[$table] = $n;
@@ -460,33 +460,33 @@  discard block
 block discarded – undo
460 460
 }
461 461
 
462 462
 // http://doc.spip.org/@match_self
463
-function match_self($w){
463
+function match_self($w) {
464 464
 	if (is_string($w)) return false;
465 465
 	if (is_array($w)) {
466
-		if (in_array(reset($w),array("SELF","SUBSELECT"))) return $w;
467
-		foreach(array_filter($w,'is_array') as $sw)
468
-			if ($m=match_self($sw)) return $m;
466
+		if (in_array(reset($w), array("SELF", "SUBSELECT"))) return $w;
467
+		foreach (array_filter($w, 'is_array') as $sw)
468
+			if ($m = match_self($sw)) return $m;
469 469
 	}
470 470
 	return false;
471 471
 }
472 472
 // http://doc.spip.org/@remplace_sous_requete
473
-function remplace_sous_requete($w,$sousrequete){
473
+function remplace_sous_requete($w, $sousrequete) {
474 474
 	if (is_array($w)) {
475
-		if (in_array(reset($w),array("SELF","SUBSELECT"))) return $sousrequete;
476
-		foreach($w as $k=>$sw)
477
-			$w[$k] = remplace_sous_requete($sw,$sousrequete);
475
+		if (in_array(reset($w), array("SELF", "SUBSELECT"))) return $sousrequete;
476
+		foreach ($w as $k=>$sw)
477
+			$w[$k] = remplace_sous_requete($sw, $sousrequete);
478 478
 	}
479 479
 	return $w;
480 480
 }
481 481
 // http://doc.spip.org/@trouver_sous_requetes
482
-function trouver_sous_requetes($where){
482
+function trouver_sous_requetes($where) {
483 483
 	$where_simples = array();
484 484
 	$where_sous = array();
485
-	foreach($where as $k=>$w){
485
+	foreach ($where as $k=>$w) {
486 486
 		if (match_self($w)) $where_sous[$k] = $w;
487 487
 		else $where_simples[$k] = $w;
488 488
 	}
489
-	return array($where_simples,$where_sous);
489
+	return array($where_simples, $where_sous);
490 490
 }
491 491
 
492 492
 
@@ -510,42 +510,42 @@  discard block
 block discarded – undo
510 510
  * @param bool $requeter
511 511
  * @return resource
512 512
  */
513
-function calculer_select ($select = array(), $from = array(), 
513
+function calculer_select($select = array(), $from = array(), 
514 514
 			$from_type = array(),
515
-      $where = array(), $join=array(),
515
+      $where = array(), $join = array(),
516 516
 			$groupby = array(), $orderby = array(), $limit = '',
517
-			$having=array(), $table = '', $id = '', $serveur='', $requeter=true) {
517
+			$having = array(), $table = '', $id = '', $serveur = '', $requeter = true) {
518 518
 
519 519
 	// retirer les criteres vides:
520 520
 	// {X ?} avec X absent de l'URL
521 521
 	// {par #ENV{X}} avec X absent de l'URL
522 522
 	// IN sur collection vide (ce dernier devrait pouvoir etre fait a la compil)
523 523
 	$menage = false;
524
-	foreach($where as $k => $v) { 
525
-		if (is_array($v)){
526
-			if ((count($v)>=2) && ($v[0]=='REGEXP') && ($v[2]=="'.*'")) $op= false;
527
-			elseif ((count($v)>=2) && ($v[0]=='LIKE') && ($v[2]=="'%'")) $op= false;
524
+	foreach ($where as $k => $v) { 
525
+		if (is_array($v)) {
526
+			if ((count($v) >= 2) && ($v[0] == 'REGEXP') && ($v[2] == "'.*'")) $op = false;
527
+			elseif ((count($v) >= 2) && ($v[0] == 'LIKE') && ($v[2] == "'%'")) $op = false;
528 528
 			else $op = $v[0] ? $v[0] : $v;
529 529
 		} else $op = $v;
530
-		if ((!$op) OR ($op==1) OR ($op=='0=0')) {
530
+		if ((!$op) OR ($op == 1) OR ($op == '0=0')) {
531 531
 			unset($where[$k]);
532 532
 			$menage = true;
533 533
 		}
534 534
 	}
535 535
 
536 536
 	// evacuer les eventuels groupby vide issus d'un calcul dynamique
537
-	$groupby = array_diff($groupby,array(''));
537
+	$groupby = array_diff($groupby, array(''));
538 538
 
539 539
 	// remplacer les sous requetes recursives au calcul
540
-	list($where_simples,$where_sous) = trouver_sous_requetes($where);
541
-	foreach($where_sous as $k=>$w) {
540
+	list($where_simples, $where_sous) = trouver_sous_requetes($where);
541
+	foreach ($where_sous as $k=>$w) {
542 542
 		$menage = true;
543 543
 		// on recupere la sous requete 
544 544
 		$sous = match_self($w);
545
-		if ($sous[0]=='SELF') {
545
+		if ($sous[0] == 'SELF') {
546 546
 			// c'est une sous requete identique a elle meme sous la forme (SELF,$select,$where)
547
-			array_push($where_simples,$sous[2]);
548
-			$wheresub = array($sous[2],'0=0'); // pour accepter une string et forcer a faire le menage car on a surement simplifie select et where
547
+			array_push($where_simples, $sous[2]);
548
+			$wheresub = array($sous[2], '0=0'); // pour accepter une string et forcer a faire le menage car on a surement simplifie select et where
549 549
 			$jsub = $join;
550 550
 			// trouver les jointures utiles a
551 551
 			// reinjecter dans le where de la sous requete les conditions supplementaires des jointures qui y sont mentionnees
@@ -553,50 +553,50 @@  discard block
 block discarded – undo
553 553
 			// on construit le where une fois, puis on ajoute les where complentaires si besoin, et on reconstruit le where en fonction
554 554
 			$i = 0;
555 555
 			do {
556
-				$where[$k] = remplace_sous_requete($w,"(".calculer_select(
556
+				$where[$k] = remplace_sous_requete($w, "(".calculer_select(
557 557
 				array($sous[1]." AS id"),
558 558
 				$from,
559 559
 				$from_type,
560 560
 				$wheresub,
561 561
 				$jsub,
562
-				array(),array(),'',
563
-				$having,$table,$id,$serveur,false).")");
564
-				if (!$i){
562
+				array(), array(), '',
563
+				$having, $table, $id, $serveur, false).")");
564
+				if (!$i) {
565 565
 					$i = 1;
566 566
 					$wherestring = calculer_where_to_string($where[$k]);
567
-					foreach ($join as $cle=>$wj){
568
-						if (count($wj)==4
569
-							AND strpos($wherestring,"{$cle}.")!==FALSE
570
-						){
567
+					foreach ($join as $cle=>$wj) {
568
+						if (count($wj) == 4
569
+							AND strpos($wherestring, "{$cle}.") !== FALSE
570
+						) {
571 571
 							$i = 0;
572 572
 							$wheresub[] = $wj[3];
573 573
 							unset($jsub[$cle][3]);
574 574
 						}
575 575
 					}
576 576
 				}
577
-			} while ($i++<1);
577
+			} while ($i++ < 1);
578 578
 		}
579
-		if ($sous[0]=='SUBSELECT') {
579
+		if ($sous[0] == 'SUBSELECT') {
580 580
 			// c'est une sous requete explicite sous la forme identique a sql_select : (SUBSELECT,$select,$from,$where,$groupby,$orderby,$limit,$having)
581
-			array_push($where_simples,$sous[3]); // est-ce utile dans ce cas ?
582
-			$where[$k] = remplace_sous_requete($w,"(".calculer_select(
581
+			array_push($where_simples, $sous[3]); // est-ce utile dans ce cas ?
582
+			$where[$k] = remplace_sous_requete($w, "(".calculer_select(
583 583
 			$sous[1], # select
584 584
 			$sous[2], #from
585 585
 			array(), #from_type
586
-			$sous[3]?(is_array($sous[3])?$sous[3]:array($sous[3])):array(), #where, qui peut etre de la forme string comme dans sql_select
586
+			$sous[3] ? (is_array($sous[3]) ? $sous[3] : array($sous[3])) : array(), #where, qui peut etre de la forme string comme dans sql_select
587 587
 			array(), #join
588
-			$sous[4]?$sous[4]:array(), #groupby
589
-			$sous[5]?$sous[5]:array(), #orderby
588
+			$sous[4] ? $sous[4] : array(), #groupby
589
+			$sous[5] ? $sous[5] : array(), #orderby
590 590
 			$sous[6], #limit
591
-			$sous[7]?$sous[7]:array(), #having
592
-			$table,$id,$serveur,false
591
+			$sous[7] ? $sous[7] : array(), #having
592
+			$table, $id, $serveur, false
593 593
 			).")");
594 594
 		}
595 595
 		array_pop($where_simples);
596 596
 	}
597 597
 
598
-	foreach($having as $k => $v) { 
599
-		if ((!$v) OR ($v==1) OR ($v=='0=0')) {
598
+	foreach ($having as $k => $v) { 
599
+		if ((!$v) OR ($v == 1) OR ($v == '0=0')) {
600 600
 			unset($having[$k]);
601 601
 		}
602 602
 	}
@@ -609,13 +609,13 @@  discard block
 block discarded – undo
609 609
 	$afrom = array();
610 610
 	$equiv = array();
611 611
 	$k = count($join);
612
-	foreach(array_reverse($join,true) as $cledef=>$j) {
612
+	foreach (array_reverse($join, true) as $cledef=>$j) {
613 613
 		$cle = $cledef;
614 614
 		// le format de join est :
615 615
 		// array(table depart, cle depart [,cle arrivee[,condition optionnelle and ...]])
616
-		if (count($join[$cle])==2) $join[$cle][] = $join[$cle][1];
617
-		if (count($join[$cle])==3) $join[$cle][] = '';
618
-		list($t,$c,$carr,$and) = $join[$cle];
616
+		if (count($join[$cle]) == 2) $join[$cle][] = $join[$cle][1];
617
+		if (count($join[$cle]) == 3) $join[$cle][] = '';
618
+		list($t, $c, $carr, $and) = $join[$cle];
619 619
 		// si le nom de la jointure n'a pas ete specifiee, on prend Lx avec x sont rang dans la liste
620 620
 		// pour compat avec ancienne convention
621 621
 		if (is_numeric($cle))
@@ -628,13 +628,13 @@  discard block
 block discarded – undo
628 628
 		OR calculer_jointnul($cle, $where_simples)) {
629 629
 			// corriger les references non explicites dans select
630 630
 			// ou groupby
631
-			foreach($select as $i=>$s) {
631
+			foreach ($select as $i=>$s) {
632 632
 				if ($s == $c) {
633 633
 					$select[$i] = "$cle.$c AS $c";
634 634
 					break;
635 635
 				}
636 636
 			}
637
-			foreach($groupby as $i=>$g) {
637
+			foreach ($groupby as $i=>$g) {
638 638
 				if ($g == $c) {
639 639
 					$groupby[$i] = "$cle.$c";
640 640
 					break;
@@ -643,22 +643,22 @@  discard block
 block discarded – undo
643 643
 			// on garde une ecriture decomposee pour permettre une simplification ulterieure si besoin
644 644
 			// sans recours a preg_match
645 645
 			// un implode(' ',..) est fait dans reinjecte_joint un peu plus bas
646
-			$afrom[$t][$cle] = array("\n" .
647
-				(isset($from_type[$cle])?$from_type[$cle]:"INNER")." JOIN",
646
+			$afrom[$t][$cle] = array("\n".
647
+				(isset($from_type[$cle]) ? $from_type[$cle] : "INNER")." JOIN",
648 648
 				$from[$cle],
649 649
 				"AS $cle",
650 650
 				"ON (",
651 651
 				"$cle.$c",
652 652
 				"=",
653 653
 				"$t.$carr",
654
-				($and ? "AND ". $and:"") .
654
+				($and ? "AND ".$and : "").
655 655
 				")");
656
-			if (isset($afrom[$cle])){
656
+			if (isset($afrom[$cle])) {
657 657
 				$afrom[$t] = $afrom[$t] + $afrom[$cle];
658 658
 				unset($afrom[$cle]);
659 659
 			}
660
-			$equiv[]= $carr;
661
-		} else { unset($join[$cledef]);}
660
+			$equiv[] = $carr;
661
+		} else { unset($join[$cledef]); }
662 662
 		unset($from[$cle]);
663 663
 		$k--;
664 664
 	}
@@ -679,9 +679,9 @@  discard block
 block discarded – undo
679 679
 		// penser a regarder aussi la clause groubpy pour ne pas simplifier abusivement
680 680
 		// <BOUCLE10(EVENEMENTS){id_rubrique} />#TOTAL_BOUCLE<//B10>
681 681
 		
682
-	  list($t,$c) = each($from);
682
+	  list($t, $c) = each($from);
683 683
 	  reset($from);
684
-	  $e = '/\b(' . "$t\\." . join("|" . $t . '\.', $equiv) . ')\b/';
684
+	  $e = '/\b('."$t\\.".join("|".$t.'\.', $equiv).')\b/';
685 685
 	  if (!(strpos($t, ' ') OR // jointure des le depart cf boucle_doc
686 686
 		 calculer_jointnul($t, $select, $e) OR
687 687
 		 calculer_jointnul($t, $join, $e) OR
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		 calculer_jointnul($t, $having, $e))
692 692
 		 && count($afrom[$t])) {
693 693
 		 	reset($afrom[$t]);
694
-		 	list($nt,$nfrom) = each($afrom[$t]);
694
+		 	list($nt, $nfrom) = each($afrom[$t]);
695 695
 	    unset($from[$t]);
696 696
 	    $from[$nt] = $nfrom[1];
697 697
 	    unset($afrom[$t][$nt]);
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
 	    $t = $nfrom[4];
702 702
 	    $alias = "";
703 703
 	    // verifier que les deux cles sont homonymes, sinon installer un alias dans le select
704
-	    $oldcle = explode('.',$nfrom[6]);
704
+	    $oldcle = explode('.', $nfrom[6]);
705 705
 	    $oldcle = end($oldcle);
706
-	    $newcle = explode('.',$nfrom[4]);
706
+	    $newcle = explode('.', $nfrom[4]);
707 707
 	    $newcle = end($newcle);
708
-	    if ($newcle!=$oldcle){
708
+	    if ($newcle != $oldcle) {
709 709
 		    // si l'ancienne cle etait deja dans le select avec un AS
710 710
 		    // reprendre simplement ce AS
711 711
 		    $as = '/\b'.preg_quote($nfrom[6]).'\s+(AS\s+\w+)\b/';
712
-		    if (preg_match($as,implode(',',$select),$m)){
712
+		    if (preg_match($as, implode(',', $select), $m)) {
713 713
 			    $alias = "";
714 714
 		    }
715 715
 		    else
716 716
 					$alias = ", ".$nfrom[4]." AS $oldcle";
717 717
 	    }
718
-	    $select = remplacer_jointnul($t . $alias, $select, $e);
718
+	    $select = remplacer_jointnul($t.$alias, $select, $e);
719 719
 	    $join = remplacer_jointnul($t, $join, $e);
720 720
 	    $where = remplacer_jointnul($t, $where, $e);
721 721
 	    $having = remplacer_jointnul($t, $having, $e);
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	  }
725 725
 	  $from = reinjecte_joint($afrom, $from);
726 726
 	}
727
-	$GLOBALS['debug']['aucasou'] = array ($table, $id, $serveur, $requeter);
727
+	$GLOBALS['debug']['aucasou'] = array($table, $id, $serveur, $requeter);
728 728
 	$r = sql_select($select, $from, $where,
729 729
 		$groupby, array_filter($orderby), $limit, $having, $serveur, $requeter);
730 730
 	unset($GLOBALS['debug']['aucasou']);
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
  * @param string $join
738 738
  * @return string
739 739
  */
740
-function calculer_where_to_string($v, $join = 'AND'){
740
+function calculer_where_to_string($v, $join = 'AND') {
741 741
 	if (empty($v))
742 742
 		return '';
743 743
 
@@ -746,9 +746,9 @@  discard block
 block discarded – undo
746 746
 	} else {
747 747
 		$exp = "";
748 748
 		if (strtoupper($join) === 'AND')
749
-			return $exp . join(" $join ", array_map('calculer_where_to_string', $v));
749
+			return $exp.join(" $join ", array_map('calculer_where_to_string', $v));
750 750
 		else
751
-			return $exp . join($join, $v);
751
+			return $exp.join($join, $v);
752 752
 	}
753 753
 }
754 754
 
@@ -756,13 +756,13 @@  discard block
 block discarded – undo
756 756
 //condition suffisante (mais non necessaire) pour qu'une table soit utile
757 757
 
758 758
 // http://doc.spip.org/@calculer_jointnul
759
-function calculer_jointnul($cle, $exp, $equiv='')
759
+function calculer_jointnul($cle, $exp, $equiv = '')
760 760
 {
761 761
 	if (!is_array($exp)) {
762 762
 		if ($equiv) $exp = preg_replace($equiv, '', $exp);
763 763
 		return preg_match("/\\b$cle\\./", $exp);
764 764
 	} else {
765
-		foreach($exp as $v) {
765
+		foreach ($exp as $v) {
766 766
 			if (calculer_jointnul($cle, $v, $equiv)) return true;
767 767
 		}
768 768
 		return false;
@@ -773,11 +773,11 @@  discard block
 block discarded – undo
773 773
 function reinjecte_joint($afrom, $from)
774 774
 {
775 775
 	  $from_synth = array();
776
-	  foreach($from as $k=>$v){
777
-	  	$from_synth[$k]=$from[$k];
776
+	  foreach ($from as $k=>$v) {
777
+	  	$from_synth[$k] = $from[$k];
778 778
 	  	if (isset($afrom[$k])) {
779
-	  		foreach($afrom[$k] as $kk=>$vv) $afrom[$k][$kk] = implode(' ',$afrom[$k][$kk]);
780
-	  		$from_synth["$k@"]= implode(' ',$afrom[$k]);
779
+	  		foreach ($afrom[$k] as $kk=>$vv) $afrom[$k][$kk] = implode(' ', $afrom[$k][$kk]);
780
+	  		$from_synth["$k@"] = implode(' ', $afrom[$k]);
781 781
 	  		unset($afrom[$k]);
782 782
 	  	}
783 783
 	  }
@@ -785,12 +785,12 @@  discard block
 block discarded – undo
785 785
 }
786 786
 
787 787
 // http://doc.spip.org/@remplacer_jointnul
788
-function remplacer_jointnul($cle, $exp, $equiv='')
788
+function remplacer_jointnul($cle, $exp, $equiv = '')
789 789
 {
790 790
 	if (!is_array($exp)) {
791 791
 		return preg_replace($equiv, $cle, $exp);
792 792
 	} else {
793
-		foreach($exp as $k => $v) {
793
+		foreach ($exp as $k => $v) {
794 794
 		  $exp[$k] = remplacer_jointnul($cle, $v, $equiv);
795 795
 		}
796 796
 		return $exp;
@@ -799,14 +799,14 @@  discard block
 block discarded – undo
799 799
 
800 800
 // calcul du nom du squelette
801 801
 // http://doc.spip.org/@calculer_nom_fonction_squel
802
-function calculer_nom_fonction_squel($skel, $mime_type='html', $connect='')
802
+function calculer_nom_fonction_squel($skel, $mime_type = 'html', $connect = '')
803 803
 {
804 804
 	// ne pas doublonner les squelette selon qu'ils sont calcules depuis ecrire/ ou depuis la racine
805
-	if ($l=strlen(_DIR_RACINE) AND strncmp($skel,_DIR_RACINE,$l)==0)
806
-		$skel = substr($skel,strlen(_DIR_RACINE));
805
+	if ($l = strlen(_DIR_RACINE) AND strncmp($skel, _DIR_RACINE, $l) == 0)
806
+		$skel = substr($skel, strlen(_DIR_RACINE));
807 807
 	return $mime_type
808
-	. (!$connect ?  '' : preg_replace('/\W/',"_", $connect)) . '_'
809
-	. md5($GLOBALS['spip_version_code'] . ' * ' . $skel . (isset($GLOBALS['marqueur_skel'])?'*'.$GLOBALS['marqueur_skel']:''));
808
+	. (!$connect ? '' : preg_replace('/\W/', "_", $connect)).'_'
809
+	. md5($GLOBALS['spip_version_code'].' * '.$skel.(isset($GLOBALS['marqueur_skel']) ? '*'.$GLOBALS['marqueur_skel'] : ''));
810 810
 }
811 811
 
812 812
 ?>
Please login to merge, or discard this patch.
ecrire/public/tracer.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 		// A fortiori quand on demande une trace
23 23
 		$trace = isset($_GET['var_profile']) AND (autoriser('debug'));
24 24
 	}
25
-	return  $trace ?  microtime() : 0;
25
+	return  $trace ? microtime() : 0;
26 26
 }
27 27
 
28 28
 // http://doc.spip.org/@trace_query_end
29
-function trace_query_end($query, $start, $result, $erreur, $serveur=''){
29
+function trace_query_end($query, $start, $result, $erreur, $serveur = '') {
30 30
 	if ($start)
31 31
 		trace_query_chrono($start, microtime(), $query, $result, $serveur);
32 32
 	// tracer les erreurs, sauf pour select, c'est fait dans abstract_sql
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 }
37 37
 
38 38
 // http://doc.spip.org/@trace_query_chrono
39
-function trace_query_chrono($m1, $m2, $query, $result, $serveur='')
39
+function trace_query_chrono($m1, $m2, $query, $result, $serveur = '')
40 40
 {
41
-	static $tt = 0, $nb=0;
41
+	static $tt = 0, $nb = 0;
42 42
 	global $tableau_des_temps;
43 43
 
44 44
 	include_spip('inc/filtres_mini');
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	$tt += $dt;
62 62
 	$nb++;
63 63
 
64
-	$q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n<br />$2",spip_htmlentities($query));
65
-	$e =  sql_explain($query, $serveur);
66
-	$r = str_replace('Resource id ','',(is_object($result)?get_class($result):$result));
64
+	$q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n<br />$2", spip_htmlentities($query));
65
+	$e = sql_explain($query, $serveur);
66
+	$r = str_replace('Resource id ', '', (is_object($result) ? get_class($result) : $result));
67 67
 	$tableau_des_temps[] = array($dt, $nb, $boucle, $q, $e, $r, $contexte);
68 68
 }
69 69
 
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
 function chrono_requete($temps)
72 72
 {
73 73
 	$total = 0;
74
-	$hors = "<i>" . _T('zbug_hors_compilation') . "</i>";
74
+	$hors = "<i>"._T('zbug_hors_compilation')."</i>";
75 75
 	$t = $q = $n = $d = array();
76 76
 	// Totaliser les temps et completer le Explain
77 77
 	foreach ($temps as $key => $v) {
78 78
 		list($dt, $nb, $boucle, $query, $explain, $res, $contexte) = $v;
79 79
 		if (is_array($contexte)) {
80
-			$k = ($contexte[0] . " $boucle");
80
+			$k = ($contexte[0]." $boucle");
81 81
 			include_spip('public/compiler');
82 82
 			$env = reconstruire_contexte_compil($contexte);
83 83
 		} else $k = $env = $boucle;
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 		$total += $dt;
86 86
 		$t[$key] = $dt;
87 87
 		$q[$key] = $nb;
88
-		$d[$k]+= $dt;
88
+		$d[$k] += $dt;
89 89
 		if ($k) @++$n[$k];
90 90
 
91 91
 		if (!is_array($explain))
92 92
 			$explain = array();
93
-		foreach($explain as $j => $v) {
93
+		foreach ($explain as $j => $v) {
94 94
 			$explain[$j] = "<tr><th>$j</th><td>"
95
-			  . str_replace(';','<br />',$v)
95
+			  . str_replace(';', '<br />', $v)
96 96
 			  . "</td></tr>";
97 97
 		}
98 98
 		$e = "<table class='explain'>"
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 	$i = 1;
114 114
 	$t = array();
115 115
 	// Fabriquer les liens de navigations dans le tableau des temps
116
-	foreach($temps as $k => $v) {
116
+	foreach ($temps as $k => $v) {
117 117
 		$titre = strip_tags($v[2]);
118 118
 		$href = quote_amp($GLOBALS['REQUEST_URI'])."#req$i";
119 119
 
120
-		$t[$v[2]][]= "<span class='spip-debug-arg'> "
120
+		$t[$v[2]][] = "<span class='spip-debug-arg'> "
121 121
 		. "<a title='$titre' href='$href'>$i</a>"
122 122
 		. '</span>'
123
-		. ((count($t[$v[2]]) % 10 == 9) ?  "<br />" : '');
123
+		. ((count($t[$v[2]]) % 10 == 9) ? "<br />" : '');
124 124
 		$i++;
125 125
 	}
126 126
 
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	unset($d['']);
133 133
 	// Fabriquer le tableau des liens de navigation dans le grand tableau
134 134
 	foreach ($d as $k => $v) {
135
-		$d[$k] =  $n[$k] . "</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>"
136
-		  . join('',$t[$k]);
135
+		$d[$k] = $n[$k]."</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>"
136
+		  . join('', $t[$k]);
137 137
 	}
138 138
 
139 139
 	$navigation = array(_T('zbug_statistiques'),
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		. join("</td></tr>\n<tr><td>", $d)
142 142
 	  . "</td></tr>\n"
143 143
 	  .  (# _request('var_mode_objet') ? '' : 
144
-	     ("<tr><td>" .  count($temps) . "</td><td>" . _T('info_total') . '</td><td class="time">' . $total . "</td><td></td></tr>")));
144
+	     ("<tr><td>".count($temps)."</td><td>"._T('info_total').'</td><td class="time">'.$total."</td><td></td></tr>")));
145 145
 	  
146 146
 	return array($temps, $navigation);
147 147
 }
Please login to merge, or discard this patch.