Completed
Pull Request — master (#39)
by
unknown
07:42
created
ecrire/public/evaluer_page.php 3 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -33,64 +33,64 @@  discard block
 block discarded – undo
33 33
 // Cas d'une page contenant du PHP :
34 34
 if (empty($page['process_ins']) or $page['process_ins'] != 'html') {
35 35
 
36
-	include_spip('inc/lang');
36
+    include_spip('inc/lang');
37 37
 
38
-	// restaurer l'etat des notes avant calcul
39
-	if (isset($page['notes'])
40
-		and $page['notes']
41
-		and $notes = charger_fonction("notes", "inc", true)
42
-	) {
43
-		$notes($page['notes'], 'restaurer_etat');
44
-	}
45
-	ob_start();
46
-	if (strpos($page['texte'], '?xml') !== false) {
47
-		$page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']);
48
-	}
38
+    // restaurer l'etat des notes avant calcul
39
+    if (isset($page['notes'])
40
+        and $page['notes']
41
+        and $notes = charger_fonction("notes", "inc", true)
42
+    ) {
43
+        $notes($page['notes'], 'restaurer_etat');
44
+    }
45
+    ob_start();
46
+    if (strpos($page['texte'], '?xml') !== false) {
47
+        $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']);
48
+    }
49 49
 
50
-	try {
51
-		$res = eval('?' . '>' . $page['texte']);
52
-		// error catching 5.2<=PHP<7
53
-		if ($res === false
54
-		  and function_exists('error_get_last')
55
-		  and ($erreur = error_get_last()) ) {
56
-			$code = $page['texte'];
57
-			$GLOBALS['numero_ligne_php'] = 1;
58
-			if (!function_exists('numerote_ligne_php')){
59
-				function numerote_ligne_php($match){
60
-					$GLOBALS['numero_ligne_php']++;
61
-					return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/";
62
-				}
63
-			}
64
-			$code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
65
-			$code = trim(highlight_string($code,true));
66
-			erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang']));
67
-			$page['texte'] = "<!-- Erreur -->";
68
-		}
69
-		else {
70
-			$page['texte'] = ob_get_contents();
71
-		}
72
-	}
73
-	catch (Exception $e){
74
-		$code = $page['texte'];
75
-		$GLOBALS['numero_ligne_php'] = 1;
76
-		if (!function_exists('numerote_ligne_php')){
77
-			function numerote_ligne_php($match){
78
-				$GLOBALS['numero_ligne_php']++;
79
-				return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/";
80
-			}
81
-		}
82
-		$code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
83
-		$code = trim(highlight_string($code,true));
84
-		erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']));
85
-		$page['texte'] = "<!-- Erreur -->";
86
-	}
87
-	ob_end_clean();
50
+    try {
51
+        $res = eval('?' . '>' . $page['texte']);
52
+        // error catching 5.2<=PHP<7
53
+        if ($res === false
54
+          and function_exists('error_get_last')
55
+          and ($erreur = error_get_last()) ) {
56
+            $code = $page['texte'];
57
+            $GLOBALS['numero_ligne_php'] = 1;
58
+            if (!function_exists('numerote_ligne_php')){
59
+                function numerote_ligne_php($match){
60
+                    $GLOBALS['numero_ligne_php']++;
61
+                    return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/";
62
+                }
63
+            }
64
+            $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
65
+            $code = trim(highlight_string($code,true));
66
+            erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang']));
67
+            $page['texte'] = "<!-- Erreur -->";
68
+        }
69
+        else {
70
+            $page['texte'] = ob_get_contents();
71
+        }
72
+    }
73
+    catch (Exception $e){
74
+        $code = $page['texte'];
75
+        $GLOBALS['numero_ligne_php'] = 1;
76
+        if (!function_exists('numerote_ligne_php')){
77
+            function numerote_ligne_php($match){
78
+                $GLOBALS['numero_ligne_php']++;
79
+                return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/";
80
+            }
81
+        }
82
+        $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
83
+        $code = trim(highlight_string($code,true));
84
+        erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']));
85
+        $page['texte'] = "<!-- Erreur -->";
86
+    }
87
+    ob_end_clean();
88 88
 
89
-	$page['process_ins'] = 'html';
89
+    $page['process_ins'] = 'html';
90 90
 
91
-	if (strpos($page['texte'], '?xml') !== false) {
92
-		$page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']);
93
-	}
91
+    if (strpos($page['texte'], '?xml') !== false) {
92
+        $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']);
93
+    }
94 94
 }
95 95
 
96 96
 page_base_href($page['texte']);
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -44,44 +44,44 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 	ob_start();
46 46
 	if (strpos($page['texte'], '?xml') !== false) {
47
-		$page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']);
47
+		$page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']);
48 48
 	}
49 49
 
50 50
 	try {
51
-		$res = eval('?' . '>' . $page['texte']);
51
+		$res = eval('?'.'>'.$page['texte']);
52 52
 		// error catching 5.2<=PHP<7
53 53
 		if ($res === false
54 54
 		  and function_exists('error_get_last')
55
-		  and ($erreur = error_get_last()) ) {
55
+		  and ($erreur = error_get_last())) {
56 56
 			$code = $page['texte'];
57 57
 			$GLOBALS['numero_ligne_php'] = 1;
58
-			if (!function_exists('numerote_ligne_php')){
59
-				function numerote_ligne_php($match){
58
+			if (!function_exists('numerote_ligne_php')) {
59
+				function numerote_ligne_php($match) {
60 60
 					$GLOBALS['numero_ligne_php']++;
61
-					return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/";
61
+					return "\n/*".str_pad($GLOBALS['numero_ligne_php'], 3, "0", STR_PAD_LEFT)."*/";
62 62
 				}
63 63
 			}
64
-			$code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
65
-			$code = trim(highlight_string($code,true));
66
-			erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang']));
64
+			$code = "/*001*/".preg_replace_callback(",\n,", "numerote_ligne_php", $code);
65
+			$code = trim(highlight_string($code, true));
66
+			erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code, array($page['source'], '', $erreur['file'], '', $GLOBALS['spip_lang']));
67 67
 			$page['texte'] = "<!-- Erreur -->";
68 68
 		}
69 69
 		else {
70 70
 			$page['texte'] = ob_get_contents();
71 71
 		}
72 72
 	}
73
-	catch (Exception $e){
73
+	catch (Exception $e) {
74 74
 		$code = $page['texte'];
75 75
 		$GLOBALS['numero_ligne_php'] = 1;
76
-		if (!function_exists('numerote_ligne_php')){
77
-			function numerote_ligne_php($match){
76
+		if (!function_exists('numerote_ligne_php')) {
77
+			function numerote_ligne_php($match) {
78 78
 				$GLOBALS['numero_ligne_php']++;
79
-				return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/";
79
+				return "\n/*".str_pad($GLOBALS['numero_ligne_php'], 3, "0", STR_PAD_LEFT)."*/";
80 80
 			}
81 81
 		}
82
-		$code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
83
-		$code = trim(highlight_string($code,true));
84
-		erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']));
82
+		$code = "/*001*/".preg_replace_callback(",\n,", "numerote_ligne_php", $code);
83
+		$code = trim(highlight_string($code, true));
84
+		erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code, array($page['source'], '', $e->getFile(), '', $GLOBALS['spip_lang']));
85 85
 		$page['texte'] = "<!-- Erreur -->";
86 86
 	}
87 87
 	ob_end_clean();
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$page['process_ins'] = 'html';
90 90
 
91 91
 	if (strpos($page['texte'], '?xml') !== false) {
92
-		$page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']);
92
+		$page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']);
93 93
 	}
94 94
 }
95 95
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,12 +65,10 @@
 block discarded – undo
65 65
 			$code = trim(highlight_string($code,true));
66 66
 			erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang']));
67 67
 			$page['texte'] = "<!-- Erreur -->";
68
-		}
69
-		else {
68
+		} else {
70 69
 			$page['texte'] = ob_get_contents();
71 70
 		}
72
-	}
73
-	catch (Exception $e){
71
+	} catch (Exception $e){
74 72
 		$code = $page['texte'];
75 73
 		$GLOBALS['numero_ligne_php'] = 1;
76 74
 		if (!function_exists('numerote_ligne_php')){
Please login to merge, or discard this patch.
ecrire/public/tracer.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
 
78 78
 function chrono_requete($temps) {
79 79
 	$total = 0;
80
-	$hors = "<i>" . _T('zbug_hors_compilation') . "</i>";
80
+	$hors = "<i>"._T('zbug_hors_compilation')."</i>";
81 81
 	$t = $q = $n = $d = array();
82 82
 	// Totaliser les temps et completer le Explain
83 83
 	foreach ($temps as $key => $v) {
84 84
 		list($dt, $nb, $boucle, $query, $explain, $res, $contexte) = $v;
85 85
 		if (is_array($contexte)) {
86
-			$k = ($contexte[0] . " $boucle");
86
+			$k = ($contexte[0]." $boucle");
87 87
 			include_spip('public/compiler');
88 88
 			$env = reconstruire_contexte_compil($contexte);
89 89
 		} else {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	// Fabriquer les liens de navigations dans le tableau des temps
130 130
 	foreach ($temps as $k => $v) {
131 131
 		$titre = strip_tags($v[2]);
132
-		$href = quote_amp($GLOBALS['REQUEST_URI']) . "#req$i";
132
+		$href = quote_amp($GLOBALS['REQUEST_URI'])."#req$i";
133 133
 
134 134
 		if (!isset($t[$v[2]])) {
135 135
 			$t[$v[2]] = array();
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	unset($d['']);
150 150
 	// Fabriquer le tableau des liens de navigation dans le grand tableau
151 151
 	foreach ($d as $k => $v) {
152
-		$d[$k] = $n[$k] . "</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>"
152
+		$d[$k] = $n[$k]."</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>"
153 153
 			. join('', $t[$k]);
154 154
 	}
155 155
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		. join("</td></tr>\n<tr><td>", $d)
160 160
 		. "</td></tr>\n"
161 161
 		. (# _request('var_mode_objet') ? '' :
162
-		("<tr><td>" . count($temps) . "</td><td>" . _T('info_total') . '</td><td class="time">' . $total . "</td><td></td></tr>"))
162
+		("<tr><td>".count($temps)."</td><td>"._T('info_total').'</td><td class="time">'.$total."</td><td></td></tr>"))
163 163
 	);
164 164
 
165 165
 	return array($temps, $navigation);
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -11,155 +11,155 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 // http://code.spip.net/@trace_query_start
18 18
 function trace_query_start() {
19
-	static $trace = '?';
20
-	if ($trace === '?') {
21
-		include_spip('inc/autoriser');
22
-		// gare au bouclage sur calcul de droits au premier appel
23
-		// A fortiori quand on demande une trace
24
-		$trace = isset($_GET['var_profile']) and (autoriser('debug'));
25
-	}
26
-
27
-	return $trace ? microtime() : 0;
19
+    static $trace = '?';
20
+    if ($trace === '?') {
21
+        include_spip('inc/autoriser');
22
+        // gare au bouclage sur calcul de droits au premier appel
23
+        // A fortiori quand on demande une trace
24
+        $trace = isset($_GET['var_profile']) and (autoriser('debug'));
25
+    }
26
+
27
+    return $trace ? microtime() : 0;
28 28
 }
29 29
 
30 30
 // http://code.spip.net/@trace_query_end
31 31
 function trace_query_end($query, $start, $result, $erreur, $serveur = '') {
32
-	if ($start) {
33
-		trace_query_chrono($start, microtime(), $query, $result, $serveur);
34
-	}
35
-	// tracer les erreurs, sauf pour select, c'est fait dans abstract_sql
36
-	if ($erreur and !preg_match('/^select\b/i', $query)) {
37
-		erreur_squelette(array(sql_errno($serveur), $erreur, $query));
38
-	}
39
-
40
-	return $result;
32
+    if ($start) {
33
+        trace_query_chrono($start, microtime(), $query, $result, $serveur);
34
+    }
35
+    // tracer les erreurs, sauf pour select, c'est fait dans abstract_sql
36
+    if ($erreur and !preg_match('/^select\b/i', $query)) {
37
+        erreur_squelette(array(sql_errno($serveur), $erreur, $query));
38
+    }
39
+
40
+    return $result;
41 41
 }
42 42
 
43 43
 // http://code.spip.net/@trace_query_chrono
44 44
 function trace_query_chrono($m1, $m2, $query, $result, $serveur = '') {
45
-	include_spip('inc/filtres_mini');
46
-	static $tt = 0, $nb = 0;
47
-
48
-	$x = _request('var_mode_objet');
49
-	if (isset($GLOBALS['debug']['aucasou'])) {
50
-		list(, $boucle, $serveur, $contexte) = $GLOBALS['debug']['aucasou'];
51
-		if ($x and !preg_match("/$boucle\$/", $x)) {
52
-			return;
53
-		}
54
-		if ($serveur) {
55
-			$boucle .= " ($serveur)";
56
-		}
57
-		$boucle = "<b>$boucle</b>";
58
-	} else {
59
-		if ($x) {
60
-			return;
61
-		}
62
-		$boucle = $contexte = '';
63
-	}
64
-
65
-	list($usec, $sec) = explode(" ", $m1);
66
-	list($usec2, $sec2) = explode(" ", $m2);
67
-	$dt = $sec2 + $usec2 - $sec - $usec;
68
-	$tt += $dt;
69
-	$nb++;
70
-
71
-	$q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n<br />$2", spip_htmlentities($query));
72
-	$e = sql_explain($query, $serveur);
73
-	$r = str_replace('Resource id ', '', (is_object($result) ? get_class($result) : $result));
74
-	$GLOBALS['tableau_des_temps'][] = array($dt, $nb, $boucle, $q, $e, $r, $contexte);
45
+    include_spip('inc/filtres_mini');
46
+    static $tt = 0, $nb = 0;
47
+
48
+    $x = _request('var_mode_objet');
49
+    if (isset($GLOBALS['debug']['aucasou'])) {
50
+        list(, $boucle, $serveur, $contexte) = $GLOBALS['debug']['aucasou'];
51
+        if ($x and !preg_match("/$boucle\$/", $x)) {
52
+            return;
53
+        }
54
+        if ($serveur) {
55
+            $boucle .= " ($serveur)";
56
+        }
57
+        $boucle = "<b>$boucle</b>";
58
+    } else {
59
+        if ($x) {
60
+            return;
61
+        }
62
+        $boucle = $contexte = '';
63
+    }
64
+
65
+    list($usec, $sec) = explode(" ", $m1);
66
+    list($usec2, $sec2) = explode(" ", $m2);
67
+    $dt = $sec2 + $usec2 - $sec - $usec;
68
+    $tt += $dt;
69
+    $nb++;
70
+
71
+    $q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n<br />$2", spip_htmlentities($query));
72
+    $e = sql_explain($query, $serveur);
73
+    $r = str_replace('Resource id ', '', (is_object($result) ? get_class($result) : $result));
74
+    $GLOBALS['tableau_des_temps'][] = array($dt, $nb, $boucle, $q, $e, $r, $contexte);
75 75
 }
76 76
 
77 77
 
78 78
 function chrono_requete($temps) {
79
-	$total = 0;
80
-	$hors = "<i>" . _T('zbug_hors_compilation') . "</i>";
81
-	$t = $q = $n = $d = array();
82
-	// Totaliser les temps et completer le Explain
83
-	foreach ($temps as $key => $v) {
84
-		list($dt, $nb, $boucle, $query, $explain, $res, $contexte) = $v;
85
-		if (is_array($contexte)) {
86
-			$k = ($contexte[0] . " $boucle");
87
-			include_spip('public/compiler');
88
-			$env = reconstruire_contexte_compil($contexte);
89
-		} else {
90
-			$k = $env = $boucle;
91
-		}
92
-
93
-		$total += $dt;
94
-		$t[$key] = $dt;
95
-		$q[$key] = $nb;
96
-		if (!isset($d[$k])) {
97
-			$d[$k] = 0;
98
-			$n[$k] = 0;
99
-		}
100
-		$d[$k] += $dt;
101
-		++$n[$k];
102
-
103
-		if (!is_array($explain)) {
104
-			$explain = array();
105
-		}
106
-		foreach ($explain as $j => $v) {
107
-			$explain[$j] = "<tr><th>$j</th><td>"
108
-				. str_replace(';', '<br />', $v)
109
-				. "</td></tr>";
110
-		}
111
-		$e = "<table class='explain'>"
112
-			. "<caption>"
113
-			. $query
114
-			. "</caption>"
115
-			. "<tr><th>Time</th><td>$dt</td></tr>"
116
-			. "<tr><th>Order</th><td>$nb</td></tr>"
117
-			. "<tr><th>Res</th><td>$res</td></tr>"
118
-			. join('', $explain)
119
-			. "</table>";
120
-
121
-		$temps[$key] = array($e, $env, $k);
122
-	}
123
-	// Trier par temps d'execution decroissant
124
-	array_multisort($t, SORT_DESC, $q, $temps);
125
-	arsort($d);
126
-	$i = 1;
127
-	$t = array();
128
-	// Fabriquer les liens de navigations dans le tableau des temps
129
-	foreach ($temps as $k => $v) {
130
-		$titre = strip_tags($v[2]);
131
-		$href = quote_amp($GLOBALS['REQUEST_URI']) . "#req$i";
132
-
133
-		if (!isset($t[$v[2]])) {
134
-			$t[$v[2]] = array();
135
-		}
136
-		$t[$v[2]][] = "<span class='spip-debug-arg'> "
137
-			. "<a title='$titre' href='$href'>$i</a>"
138
-			. '</span>'
139
-			. ((count($t[$v[2]]) % 10 == 9) ? "<br />" : '');
140
-		$i++;
141
-	}
142
-
143
-	if ($d['']) {
144
-		$d[$hors] = $d[''];
145
-		$n[$hors] = $n[''];
146
-		$t[$hors] = $t[''];
147
-	}
148
-	unset($d['']);
149
-	// Fabriquer le tableau des liens de navigation dans le grand tableau
150
-	foreach ($d as $k => $v) {
151
-		$d[$k] = $n[$k] . "</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>"
152
-			. join('', $t[$k]);
153
-	}
154
-
155
-	$navigation = array(
156
-		_T('zbug_statistiques'),
157
-		"<tr><td>"
158
-		. join("</td></tr>\n<tr><td>", $d)
159
-		. "</td></tr>\n"
160
-		. (# _request('var_mode_objet') ? '' :
161
-		("<tr><td>" . count($temps) . "</td><td>" . _T('info_total') . '</td><td class="time">' . $total . "</td><td></td></tr>"))
162
-	);
163
-
164
-	return array($temps, $navigation);
79
+    $total = 0;
80
+    $hors = "<i>" . _T('zbug_hors_compilation') . "</i>";
81
+    $t = $q = $n = $d = array();
82
+    // Totaliser les temps et completer le Explain
83
+    foreach ($temps as $key => $v) {
84
+        list($dt, $nb, $boucle, $query, $explain, $res, $contexte) = $v;
85
+        if (is_array($contexte)) {
86
+            $k = ($contexte[0] . " $boucle");
87
+            include_spip('public/compiler');
88
+            $env = reconstruire_contexte_compil($contexte);
89
+        } else {
90
+            $k = $env = $boucle;
91
+        }
92
+
93
+        $total += $dt;
94
+        $t[$key] = $dt;
95
+        $q[$key] = $nb;
96
+        if (!isset($d[$k])) {
97
+            $d[$k] = 0;
98
+            $n[$k] = 0;
99
+        }
100
+        $d[$k] += $dt;
101
+        ++$n[$k];
102
+
103
+        if (!is_array($explain)) {
104
+            $explain = array();
105
+        }
106
+        foreach ($explain as $j => $v) {
107
+            $explain[$j] = "<tr><th>$j</th><td>"
108
+                . str_replace(';', '<br />', $v)
109
+                . "</td></tr>";
110
+        }
111
+        $e = "<table class='explain'>"
112
+            . "<caption>"
113
+            . $query
114
+            . "</caption>"
115
+            . "<tr><th>Time</th><td>$dt</td></tr>"
116
+            . "<tr><th>Order</th><td>$nb</td></tr>"
117
+            . "<tr><th>Res</th><td>$res</td></tr>"
118
+            . join('', $explain)
119
+            . "</table>";
120
+
121
+        $temps[$key] = array($e, $env, $k);
122
+    }
123
+    // Trier par temps d'execution decroissant
124
+    array_multisort($t, SORT_DESC, $q, $temps);
125
+    arsort($d);
126
+    $i = 1;
127
+    $t = array();
128
+    // Fabriquer les liens de navigations dans le tableau des temps
129
+    foreach ($temps as $k => $v) {
130
+        $titre = strip_tags($v[2]);
131
+        $href = quote_amp($GLOBALS['REQUEST_URI']) . "#req$i";
132
+
133
+        if (!isset($t[$v[2]])) {
134
+            $t[$v[2]] = array();
135
+        }
136
+        $t[$v[2]][] = "<span class='spip-debug-arg'> "
137
+            . "<a title='$titre' href='$href'>$i</a>"
138
+            . '</span>'
139
+            . ((count($t[$v[2]]) % 10 == 9) ? "<br />" : '');
140
+        $i++;
141
+    }
142
+
143
+    if ($d['']) {
144
+        $d[$hors] = $d[''];
145
+        $n[$hors] = $n[''];
146
+        $t[$hors] = $t[''];
147
+    }
148
+    unset($d['']);
149
+    // Fabriquer le tableau des liens de navigation dans le grand tableau
150
+    foreach ($d as $k => $v) {
151
+        $d[$k] = $n[$k] . "</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>"
152
+            . join('', $t[$k]);
153
+    }
154
+
155
+    $navigation = array(
156
+        _T('zbug_statistiques'),
157
+        "<tr><td>"
158
+        . join("</td></tr>\n<tr><td>", $d)
159
+        . "</td></tr>\n"
160
+        . (# _request('var_mode_objet') ? '' :
161
+        ("<tr><td>" . count($temps) . "</td><td>" . _T('info_total') . '</td><td class="time">' . $total . "</td><td></td></tr>"))
162
+    );
163
+
164
+    return array($temps, $navigation);
165 165
 }
Please login to merge, or discard this patch.
ecrire/public/admin.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -34,32 +34,32 @@  discard block
 block discarded – undo
34 34
  *     Contenu HTML, avec boutons d'administrations et sa CSS
35 35
  **/
36 36
 function affiche_boutons_admin($contenu) {
37
-	include_spip('inc/filtres');
37
+    include_spip('inc/filtres');
38 38
 
39
-	// Inserer le css d'admin
40
-	$css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css')))
41
-		. "' type='text/css' />\n";
42
-	if ($f = find_in_path('spip_admin_perso.css')) {
43
-		$css .= "<link rel='stylesheet' href='"
44
-			. url_absolue(direction_css($f)) . "' type='text/css' />\n";
45
-	}
39
+    // Inserer le css d'admin
40
+    $css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css')))
41
+        . "' type='text/css' />\n";
42
+    if ($f = find_in_path('spip_admin_perso.css')) {
43
+        $css .= "<link rel='stylesheet' href='"
44
+            . url_absolue(direction_css($f)) . "' type='text/css' />\n";
45
+    }
46 46
 
47
-	($pos = stripos($contenu, '</head>'))
48
-	|| ($pos = stripos($contenu, '<body>'))
49
-	|| ($pos = 0);
50
-	$contenu = substr_replace($contenu, $css, $pos, 0);
47
+    ($pos = stripos($contenu, '</head>'))
48
+    || ($pos = stripos($contenu, '<body>'))
49
+    || ($pos = 0);
50
+    $contenu = substr_replace($contenu, $css, $pos, 0);
51 51
 
52 52
 
53
-	// Inserer la balise #FORMULAIRE_ADMIN, en float
54
-	$boutons_admin = inclure_balise_dynamique(
55
-		balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'),
56
-		false);
53
+    // Inserer la balise #FORMULAIRE_ADMIN, en float
54
+    $boutons_admin = inclure_balise_dynamique(
55
+        balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'),
56
+        false);
57 57
 
58
-	($pos = strripos($contenu, '</body>'))
59
-	|| ($pos = strripos($contenu, '</html>'))
60
-	|| ($pos = strlen($contenu));
61
-	$contenu = substr_replace($contenu, $boutons_admin, $pos, 0);
58
+    ($pos = strripos($contenu, '</body>'))
59
+    || ($pos = strripos($contenu, '</html>'))
60
+    || ($pos = strlen($contenu));
61
+    $contenu = substr_replace($contenu, $boutons_admin, $pos, 0);
62 62
 
63 63
 
64
-	return $contenu;
64
+    return $contenu;
65 65
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@
 block discarded – undo
37 37
 	include_spip('inc/filtres');
38 38
 
39 39
 	// Inserer le css d'admin
40
-	$css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css')))
40
+	$css = "<link rel='stylesheet' href='".url_absolue(direction_css(find_in_path('spip_admin.css')))
41 41
 		. "' type='text/css' />\n";
42 42
 	if ($f = find_in_path('spip_admin_perso.css')) {
43 43
 		$css .= "<link rel='stylesheet' href='"
44
-			. url_absolue(direction_css($f)) . "' type='text/css' />\n";
44
+			. url_absolue(direction_css($f))."' type='text/css' />\n";
45 45
 	}
46 46
 
47 47
 	($pos = stripos($contenu, '</head>'))
Please login to merge, or discard this patch.
ecrire/public/format_html.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -11,124 +11,124 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function format_boucle_html($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) {
18
-	$avant = $avant ? "<B$nom>$avant" : "";
19
-	$apres = $apres ? "$apres</B$nom>" : "";
20
-	$altern = $altern ? "$altern<//B$nom>" : "";
21
-	if (!$corps) {
22
-		$corps = " />";
23
-	} else {
24
-		$corps = ">$corps</BOUCLE$nom>";
25
-	}
26
-
27
-	return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern";
18
+    $avant = $avant ? "<B$nom>$avant" : "";
19
+    $apres = $apres ? "$apres</B$nom>" : "";
20
+    $altern = $altern ? "$altern<//B$nom>" : "";
21
+    if (!$corps) {
22
+        $corps = " />";
23
+    } else {
24
+        $corps = ">$corps</BOUCLE$nom>";
25
+    }
26
+
27
+    return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern";
28 28
 }
29 29
 
30 30
 function format_inclure_html($file, $args, $prof) {
31
-	if (strpos($file, '#') === false) {
32
-		$t = $file ? ("(" . $file . ")") : "";
33
-	} else {
34
-		$t = "{fond=" . $file . '}';
35
-	}
36
-	$args = !$args ? '' : ("{" . join(", ", $args) . "}");
37
-
38
-	return ("<INCLURE" . $t . $args . ">");
31
+    if (strpos($file, '#') === false) {
32
+        $t = $file ? ("(" . $file . ")") : "";
33
+    } else {
34
+        $t = "{fond=" . $file . '}';
35
+    }
36
+    $args = !$args ? '' : ("{" . join(", ", $args) . "}");
37
+
38
+    return ("<INCLURE" . $t . $args . ">");
39 39
 }
40 40
 
41 41
 function format_polyglotte_html($args, $prof) {
42
-	$contenu = array();
43
-	foreach ($args as $l => $t) {
44
-		$contenu[] = ($l ? "[$l]" : '') . $t;
45
-	}
42
+    $contenu = array();
43
+    foreach ($args as $l => $t) {
44
+        $contenu[] = ($l ? "[$l]" : '') . $t;
45
+    }
46 46
 
47
-	return ("<multi>" . join(" ", $contenu) . "</multi>");
47
+    return ("<multi>" . join(" ", $contenu) . "</multi>");
48 48
 }
49 49
 
50 50
 function format_idiome_html($nom, $module, $args, $filtres, $prof) {
51
-	foreach ($args as $k => $v) {
52
-		$args[$k] = "$k=$v";
53
-	}
54
-	$args = (!$args ? '' : ('{' . join(',', $args) . '}'));
51
+    foreach ($args as $k => $v) {
52
+        $args[$k] = "$k=$v";
53
+    }
54
+    $args = (!$args ? '' : ('{' . join(',', $args) . '}'));
55 55
 
56
-	return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>");
56
+    return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>");
57 57
 }
58 58
 
59 59
 function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) {
60
-	$nom = "#"
61
-		. ($boucle ? ($boucle . ":") : "")
62
-		. $nom
63
-		. $etoile
64
-		. $args
65
-		. $filtres;
60
+    $nom = "#"
61
+        . ($boucle ? ($boucle . ":") : "")
62
+        . $nom
63
+        . $etoile
64
+        . $args
65
+        . $filtres;
66 66
 
67
-	// Determiner si c'est un champ etendu, 
67
+    // Determiner si c'est un champ etendu, 
68 68
 
69
-	$s = ($avant or $apres or $filtres
70
-		or (strpos($args, '(#') !== false));
69
+    $s = ($avant or $apres or $filtres
70
+        or (strpos($args, '(#') !== false));
71 71
 
72
-	return ($s ? "[$avant($nom)$apres]" : $nom);
72
+    return ($s ? "[$avant($nom)$apres]" : $nom);
73 73
 }
74 74
 
75 75
 function format_critere_html($critere) {
76
-	foreach ($critere as $k => $crit) {
77
-		$crit_s = '';
78
-		foreach ($crit as $operande) {
79
-			list($type, $valeur) = $operande;
80
-			if ($type == 'champ' and $valeur[0] == '[') {
81
-				$valeur = substr($valeur, 1, -1);
82
-				if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) {
83
-					$valeur = substr($valeur, 1, -1);
84
-				}
85
-			}
86
-			$crit_s .= $valeur;
87
-		}
88
-		$critere[$k] = $crit_s;
89
-	}
90
-
91
-	return (!$critere ? "" : ("{" . join(",", $critere) . "}"));
76
+    foreach ($critere as $k => $crit) {
77
+        $crit_s = '';
78
+        foreach ($crit as $operande) {
79
+            list($type, $valeur) = $operande;
80
+            if ($type == 'champ' and $valeur[0] == '[') {
81
+                $valeur = substr($valeur, 1, -1);
82
+                if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) {
83
+                    $valeur = substr($valeur, 1, -1);
84
+                }
85
+            }
86
+            $crit_s .= $valeur;
87
+        }
88
+        $critere[$k] = $crit_s;
89
+    }
90
+
91
+    return (!$critere ? "" : ("{" . join(",", $critere) . "}"));
92 92
 }
93 93
 
94 94
 function format_liste_html($fonc, $args, $prof) {
95
-	return ((($fonc !== '') ? "|$fonc" : $fonc)
96
-		. (!$args ? "" : ("{" . join(",", $args) . "}")));
95
+    return ((($fonc !== '') ? "|$fonc" : $fonc)
96
+        . (!$args ? "" : ("{" . join(",", $args) . "}")));
97 97
 }
98 98
 
99 99
 // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes
100 100
 function format_suite_html($args) {
101
-	for ($i = 0; $i < count($args) - 1; $i++) {
102
-		list($texte, $type) = $args[$i];
103
-		list($texte2, $type2) = $args[$i + 1];
104
-		if (!$texte or !$texte2) {
105
-			continue;
106
-		}
107
-		$c1 = substr($texte, -1);
108
-		if ($type2 !== 'texte') {
109
-			// si un texte se termine par ( et est suivi d'un champ
110
-			// ou assimiles, forcer la notation pleine
111
-			if ($c1 == '(' and substr($texte2, 0, 1) == '#') {
112
-				$args[$i + 1][0] = '[(' . $texte2 . ')]';
113
-			}
114
-		} else {
115
-			if ($type == 'texte') {
116
-				continue;
117
-			}
118
-			// si un champ ou assimiles est suivi d'un texte
119
-			// et si celui-ci commence par un caractere de champ
120
-			// forcer la notation pleine
121
-			if (($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|')
122
-				or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2))
123
-			) {
124
-				$args[$i][0] = '[(' . $texte . ')]';
125
-			}
126
-		}
127
-	}
128
-
129
-	return join("", array_map('array_shift', $args));
101
+    for ($i = 0; $i < count($args) - 1; $i++) {
102
+        list($texte, $type) = $args[$i];
103
+        list($texte2, $type2) = $args[$i + 1];
104
+        if (!$texte or !$texte2) {
105
+            continue;
106
+        }
107
+        $c1 = substr($texte, -1);
108
+        if ($type2 !== 'texte') {
109
+            // si un texte se termine par ( et est suivi d'un champ
110
+            // ou assimiles, forcer la notation pleine
111
+            if ($c1 == '(' and substr($texte2, 0, 1) == '#') {
112
+                $args[$i + 1][0] = '[(' . $texte2 . ')]';
113
+            }
114
+        } else {
115
+            if ($type == 'texte') {
116
+                continue;
117
+            }
118
+            // si un champ ou assimiles est suivi d'un texte
119
+            // et si celui-ci commence par un caractere de champ
120
+            // forcer la notation pleine
121
+            if (($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|')
122
+                or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2))
123
+            ) {
124
+                $args[$i][0] = '[(' . $texte . ')]';
125
+            }
126
+        }
127
+    }
128
+
129
+    return join("", array_map('array_shift', $args));
130 130
 }
131 131
 
132 132
 function format_texte_html($texte) {
133
-	return $texte;
133
+    return $texte;
134 134
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,36 +29,36 @@  discard block
 block discarded – undo
29 29
 
30 30
 function format_inclure_html($file, $args, $prof) {
31 31
 	if (strpos($file, '#') === false) {
32
-		$t = $file ? ("(" . $file . ")") : "";
32
+		$t = $file ? ("(".$file.")") : "";
33 33
 	} else {
34
-		$t = "{fond=" . $file . '}';
34
+		$t = "{fond=".$file.'}';
35 35
 	}
36
-	$args = !$args ? '' : ("{" . join(", ", $args) . "}");
36
+	$args = !$args ? '' : ("{".join(", ", $args)."}");
37 37
 
38
-	return ("<INCLURE" . $t . $args . ">");
38
+	return ("<INCLURE".$t.$args.">");
39 39
 }
40 40
 
41 41
 function format_polyglotte_html($args, $prof) {
42 42
 	$contenu = array();
43 43
 	foreach ($args as $l => $t) {
44
-		$contenu[] = ($l ? "[$l]" : '') . $t;
44
+		$contenu[] = ($l ? "[$l]" : '').$t;
45 45
 	}
46 46
 
47
-	return ("<multi>" . join(" ", $contenu) . "</multi>");
47
+	return ("<multi>".join(" ", $contenu)."</multi>");
48 48
 }
49 49
 
50 50
 function format_idiome_html($nom, $module, $args, $filtres, $prof) {
51 51
 	foreach ($args as $k => $v) {
52 52
 		$args[$k] = "$k=$v";
53 53
 	}
54
-	$args = (!$args ? '' : ('{' . join(',', $args) . '}'));
54
+	$args = (!$args ? '' : ('{'.join(',', $args).'}'));
55 55
 
56
-	return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>");
56
+	return ("<:".($module ? "$module:" : "").$nom.$args.$filtres.":>");
57 57
 }
58 58
 
59 59
 function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) {
60 60
 	$nom = "#"
61
-		. ($boucle ? ($boucle . ":") : "")
61
+		. ($boucle ? ($boucle.":") : "")
62 62
 		. $nom
63 63
 		. $etoile
64 64
 		. $args
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 		$critere[$k] = $crit_s;
89 89
 	}
90 90
 
91
-	return (!$critere ? "" : ("{" . join(",", $critere) . "}"));
91
+	return (!$critere ? "" : ("{".join(",", $critere)."}"));
92 92
 }
93 93
 
94 94
 function format_liste_html($fonc, $args, $prof) {
95 95
 	return ((($fonc !== '') ? "|$fonc" : $fonc)
96
-		. (!$args ? "" : ("{" . join(",", $args) . "}")));
96
+		. (!$args ? "" : ("{".join(",", $args)."}")));
97 97
 }
98 98
 
99 99
 // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			// si un texte se termine par ( et est suivi d'un champ
110 110
 			// ou assimiles, forcer la notation pleine
111 111
 			if ($c1 == '(' and substr($texte2, 0, 1) == '#') {
112
-				$args[$i + 1][0] = '[(' . $texte2 . ')]';
112
+				$args[$i + 1][0] = '[('.$texte2.')]';
113 113
 			}
114 114
 		} else {
115 115
 			if ($type == 'texte') {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			if (($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|')
122 122
 				or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2))
123 123
 			) {
124
-				$args[$i][0] = '[(' . $texte . ')]';
124
+				$args[$i][0] = '[('.$texte.')]';
125 125
 			}
126 126
 		}
127 127
 	}
Please login to merge, or discard this patch.
ecrire/public/assembler.php 3 patches
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -469,9 +469,11 @@  discard block
 block discarded – undo
469 469
 				$contexte[$var] = $val;
470 470
 			} else {
471 471
 				$args = explode('=', $val);
472
-				if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args
472
+				if (count($args) >= 2) {
473
+				    // Flashvars=arg1=machin&arg2=truc genere plus de deux args
473 474
 				{
474 475
 					$contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1);
476
+				}
475 477
 				} else // notation abregee
476 478
 				{
477 479
 					$contexte[trim($val)] = trim($val);
@@ -626,8 +628,8 @@  discard block
 block discarded – undo
626 628
 function page_base_href(&$texte) {
627 629
 	static $set_html_base = null;
628 630
 	if (is_null($set_html_base)) {
629
-		if (!defined('_SET_HTML_BASE'))
630
-			// si la profondeur est superieure a 1
631
+		if (!defined('_SET_HTML_BASE')) {
632
+					// si la profondeur est superieure a 1
631 633
 			// est que ce n'est pas une url page ni une url action
632 634
 			// activer par defaut
633 635
 		{
@@ -635,6 +637,7 @@  discard block
 block discarded – undo
635 637
 				$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
636 638
 				and _request(_SPIP_PAGE) !== 'login'
637 639
 				and !_request('action')) ? true : false);
640
+		}
638 641
 		} else {
639 642
 			$set_html_base = _SET_HTML_BASE;
640 643
 		}
@@ -688,8 +691,10 @@  discard block
 block discarded – undo
688 691
 // et demarrent par X-Spip-...
689 692
 // http://code.spip.net/@envoyer_entetes
690 693
 function envoyer_entetes($entetes) {
691
-	foreach ($entetes as $k => $v) #	if (strncmp($k, 'X-Spip-', 7))
694
+	foreach ($entetes as $k => $v) {
695
+	    #	if (strncmp($k, 'X-Spip-', 7))
692 696
 	{
693 697
 		@header(strlen($v) ? "$k: $v" : $k);
694 698
 	}
699
+	}
695 700
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 	$GLOBALS['contexte'] = calculer_contexte();
38 38
 	$page = array('contexte_implicite' => calculer_contexte_implicite());
39
-	$page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '',
39
+	$page['contexte_implicite']['cache'] = $fond.preg_replace(',\.[a-zA-Z0-9]*$,', '',
40 40
 			preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']));
41 41
 	// Cette fonction est utilisee deux fois
42 42
 	$cacher = charger_fonction('cacher', 'public', true);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 				$lastmodified, $connect);
118 118
 			if ($page === '') {
119 119
 				$erreur = _T('info_erreur_squelette2',
120
-					array('fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES));
120
+					array('fichier' => spip_htmlspecialchars($fond).'.'._EXTENSION_SQUELETTES));
121 121
 				erreur_squelette($erreur);
122 122
 				// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
123 123
 				$page = array('texte' => '', 'erreur' => $erreur);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
160 160
 		and !isset($page['entetes']["Last-Modified"])
161 161
 	) {
162
-		$page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified) . " GMT";
162
+		$page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified)." GMT";
163 163
 	}
164 164
 
165 165
 	// fermer la connexion apres les headers si requete HEAD
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		'spip_version_code' => $GLOBALS['spip_version_code'],
225 225
 	);
226 226
 	if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
227
-		$contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST'];
227
+		$contexte_implicite['host'] .= "|".$_SERVER['HTTP_X_FORWARDED_HOST'];
228 228
 	}
229 229
 
230 230
 	return $contexte_implicite;
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 		}
522 522
 
523 523
 		if (preg_match(',^[a-z0-9_]+$,', $soustype)) {
524
-			if (!trouve_modele($fond = ($type . '_' . $soustype))) {
524
+			if (!trouve_modele($fond = ($type.'_'.$soustype))) {
525 525
 				$fond = '';
526 526
 				$class = $soustype;
527 527
 			}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 
537 537
 		return false;
538 538
 	}
539
-	$fond = 'modeles/' . $fond;
539
+	$fond = 'modeles/'.$fond;
540 540
 	// Creer le contexte
541 541
 	$contexte = $env;
542 542
 	$contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte
@@ -575,13 +575,13 @@  discard block
 block discarded – undo
575 575
 	// Regarder si le modele tient compte des liens (il *doit* alors indiquer
576 576
 	// spip_lien_ok dans les classes de son conteneur de premier niveau ;
577 577
 	// sinon, s'il y a un lien, on l'ajoute classiquement
578
-	if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')) . ' ',
578
+	if (strstr(' '.($classes = extraire_attribut($retour, 'class')).' ',
579 579
 		'spip_lien_ok')) {
580 580
 		$retour = inserer_attribut($retour, 'class',
581 581
 			trim(str_replace(' spip_lien_ok ', ' ', " $classes ")));
582 582
 	} else {
583 583
 		if ($lien) {
584
-			$retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . "</a>";
584
+			$retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>";
585 585
 		}
586 586
 	}
587 587
 
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 		return $page;
606 606
 	}
607 607
 	// eval $page et affecte $res
608
-	include _ROOT_RESTREINT . "public/evaluer_page.php";
608
+	include _ROOT_RESTREINT."public/evaluer_page.php";
609 609
 
610 610
 	// Lever un drapeau (global) si le fond utilise #SESSION
611 611
 	// a destination de public/parametrer
@@ -668,14 +668,14 @@  discard block
 block discarded – undo
668 668
 			if (($pos = strpos($head, '<head>')) !== false) {
669 669
 				$head = substr_replace($head, $bbase, $pos + 6, 0);
670 670
 			} elseif (preg_match(",<head[^>]*>,i", $head, $r)) {
671
-				$head = str_replace($r[0], $r[0] . $bbase, $head);
671
+				$head = str_replace($r[0], $r[0].$bbase, $head);
672 672
 			}
673
-			$texte = $head . substr($texte, $poshead);
673
+			$texte = $head.substr($texte, $poshead);
674 674
 			// gerer les ancres
675 675
 			$base = $_SERVER['REQUEST_URI'];
676 676
 			// pas de guillemets ni < dans l'URL qu'on insere dans le HTML
677
-			if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) {
678
-				$base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base);
677
+			if (strpos($base, "'") or strpos($base, '"') or strpos($base, '<')) {
678
+				$base = str_replace(array("'", '"', '<'), array("%27", '%22', '%3C'), $base);
679 679
 			}
680 680
 			if (strpos($texte, "href='#") !== false) {
681 681
 				$texte = str_replace("href='#", "href='$base#", $texte);
Please login to merge, or discard this patch.
Indentation   +532 added lines, -532 removed lines patch added patch discarded remove patch
@@ -20,155 +20,155 @@  discard block
 block discarded – undo
20 20
  **/
21 21
 
22 22
 if (!defined('_ECRIRE_INC_VERSION')) {
23
-	return;
23
+    return;
24 24
 }
25 25
 
26 26
 // En cas de modification, il faut aussi actualiser la regexp de nettoyer_uri_var() dans inc/utils.php
27 27
 if (!defined('_CONTEXTE_IGNORE_VARIABLES')) {
28
-	define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$|^fbclid$|^utm_)/");
28
+    define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$|^fbclid$|^utm_)/");
29 29
 }
30 30
 
31 31
 // http://code.spip.net/@assembler
32 32
 function assembler($fond, $connect = '') {
33 33
 
34
-	// flag_preserver est modifie ici, et utilise en globale
35
-	// use_cache sert a informer le bouton d'admin pr savoir s'il met un *
36
-	// contexte est utilise en globale dans le formulaire d'admin
37
-
38
-	$GLOBALS['contexte'] = calculer_contexte();
39
-	$page = array('contexte_implicite' => calculer_contexte_implicite());
40
-	$page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '',
41
-			preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']));
42
-	// Cette fonction est utilisee deux fois
43
-	$cacher = charger_fonction('cacher', 'public', true);
44
-	// Les quatre derniers parametres sont modifies par la fonction:
45
-	// emplacement, validite, et, s'il est valide, contenu & age
46
-	if ($cacher) {
47
-		$res = $cacher($GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, $page, $lastmodified);
48
-	} else {
49
-		$GLOBALS['use_cache'] = -1;
50
-	}
51
-	// Si un resultat est retourne, c'est un message d'impossibilite
52
-	if ($res) {
53
-		return array('texte' => $res);
54
-	}
55
-
56
-	if (!$chemin_cache || !$lastmodified) {
57
-		$lastmodified = time();
58
-	}
59
-
60
-	$headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD');
61
-	$calculer_page = true;
62
-
63
-	// Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client})
64
-	// une perennite valide a meme reponse qu'une requete HEAD (par defaut les
65
-	// pages sont dynamiques)
66
-	if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
67
-		and (!defined('_VAR_MODE') or !_VAR_MODE)
68
-		and $chemin_cache
69
-		and isset($page['entetes'])
70
-		and isset($page['entetes']['Cache-Control'])
71
-		and strstr($page['entetes']['Cache-Control'], 'max-age=')
72
-		and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
73
-	) {
74
-		$since = preg_replace('/;.*/', '',
75
-			$_SERVER['HTTP_IF_MODIFIED_SINCE']);
76
-		$since = str_replace('GMT', '', $since);
77
-		if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) {
78
-			$page['status'] = 304;
79
-			$headers_only = true;
80
-			$calculer_page = false;
81
-		}
82
-	}
83
-
84
-	// Si requete HEAD ou Last-modified compatible, ignorer le texte
85
-	// et pas de content-type (pour contrer le bouton admin de inc-public)
86
-	if (!$calculer_page) {
87
-		$page['texte'] = "";
88
-	} else {
89
-		// si la page est prise dans le cache
90
-		if (!$GLOBALS['use_cache']) {
91
-			// Informer les boutons d'admin du contexte
92
-			// (fourni par urls_decoder_url ci-dessous lors de la mise en cache)
93
-			$GLOBALS['contexte'] = $page['contexte'];
94
-
95
-			// vider les globales url propres qui ne doivent plus etre utilisees en cas
96
-			// d'inversion url => objet
97
-			// plus necessaire si on utilise bien la fonction urls_decoder_url
98
-			#unset($_SERVER['REDIRECT_url_propre']);
99
-			#unset($_ENV['url_propre']);
100
-		} else {
101
-			// Compat ascendante :
102
-			// 1. $contexte est global
103
-			// (a evacuer car urls_decoder_url gere ce probleme ?)
104
-			// et calculer la page
105
-			if (!test_espace_prive()) {
106
-				include_spip('inc/urls');
107
-				list($fond, $GLOBALS['contexte'], $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $GLOBALS['contexte'],
108
-					true);
109
-			}
110
-			// squelette par defaut
111
-			if (!strlen($fond)) {
112
-				$fond = 'sommaire';
113
-			}
114
-
115
-			// produire la page : peut mettre a jour $lastmodified
116
-			$produire_page = charger_fonction('produire_page', 'public');
117
-			$page = $produire_page($fond, $GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, null, $page,
118
-				$lastmodified, $connect);
119
-			if ($page === '') {
120
-				$erreur = _T('info_erreur_squelette2',
121
-					array('fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES));
122
-				erreur_squelette($erreur);
123
-				// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
124
-				$page = array('texte' => '', 'erreur' => $erreur);
125
-			}
126
-		}
127
-
128
-		if ($page and $chemin_cache) {
129
-			$page['cache'] = $chemin_cache;
130
-		}
131
-
132
-		auto_content_type($page);
133
-
134
-		$GLOBALS['flag_preserver'] |= headers_sent();
135
-
136
-		// Definir les entetes si ce n'est fait 
137
-		if (!$GLOBALS['flag_preserver']) {
138
-			if ($GLOBALS['flag_ob']) {
139
-				// Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions
140
-				if (trim($page['texte']) === ''
141
-					and _VAR_MODE != 'debug'
142
-					and !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur
143
-				) {
144
-					$GLOBALS['contexte']['fond_erreur'] = $fond;
145
-					$page = message_page_indisponible($page, $GLOBALS['contexte']);
146
-				}
147
-				// pas de cache client en mode 'observation'
148
-				if (defined('_VAR_MODE') and _VAR_MODE) {
149
-					$page['entetes']["Cache-Control"] = "no-cache,must-revalidate";
150
-					$page['entetes']["Pragma"] = "no-cache";
151
-				}
152
-			}
153
-		}
154
-	}
155
-
156
-	// Entete Last-Modified:
157
-	// eviter d'etre incoherent en envoyant un lastmodified identique
158
-	// a celui qu'on a refuse d'honorer plus haut (cf. #655)
159
-	if ($lastmodified
160
-		and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
161
-		and !isset($page['entetes']["Last-Modified"])
162
-	) {
163
-		$page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified) . " GMT";
164
-	}
165
-
166
-	// fermer la connexion apres les headers si requete HEAD
167
-	if ($headers_only) {
168
-		$page['entetes']["Connection"] = "close";
169
-	}
170
-
171
-	return $page;
34
+    // flag_preserver est modifie ici, et utilise en globale
35
+    // use_cache sert a informer le bouton d'admin pr savoir s'il met un *
36
+    // contexte est utilise en globale dans le formulaire d'admin
37
+
38
+    $GLOBALS['contexte'] = calculer_contexte();
39
+    $page = array('contexte_implicite' => calculer_contexte_implicite());
40
+    $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '',
41
+            preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI']));
42
+    // Cette fonction est utilisee deux fois
43
+    $cacher = charger_fonction('cacher', 'public', true);
44
+    // Les quatre derniers parametres sont modifies par la fonction:
45
+    // emplacement, validite, et, s'il est valide, contenu & age
46
+    if ($cacher) {
47
+        $res = $cacher($GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, $page, $lastmodified);
48
+    } else {
49
+        $GLOBALS['use_cache'] = -1;
50
+    }
51
+    // Si un resultat est retourne, c'est un message d'impossibilite
52
+    if ($res) {
53
+        return array('texte' => $res);
54
+    }
55
+
56
+    if (!$chemin_cache || !$lastmodified) {
57
+        $lastmodified = time();
58
+    }
59
+
60
+    $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD');
61
+    $calculer_page = true;
62
+
63
+    // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client})
64
+    // une perennite valide a meme reponse qu'une requete HEAD (par defaut les
65
+    // pages sont dynamiques)
66
+    if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
67
+        and (!defined('_VAR_MODE') or !_VAR_MODE)
68
+        and $chemin_cache
69
+        and isset($page['entetes'])
70
+        and isset($page['entetes']['Cache-Control'])
71
+        and strstr($page['entetes']['Cache-Control'], 'max-age=')
72
+        and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
73
+    ) {
74
+        $since = preg_replace('/;.*/', '',
75
+            $_SERVER['HTTP_IF_MODIFIED_SINCE']);
76
+        $since = str_replace('GMT', '', $since);
77
+        if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) {
78
+            $page['status'] = 304;
79
+            $headers_only = true;
80
+            $calculer_page = false;
81
+        }
82
+    }
83
+
84
+    // Si requete HEAD ou Last-modified compatible, ignorer le texte
85
+    // et pas de content-type (pour contrer le bouton admin de inc-public)
86
+    if (!$calculer_page) {
87
+        $page['texte'] = "";
88
+    } else {
89
+        // si la page est prise dans le cache
90
+        if (!$GLOBALS['use_cache']) {
91
+            // Informer les boutons d'admin du contexte
92
+            // (fourni par urls_decoder_url ci-dessous lors de la mise en cache)
93
+            $GLOBALS['contexte'] = $page['contexte'];
94
+
95
+            // vider les globales url propres qui ne doivent plus etre utilisees en cas
96
+            // d'inversion url => objet
97
+            // plus necessaire si on utilise bien la fonction urls_decoder_url
98
+            #unset($_SERVER['REDIRECT_url_propre']);
99
+            #unset($_ENV['url_propre']);
100
+        } else {
101
+            // Compat ascendante :
102
+            // 1. $contexte est global
103
+            // (a evacuer car urls_decoder_url gere ce probleme ?)
104
+            // et calculer la page
105
+            if (!test_espace_prive()) {
106
+                include_spip('inc/urls');
107
+                list($fond, $GLOBALS['contexte'], $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $GLOBALS['contexte'],
108
+                    true);
109
+            }
110
+            // squelette par defaut
111
+            if (!strlen($fond)) {
112
+                $fond = 'sommaire';
113
+            }
114
+
115
+            // produire la page : peut mettre a jour $lastmodified
116
+            $produire_page = charger_fonction('produire_page', 'public');
117
+            $page = $produire_page($fond, $GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, null, $page,
118
+                $lastmodified, $connect);
119
+            if ($page === '') {
120
+                $erreur = _T('info_erreur_squelette2',
121
+                    array('fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES));
122
+                erreur_squelette($erreur);
123
+                // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
124
+                $page = array('texte' => '', 'erreur' => $erreur);
125
+            }
126
+        }
127
+
128
+        if ($page and $chemin_cache) {
129
+            $page['cache'] = $chemin_cache;
130
+        }
131
+
132
+        auto_content_type($page);
133
+
134
+        $GLOBALS['flag_preserver'] |= headers_sent();
135
+
136
+        // Definir les entetes si ce n'est fait 
137
+        if (!$GLOBALS['flag_preserver']) {
138
+            if ($GLOBALS['flag_ob']) {
139
+                // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions
140
+                if (trim($page['texte']) === ''
141
+                    and _VAR_MODE != 'debug'
142
+                    and !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur
143
+                ) {
144
+                    $GLOBALS['contexte']['fond_erreur'] = $fond;
145
+                    $page = message_page_indisponible($page, $GLOBALS['contexte']);
146
+                }
147
+                // pas de cache client en mode 'observation'
148
+                if (defined('_VAR_MODE') and _VAR_MODE) {
149
+                    $page['entetes']["Cache-Control"] = "no-cache,must-revalidate";
150
+                    $page['entetes']["Pragma"] = "no-cache";
151
+                }
152
+            }
153
+        }
154
+    }
155
+
156
+    // Entete Last-Modified:
157
+    // eviter d'etre incoherent en envoyant un lastmodified identique
158
+    // a celui qu'on a refuse d'honorer plus haut (cf. #655)
159
+    if ($lastmodified
160
+        and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
161
+        and !isset($page['entetes']["Last-Modified"])
162
+    ) {
163
+        $page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified) . " GMT";
164
+    }
165
+
166
+    // fermer la connexion apres les headers si requete HEAD
167
+    if ($headers_only) {
168
+        $page['entetes']["Connection"] = "close";
169
+    }
170
+
171
+    return $page;
172 172
 }
173 173
 
174 174
 /**
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
  */
188 188
 function calculer_contexte() {
189 189
 
190
-	$contexte = array();
191
-	foreach ($_GET as $var => $val) {
192
-		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) {
193
-			$contexte[$var] = $val;
194
-		}
195
-	}
196
-	foreach ($_POST as $var => $val) {
197
-		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) {
198
-			$contexte[$var] = $val;
199
-		}
200
-	}
201
-
202
-	return $contexte;
190
+    $contexte = array();
191
+    foreach ($_GET as $var => $val) {
192
+        if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) {
193
+            $contexte[$var] = $val;
194
+        }
195
+    }
196
+    foreach ($_POST as $var => $val) {
197
+        if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) {
198
+            $contexte[$var] = $val;
199
+        }
200
+    }
201
+
202
+    return $contexte;
203 203
 }
204 204
 
205 205
 /**
@@ -210,25 +210,25 @@  discard block
 block discarded – undo
210 210
  * @return array
211 211
  */
212 212
 function calculer_contexte_implicite() {
213
-	static $notes = null;
214
-	if (is_null($notes)) {
215
-		$notes = charger_fonction('notes', 'inc', true);
216
-	}
217
-	$contexte_implicite = array(
218
-		'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ?
219
-		'host' => (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null),
220
-		'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''),
221
-		'espace' => test_espace_prive(),
222
-		'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''),
223
-		'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''),
224
-		'notes' => $notes ? $notes('', 'contexter_cache') : '',
225
-		'spip_version_code' => $GLOBALS['spip_version_code'],
226
-	);
227
-	if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
228
-		$contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST'];
229
-	}
230
-
231
-	return $contexte_implicite;
213
+    static $notes = null;
214
+    if (is_null($notes)) {
215
+        $notes = charger_fonction('notes', 'inc', true);
216
+    }
217
+    $contexte_implicite = array(
218
+        'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ?
219
+        'host' => (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null),
220
+        'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''),
221
+        'espace' => test_espace_prive(),
222
+        'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''),
223
+        'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''),
224
+        'notes' => $notes ? $notes('', 'contexter_cache') : '',
225
+        'spip_version_code' => $GLOBALS['spip_version_code'],
226
+    );
227
+    if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
228
+        $contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST'];
229
+    }
230
+
231
+    return $contexte_implicite;
232 232
 }
233 233
 
234 234
 //
@@ -238,50 +238,50 @@  discard block
 block discarded – undo
238 238
 // http://code.spip.net/@auto_content_type
239 239
 function auto_content_type($page) {
240 240
 
241
-	if (!isset($GLOBALS['flag_preserver'])) {
242
-		$GLOBALS['flag_preserver'] = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",
243
-				$page['texte']) || (isset($page['entetes']['Content-Type'])));
244
-	}
241
+    if (!isset($GLOBALS['flag_preserver'])) {
242
+        $GLOBALS['flag_preserver'] = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",
243
+                $page['texte']) || (isset($page['entetes']['Content-Type'])));
244
+    }
245 245
 }
246 246
 
247 247
 // http://code.spip.net/@inclure_page
248 248
 function inclure_page($fond, $contexte, $connect = '') {
249
-	static $cacher, $produire_page;
250
-
251
-	// enlever le fond de contexte inclus car sinon il prend la main
252
-	// dans les sous inclusions -> boucle infinie d'inclusion identique
253
-	// (cette precaution n'est probablement plus utile)
254
-	unset($contexte['fond']);
255
-	$page = array('contexte_implicite' => calculer_contexte_implicite());
256
-	$page['contexte_implicite']['cache'] = $fond;
257
-	if (is_null($cacher)) {
258
-		$cacher = charger_fonction('cacher', 'public', true);
259
-	}
260
-	// Les quatre derniers parametres sont modifies par la fonction:
261
-	// emplacement, validite, et, s'il est valide, contenu & age
262
-	if ($cacher) {
263
-		$res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude);
264
-	} else {
265
-		$use_cache = -1;
266
-	}
267
-	// $res = message d'erreur : on sort de la
268
-	if ($res) {
269
-		return array('texte' => $res);
270
-	}
271
-
272
-	// Si use_cache ne vaut pas 0, la page doit etre calculee
273
-	// produire la page : peut mettre a jour $lastinclude
274
-	// le contexte_cache envoye a cacher() a ete conserve et est passe a produire
275
-	if ($use_cache) {
276
-		if (is_null($produire_page)) {
277
-			$produire_page = charger_fonction('produire_page', 'public');
278
-		}
279
-		$page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect);
280
-	}
281
-	// dans tous les cas, mettre a jour $GLOBALS['lastmodified']
282
-	$GLOBALS['lastmodified'] = max((isset($GLOBALS['lastmodified']) ? $GLOBALS['lastmodified'] : 0), $lastinclude);
283
-
284
-	return $page;
249
+    static $cacher, $produire_page;
250
+
251
+    // enlever le fond de contexte inclus car sinon il prend la main
252
+    // dans les sous inclusions -> boucle infinie d'inclusion identique
253
+    // (cette precaution n'est probablement plus utile)
254
+    unset($contexte['fond']);
255
+    $page = array('contexte_implicite' => calculer_contexte_implicite());
256
+    $page['contexte_implicite']['cache'] = $fond;
257
+    if (is_null($cacher)) {
258
+        $cacher = charger_fonction('cacher', 'public', true);
259
+    }
260
+    // Les quatre derniers parametres sont modifies par la fonction:
261
+    // emplacement, validite, et, s'il est valide, contenu & age
262
+    if ($cacher) {
263
+        $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude);
264
+    } else {
265
+        $use_cache = -1;
266
+    }
267
+    // $res = message d'erreur : on sort de la
268
+    if ($res) {
269
+        return array('texte' => $res);
270
+    }
271
+
272
+    // Si use_cache ne vaut pas 0, la page doit etre calculee
273
+    // produire la page : peut mettre a jour $lastinclude
274
+    // le contexte_cache envoye a cacher() a ete conserve et est passe a produire
275
+    if ($use_cache) {
276
+        if (is_null($produire_page)) {
277
+            $produire_page = charger_fonction('produire_page', 'public');
278
+        }
279
+        $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect);
280
+    }
281
+    // dans tous les cas, mettre a jour $GLOBALS['lastmodified']
282
+    $GLOBALS['lastmodified'] = max((isset($GLOBALS['lastmodified']) ? $GLOBALS['lastmodified'] : 0), $lastinclude);
283
+
284
+    return $page;
285 285
 }
286 286
 
287 287
 /**
@@ -299,40 +299,40 @@  discard block
 block discarded – undo
299 299
  * @return array
300 300
  */
301 301
 function public_produire_page_dist(
302
-	$fond,
303
-	$contexte,
304
-	$use_cache,
305
-	$chemin_cache,
306
-	$contexte_cache,
307
-	&$page,
308
-	&$lastinclude,
309
-	$connect = ''
302
+    $fond,
303
+    $contexte,
304
+    $use_cache,
305
+    $chemin_cache,
306
+    $contexte_cache,
307
+    &$page,
308
+    &$lastinclude,
309
+    $connect = ''
310 310
 ) {
311
-	static $parametrer, $cacher;
312
-	if (!$parametrer) {
313
-		$parametrer = charger_fonction('parametrer', 'public');
314
-	}
315
-	$page = $parametrer($fond, $contexte, $chemin_cache, $connect);
316
-	// et on l'enregistre sur le disque
317
-	if ($chemin_cache
318
-		and $use_cache > -1
319
-		and is_array($page)
320
-		and count($page)
321
-		and isset($page['entetes']['X-Spip-Cache'])
322
-		and $page['entetes']['X-Spip-Cache'] > 0
323
-	) {
324
-		if (is_null($cacher)) {
325
-			$cacher = charger_fonction('cacher', 'public', true);
326
-		}
327
-		$lastinclude = time();
328
-		if ($cacher) {
329
-			$cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude);
330
-		} else {
331
-			$use_cache = -1;
332
-		}
333
-	}
334
-
335
-	return $page;
311
+    static $parametrer, $cacher;
312
+    if (!$parametrer) {
313
+        $parametrer = charger_fonction('parametrer', 'public');
314
+    }
315
+    $page = $parametrer($fond, $contexte, $chemin_cache, $connect);
316
+    // et on l'enregistre sur le disque
317
+    if ($chemin_cache
318
+        and $use_cache > -1
319
+        and is_array($page)
320
+        and count($page)
321
+        and isset($page['entetes']['X-Spip-Cache'])
322
+        and $page['entetes']['X-Spip-Cache'] > 0
323
+    ) {
324
+        if (is_null($cacher)) {
325
+            $cacher = charger_fonction('cacher', 'public', true);
326
+        }
327
+        $lastinclude = time();
328
+        if ($cacher) {
329
+            $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude);
330
+        } else {
331
+            $use_cache = -1;
332
+        }
333
+    }
334
+
335
+    return $page;
336 336
 }
337 337
 
338 338
 // Fonction inseree par le compilateur dans le code compile.
@@ -346,12 +346,12 @@  discard block
 block discarded – undo
346 346
 // 4: langue
347 347
 
348 348
 function inserer_balise_dynamique($contexte_exec, $contexte_compil) {
349
-	if (!is_array($contexte_exec)) {
350
-		echo $contexte_exec;
351
-	} // message d'erreur etc
352
-	else {
353
-		inclure_balise_dynamique($contexte_exec, true, $contexte_compil);
354
-	}
349
+    if (!is_array($contexte_exec)) {
350
+        echo $contexte_exec;
351
+    } // message d'erreur etc
352
+    else {
353
+        inclure_balise_dynamique($contexte_exec, true, $contexte_compil);
354
+    }
355 355
 }
356 356
 
357 357
 /**
@@ -366,124 +366,124 @@  discard block
 block discarded – undo
366 366
  * @return string
367 367
  */
368 368
 function inclure_balise_dynamique($texte, $echo = true, $contexte_compil = array()) {
369
-	if (is_array($texte)) {
370
-
371
-		list($fond, $delainc, $contexte_inclus) = $texte;
372
-
373
-		// delais a l'ancienne, c'est pratiquement mort
374
-		$d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : null;
375
-		$GLOBALS['delais'] = $delainc;
376
-
377
-		$page = recuperer_fond($fond, $contexte_inclus,
378
-			array('trim' => false, 'raw' => true, 'compil' => $contexte_compil));
379
-
380
-		$texte = $page['texte'];
381
-
382
-		$GLOBALS['delais'] = $d;
383
-		// Faire remonter les entetes
384
-		if (is_array($page['entetes'])) {
385
-			// mais pas toutes
386
-			unset($page['entetes']['X-Spip-Cache']);
387
-			unset($page['entetes']['Content-Type']);
388
-			if (isset($GLOBALS['page']) and is_array($GLOBALS['page'])) {
389
-				if (!is_array($GLOBALS['page']['entetes'])) {
390
-					$GLOBALS['page']['entetes'] = array();
391
-				}
392
-				$GLOBALS['page']['entetes'] =
393
-					array_merge($GLOBALS['page']['entetes'], $page['entetes']);
394
-			}
395
-		}
396
-		// _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines
397
-		if (isset($page['contexte']['_pipelines'])
398
-			and is_array($page['contexte']['_pipelines'])
399
-			and count($page['contexte']['_pipelines'])
400
-		) {
401
-			foreach ($page['contexte']['_pipelines'] as $pipe => $args) {
402
-				$args['contexte'] = $page['contexte'];
403
-				unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul
404
-				$texte = pipeline(
405
-					$pipe,
406
-					array(
407
-						'data' => $texte,
408
-						'args' => $args
409
-					),
410
-					false
411
-				);
412
-			}
413
-		}
414
-	}
415
-
416
-	if (defined('_VAR_MODE') and _VAR_MODE == 'debug') {
417
-		// compatibilite : avant on donnait le numero de ligne ou rien.
418
-		$ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil);
419
-		$GLOBALS['debug_objets']['resultat'][$ligne] = $texte;
420
-	}
421
-	if ($echo) {
422
-		echo $texte;
423
-	} else {
424
-		return $texte;
425
-	}
369
+    if (is_array($texte)) {
370
+
371
+        list($fond, $delainc, $contexte_inclus) = $texte;
372
+
373
+        // delais a l'ancienne, c'est pratiquement mort
374
+        $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : null;
375
+        $GLOBALS['delais'] = $delainc;
376
+
377
+        $page = recuperer_fond($fond, $contexte_inclus,
378
+            array('trim' => false, 'raw' => true, 'compil' => $contexte_compil));
379
+
380
+        $texte = $page['texte'];
381
+
382
+        $GLOBALS['delais'] = $d;
383
+        // Faire remonter les entetes
384
+        if (is_array($page['entetes'])) {
385
+            // mais pas toutes
386
+            unset($page['entetes']['X-Spip-Cache']);
387
+            unset($page['entetes']['Content-Type']);
388
+            if (isset($GLOBALS['page']) and is_array($GLOBALS['page'])) {
389
+                if (!is_array($GLOBALS['page']['entetes'])) {
390
+                    $GLOBALS['page']['entetes'] = array();
391
+                }
392
+                $GLOBALS['page']['entetes'] =
393
+                    array_merge($GLOBALS['page']['entetes'], $page['entetes']);
394
+            }
395
+        }
396
+        // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines
397
+        if (isset($page['contexte']['_pipelines'])
398
+            and is_array($page['contexte']['_pipelines'])
399
+            and count($page['contexte']['_pipelines'])
400
+        ) {
401
+            foreach ($page['contexte']['_pipelines'] as $pipe => $args) {
402
+                $args['contexte'] = $page['contexte'];
403
+                unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul
404
+                $texte = pipeline(
405
+                    $pipe,
406
+                    array(
407
+                        'data' => $texte,
408
+                        'args' => $args
409
+                    ),
410
+                    false
411
+                );
412
+            }
413
+        }
414
+    }
415
+
416
+    if (defined('_VAR_MODE') and _VAR_MODE == 'debug') {
417
+        // compatibilite : avant on donnait le numero de ligne ou rien.
418
+        $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil);
419
+        $GLOBALS['debug_objets']['resultat'][$ligne] = $texte;
420
+    }
421
+    if ($echo) {
422
+        echo $texte;
423
+    } else {
424
+        return $texte;
425
+    }
426 426
 }
427 427
 
428 428
 // http://code.spip.net/@message_page_indisponible
429 429
 function message_page_indisponible($page, $contexte) {
430
-	static $deja = false;
431
-	if ($deja) {
432
-		return "erreur";
433
-	}
434
-	$codes = array(
435
-		'404' => '404 Not Found',
436
-		'503' => '503 Service Unavailable',
437
-	);
438
-
439
-	$contexte['status'] = ($page !== false) ? '404' : '503';
440
-	$contexte['code'] = $codes[$contexte['status']];
441
-	$contexte['fond'] = '404'; // gere les 2 erreurs
442
-	if (!isset($contexte['lang'])) {
443
-		$contexte['lang'] = $GLOBALS['spip_lang'];
444
-	}
445
-
446
-	$deja = true;
447
-	// passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent
448
-	// ex restriction d'acces => 401
449
-	$contexte = pipeline('page_indisponible', $contexte);
450
-
451
-	// produire la page d'erreur
452
-	$page = inclure_page($contexte['fond'], $contexte);
453
-	if (!$page) {
454
-		$page = inclure_page('404', $contexte);
455
-	}
456
-	$page['status'] = $contexte['status'];
457
-
458
-	return $page;
430
+    static $deja = false;
431
+    if ($deja) {
432
+        return "erreur";
433
+    }
434
+    $codes = array(
435
+        '404' => '404 Not Found',
436
+        '503' => '503 Service Unavailable',
437
+    );
438
+
439
+    $contexte['status'] = ($page !== false) ? '404' : '503';
440
+    $contexte['code'] = $codes[$contexte['status']];
441
+    $contexte['fond'] = '404'; // gere les 2 erreurs
442
+    if (!isset($contexte['lang'])) {
443
+        $contexte['lang'] = $GLOBALS['spip_lang'];
444
+    }
445
+
446
+    $deja = true;
447
+    // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent
448
+    // ex restriction d'acces => 401
449
+    $contexte = pipeline('page_indisponible', $contexte);
450
+
451
+    // produire la page d'erreur
452
+    $page = inclure_page($contexte['fond'], $contexte);
453
+    if (!$page) {
454
+        $page = inclure_page('404', $contexte);
455
+    }
456
+    $page['status'] = $contexte['status'];
457
+
458
+    return $page;
459 459
 }
460 460
 
461 461
 // temporairement ici : a mettre dans le futur inc/modeles
462 462
 // creer_contexte_de_modele('left', 'autostart=true', ...) renvoie un array()
463 463
 // http://code.spip.net/@creer_contexte_de_modele
464 464
 function creer_contexte_de_modele($args) {
465
-	$contexte = array();
466
-	foreach ($args as $var => $val) {
467
-		if (is_int($var)) { // argument pas formate
468
-			if (in_array($val, array('left', 'right', 'center'))) {
469
-				$var = 'align';
470
-				$contexte[$var] = $val;
471
-			} else {
472
-				$args = explode('=', $val);
473
-				if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args
474
-				{
475
-					$contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1);
476
-				} else // notation abregee
477
-				{
478
-					$contexte[trim($val)] = trim($val);
479
-				}
480
-			}
481
-		} else {
482
-			$contexte[$var] = $val;
483
-		}
484
-	}
485
-
486
-	return $contexte;
465
+    $contexte = array();
466
+    foreach ($args as $var => $val) {
467
+        if (is_int($var)) { // argument pas formate
468
+            if (in_array($val, array('left', 'right', 'center'))) {
469
+                $var = 'align';
470
+                $contexte[$var] = $val;
471
+            } else {
472
+                $args = explode('=', $val);
473
+                if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args
474
+                {
475
+                    $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1);
476
+                } else // notation abregee
477
+                {
478
+                    $contexte[trim($val)] = trim($val);
479
+                }
480
+            }
481
+        } else {
482
+            $contexte[$var] = $val;
483
+        }
484
+    }
485
+
486
+    return $contexte;
487 487
 }
488 488
 
489 489
 /**
@@ -502,94 +502,94 @@  discard block
 block discarded – undo
502 502
  */
503 503
 function inclure_modele($type, $id, $params, $lien, $connect = '', $env = array()) {
504 504
 
505
-	static $compteur;
506
-	if (++$compteur > 10) {
507
-		return '';
508
-	} # ne pas boucler indefiniment
509
-
510
-	$type = strtolower($type);
511
-
512
-	$fond = $class = '';
513
-
514
-	$params = array_filter(explode('|', $params));
515
-	if ($params) {
516
-		$soustype = current($params);
517
-		$soustype = strtolower(trim($soustype));
518
-		if (in_array($soustype, array('left', 'right', 'center', 'ajax'))) {
519
-			$soustype = next($params);
520
-			$soustype = strtolower($soustype);
521
-		}
522
-
523
-		if (preg_match(',^[a-z0-9_]+$,', $soustype)) {
524
-			if (!trouve_modele($fond = ($type . '_' . $soustype))) {
525
-				$fond = '';
526
-				$class = $soustype;
527
-			}
528
-			// enlever le sous type des params
529
-			$params = array_diff($params, array($soustype));
530
-		}
531
-	}
532
-
533
-	// Si ca marche pas en precisant le sous-type, prendre le type
534
-	if (!$fond and !trouve_modele($fond = $type)) {
535
-		spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE);
536
-
537
-		return false;
538
-	}
539
-	$fond = 'modeles/' . $fond;
540
-	// Creer le contexte
541
-	$contexte = $env;
542
-	$contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte
543
-
544
-	// Le numero du modele est mis dans l'environnement
545
-	// d'une part sous l'identifiant "id"
546
-	// et d'autre part sous l'identifiant de la cle primaire
547
-	// par la fonction id_table_objet,
548
-	// (<article1> =>> article =>> id_article =>> id_article=1)
549
-	$_id = id_table_objet($type);
550
-	$contexte['id'] = $contexte[$_id] = $id;
551
-
552
-	if (isset($class)) {
553
-		$contexte['class'] = $class;
554
-	}
555
-
556
-	// Si un lien a ete passe en parametre, ex: [<modele1>->url] ou [<modele1|title_du_lien{hreflang}->url]
557
-	if ($lien) {
558
-		# un eventuel guillemet (") sera reechappe par #ENV
559
-		$contexte['lien'] = str_replace("&quot;", '"', $lien['href']);
560
-		$contexte['lien_class'] = $lien['class'];
561
-		$contexte['lien_mime'] = $lien['mime'];
562
-		$contexte['lien_title'] = $lien['title'];
563
-		$contexte['lien_hreflang'] = $lien['hreflang'];
564
-	}
565
-
566
-	// Traiter les parametres
567
-	// par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en>
568
-	$arg_list = creer_contexte_de_modele($params);
569
-	$contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args
570
-	$contexte = array_merge($contexte, $arg_list);
571
-
572
-	// Appliquer le modele avec le contexte
573
-	$retour = recuperer_fond($fond, $contexte, array(), $connect);
574
-
575
-	// Regarder si le modele tient compte des liens (il *doit* alors indiquer
576
-	// spip_lien_ok dans les classes de son conteneur de premier niveau ;
577
-	// sinon, s'il y a un lien, on l'ajoute classiquement
578
-	if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')) . ' ',
579
-		'spip_lien_ok')) {
580
-		$retour = inserer_attribut($retour, 'class',
581
-			trim(str_replace(' spip_lien_ok ', ' ', " $classes ")));
582
-	} else {
583
-		if ($lien) {
584
-			$retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . "</a>";
585
-		}
586
-	}
587
-
588
-	$compteur--;
589
-
590
-	return (isset($arg_list['ajax']) and $arg_list['ajax'] == 'ajax')
591
-		? encoder_contexte_ajax($contexte, '', $retour)
592
-		: $retour;
505
+    static $compteur;
506
+    if (++$compteur > 10) {
507
+        return '';
508
+    } # ne pas boucler indefiniment
509
+
510
+    $type = strtolower($type);
511
+
512
+    $fond = $class = '';
513
+
514
+    $params = array_filter(explode('|', $params));
515
+    if ($params) {
516
+        $soustype = current($params);
517
+        $soustype = strtolower(trim($soustype));
518
+        if (in_array($soustype, array('left', 'right', 'center', 'ajax'))) {
519
+            $soustype = next($params);
520
+            $soustype = strtolower($soustype);
521
+        }
522
+
523
+        if (preg_match(',^[a-z0-9_]+$,', $soustype)) {
524
+            if (!trouve_modele($fond = ($type . '_' . $soustype))) {
525
+                $fond = '';
526
+                $class = $soustype;
527
+            }
528
+            // enlever le sous type des params
529
+            $params = array_diff($params, array($soustype));
530
+        }
531
+    }
532
+
533
+    // Si ca marche pas en precisant le sous-type, prendre le type
534
+    if (!$fond and !trouve_modele($fond = $type)) {
535
+        spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE);
536
+
537
+        return false;
538
+    }
539
+    $fond = 'modeles/' . $fond;
540
+    // Creer le contexte
541
+    $contexte = $env;
542
+    $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte
543
+
544
+    // Le numero du modele est mis dans l'environnement
545
+    // d'une part sous l'identifiant "id"
546
+    // et d'autre part sous l'identifiant de la cle primaire
547
+    // par la fonction id_table_objet,
548
+    // (<article1> =>> article =>> id_article =>> id_article=1)
549
+    $_id = id_table_objet($type);
550
+    $contexte['id'] = $contexte[$_id] = $id;
551
+
552
+    if (isset($class)) {
553
+        $contexte['class'] = $class;
554
+    }
555
+
556
+    // Si un lien a ete passe en parametre, ex: [<modele1>->url] ou [<modele1|title_du_lien{hreflang}->url]
557
+    if ($lien) {
558
+        # un eventuel guillemet (") sera reechappe par #ENV
559
+        $contexte['lien'] = str_replace("&quot;", '"', $lien['href']);
560
+        $contexte['lien_class'] = $lien['class'];
561
+        $contexte['lien_mime'] = $lien['mime'];
562
+        $contexte['lien_title'] = $lien['title'];
563
+        $contexte['lien_hreflang'] = $lien['hreflang'];
564
+    }
565
+
566
+    // Traiter les parametres
567
+    // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en>
568
+    $arg_list = creer_contexte_de_modele($params);
569
+    $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args
570
+    $contexte = array_merge($contexte, $arg_list);
571
+
572
+    // Appliquer le modele avec le contexte
573
+    $retour = recuperer_fond($fond, $contexte, array(), $connect);
574
+
575
+    // Regarder si le modele tient compte des liens (il *doit* alors indiquer
576
+    // spip_lien_ok dans les classes de son conteneur de premier niveau ;
577
+    // sinon, s'il y a un lien, on l'ajoute classiquement
578
+    if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')) . ' ',
579
+        'spip_lien_ok')) {
580
+        $retour = inserer_attribut($retour, 'class',
581
+            trim(str_replace(' spip_lien_ok ', ' ', " $classes ")));
582
+    } else {
583
+        if ($lien) {
584
+            $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . "</a>";
585
+        }
586
+    }
587
+
588
+    $compteur--;
589
+
590
+    return (isset($arg_list['ajax']) and $arg_list['ajax'] == 'ajax')
591
+        ? encoder_contexte_ajax($contexte, '', $retour)
592
+        : $retour;
593 593
 }
594 594
 
595 595
 // Un inclure_page qui marche aussi pour l'espace prive
@@ -599,92 +599,92 @@  discard block
 block discarded – undo
599 599
 // http://code.spip.net/@evaluer_fond
600 600
 function evaluer_fond($fond, $contexte = array(), $connect = null) {
601 601
 
602
-	$page = inclure_page($fond, $contexte, $connect);
603
-
604
-	if (!$page) {
605
-		return $page;
606
-	}
607
-	// eval $page et affecte $res
608
-	include _ROOT_RESTREINT . "public/evaluer_page.php";
609
-
610
-	// Lever un drapeau (global) si le fond utilise #SESSION
611
-	// a destination de public/parametrer
612
-	// pour remonter vers les inclusions appelantes
613
-	// il faut bien lever ce drapeau apres avoir evalue le fond
614
-	// pour ne pas faire descendre le flag vers les inclusions appelees
615
-	if (isset($page['invalideurs'])
616
-		and isset($page['invalideurs']['session'])
617
-	) {
618
-		$GLOBALS['cache_utilise_session'] = $page['invalideurs']['session'];
619
-	}
620
-
621
-	return $page;
602
+    $page = inclure_page($fond, $contexte, $connect);
603
+
604
+    if (!$page) {
605
+        return $page;
606
+    }
607
+    // eval $page et affecte $res
608
+    include _ROOT_RESTREINT . "public/evaluer_page.php";
609
+
610
+    // Lever un drapeau (global) si le fond utilise #SESSION
611
+    // a destination de public/parametrer
612
+    // pour remonter vers les inclusions appelantes
613
+    // il faut bien lever ce drapeau apres avoir evalue le fond
614
+    // pour ne pas faire descendre le flag vers les inclusions appelees
615
+    if (isset($page['invalideurs'])
616
+        and isset($page['invalideurs']['session'])
617
+    ) {
618
+        $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session'];
619
+    }
620
+
621
+    return $page;
622 622
 }
623 623
 
624 624
 
625 625
 // http://code.spip.net/@page_base_href
626 626
 function page_base_href(&$texte) {
627
-	static $set_html_base = null;
628
-	if (is_null($set_html_base)) {
629
-		if (!defined('_SET_HTML_BASE'))
630
-			// si la profondeur est superieure a 1
631
-			// est que ce n'est pas une url page ni une url action
632
-			// activer par defaut
633
-		{
634
-			$set_html_base = ((
635
-				$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
636
-				and _request(_SPIP_PAGE) !== 'login'
637
-				and !_request('action')) ? true : false);
638
-		} else {
639
-			$set_html_base = _SET_HTML_BASE;
640
-		}
641
-	}
642
-
643
-	if ($set_html_base
644
-		and isset($GLOBALS['html']) and $GLOBALS['html']
645
-		and $GLOBALS['profondeur_url'] > 0
646
-		and ($poshead = strpos($texte, '</head>')) !== false
647
-	) {
648
-		$head = substr($texte, 0, $poshead);
649
-		$insert = false;
650
-		if (strpos($head, '<base') === false) {
651
-			$insert = true;
652
-		} else {
653
-			// si aucun <base ...> n'a de href c'est bon quand meme !
654
-			$insert = true;
655
-			include_spip('inc/filtres');
656
-			$bases = extraire_balises($head, 'base');
657
-			foreach ($bases as $base) {
658
-				if (extraire_attribut($base, 'href')) {
659
-					$insert = false;
660
-				}
661
-			}
662
-		}
663
-		if ($insert) {
664
-			include_spip('inc/filtres_mini');
665
-			// ajouter un base qui reglera tous les liens relatifs
666
-			$base = url_absolue('./');
667
-			$bbase = "\n<base href=\"$base\" />";
668
-			if (($pos = strpos($head, '<head>')) !== false) {
669
-				$head = substr_replace($head, $bbase, $pos + 6, 0);
670
-			} elseif (preg_match(",<head[^>]*>,i", $head, $r)) {
671
-				$head = str_replace($r[0], $r[0] . $bbase, $head);
672
-			}
673
-			$texte = $head . substr($texte, $poshead);
674
-			// gerer les ancres
675
-			$base = $_SERVER['REQUEST_URI'];
676
-			// pas de guillemets ni < dans l'URL qu'on insere dans le HTML
677
-			if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) {
678
-				$base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base);
679
-			}
680
-			if (strpos($texte, "href='#") !== false) {
681
-				$texte = str_replace("href='#", "href='$base#", $texte);
682
-			}
683
-			if (strpos($texte, "href=\"#") !== false) {
684
-				$texte = str_replace("href=\"#", "href=\"$base#", $texte);
685
-			}
686
-		}
687
-	}
627
+    static $set_html_base = null;
628
+    if (is_null($set_html_base)) {
629
+        if (!defined('_SET_HTML_BASE'))
630
+            // si la profondeur est superieure a 1
631
+            // est que ce n'est pas une url page ni une url action
632
+            // activer par defaut
633
+        {
634
+            $set_html_base = ((
635
+                $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
636
+                and _request(_SPIP_PAGE) !== 'login'
637
+                and !_request('action')) ? true : false);
638
+        } else {
639
+            $set_html_base = _SET_HTML_BASE;
640
+        }
641
+    }
642
+
643
+    if ($set_html_base
644
+        and isset($GLOBALS['html']) and $GLOBALS['html']
645
+        and $GLOBALS['profondeur_url'] > 0
646
+        and ($poshead = strpos($texte, '</head>')) !== false
647
+    ) {
648
+        $head = substr($texte, 0, $poshead);
649
+        $insert = false;
650
+        if (strpos($head, '<base') === false) {
651
+            $insert = true;
652
+        } else {
653
+            // si aucun <base ...> n'a de href c'est bon quand meme !
654
+            $insert = true;
655
+            include_spip('inc/filtres');
656
+            $bases = extraire_balises($head, 'base');
657
+            foreach ($bases as $base) {
658
+                if (extraire_attribut($base, 'href')) {
659
+                    $insert = false;
660
+                }
661
+            }
662
+        }
663
+        if ($insert) {
664
+            include_spip('inc/filtres_mini');
665
+            // ajouter un base qui reglera tous les liens relatifs
666
+            $base = url_absolue('./');
667
+            $bbase = "\n<base href=\"$base\" />";
668
+            if (($pos = strpos($head, '<head>')) !== false) {
669
+                $head = substr_replace($head, $bbase, $pos + 6, 0);
670
+            } elseif (preg_match(",<head[^>]*>,i", $head, $r)) {
671
+                $head = str_replace($r[0], $r[0] . $bbase, $head);
672
+            }
673
+            $texte = $head . substr($texte, $poshead);
674
+            // gerer les ancres
675
+            $base = $_SERVER['REQUEST_URI'];
676
+            // pas de guillemets ni < dans l'URL qu'on insere dans le HTML
677
+            if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) {
678
+                $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base);
679
+            }
680
+            if (strpos($texte, "href='#") !== false) {
681
+                $texte = str_replace("href='#", "href='$base#", $texte);
682
+            }
683
+            if (strpos($texte, "href=\"#") !== false) {
684
+                $texte = str_replace("href=\"#", "href=\"$base#", $texte);
685
+            }
686
+        }
687
+    }
688 688
 }
689 689
 
690 690
 
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 // et demarrent par X-Spip-...
693 693
 // http://code.spip.net/@envoyer_entetes
694 694
 function envoyer_entetes($entetes) {
695
-	foreach ($entetes as $k => $v) #	if (strncmp($k, 'X-Spip-', 7))
696
-	{
697
-		@header(strlen($v) ? "$k: $v" : $k);
698
-	}
695
+    foreach ($entetes as $k => $v) #	if (strncmp($k, 'X-Spip-', 7))
696
+    {
697
+        @header(strlen($v) ? "$k: $v" : $k);
698
+    }
699 699
 }
Please login to merge, or discard this patch.
ecrire/public/boucles.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
  *     Code PHP compilé de la boucle
34 34
  **/
35 35
 function boucle_DEFAUT_dist($id_boucle, &$boucles) {
36
-	return calculer_boucle($id_boucle, $boucles);
36
+    return calculer_boucle($id_boucle, $boucles);
37 37
 }
38 38
 
39 39
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  *     Code PHP compilé de la boucle
53 53
  **/
54 54
 function boucle_BOUCLE_dist($id_boucle, &$boucles) {
55
-	return calculer_boucle($id_boucle, $boucles);
55
+    return calculer_boucle($id_boucle, $boucles);
56 56
 }
57 57
 
58 58
 
@@ -82,30 +82,30 @@  discard block
 block discarded – undo
82 82
  *     Code PHP compilé de la boucle
83 83
  **/
84 84
 function boucle_HIERARCHIE_dist($id_boucle, &$boucles) {
85
-	$boucle = &$boucles[$id_boucle];
86
-	$id_table = $boucle->id_table . ".id_rubrique";
85
+    $boucle = &$boucles[$id_boucle];
86
+    $id_table = $boucle->id_table . ".id_rubrique";
87 87
 
88
-	// Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille
89
-	// sauf en presence du critere {tout} (vu par phraser_html)
90
-	// ou {id_article} qui positionne aussi le {tout}
88
+    // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille
89
+    // sauf en presence du critere {tout} (vu par phraser_html)
90
+    // ou {id_article} qui positionne aussi le {tout}
91 91
 
92
-	$boucle->hierarchie = 'if (!($id_rubrique = intval('
93
-		. calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles)
94
-		. ")))\n\t\treturn '';\n\t"
95
-		. "include_spip('inc/rubriques');\n\t"
96
-		. '$hierarchie = calcul_hierarchie_in($id_rubrique,'
97
-		. (isset($boucle->modificateur['tout']) ? 'true' : 'false')
98
-		. ");\n\t"
99
-		. 'if (!$hierarchie) return "";' . "\n\t";
92
+    $boucle->hierarchie = 'if (!($id_rubrique = intval('
93
+        . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles)
94
+        . ")))\n\t\treturn '';\n\t"
95
+        . "include_spip('inc/rubriques');\n\t"
96
+        . '$hierarchie = calcul_hierarchie_in($id_rubrique,'
97
+        . (isset($boucle->modificateur['tout']) ? 'true' : 'false')
98
+        . ");\n\t"
99
+        . 'if (!$hierarchie) return "";' . "\n\t";
100 100
 
101
-	$boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"');
101
+    $boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"');
102 102
 
103
-	$order = "FIELD($id_table, \$hierarchie)";
104
-	if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != " DESC") {
105
-		$boucle->default_order[] = "\"$order\"";
106
-	} else {
107
-		$boucle->default_order[0] = "\"$order DESC\"";
108
-	}
103
+    $order = "FIELD($id_table, \$hierarchie)";
104
+    if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != " DESC") {
105
+        $boucle->default_order[] = "\"$order\"";
106
+    } else {
107
+        $boucle->default_order[0] = "\"$order DESC\"";
108
+    }
109 109
 
110
-	return calculer_boucle($id_boucle, $boucles);
110
+    return calculer_boucle($id_boucle, $boucles);
111 111
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  **/
84 84
 function boucle_HIERARCHIE_dist($id_boucle, &$boucles) {
85 85
 	$boucle = &$boucles[$id_boucle];
86
-	$id_table = $boucle->id_table . ".id_rubrique";
86
+	$id_table = $boucle->id_table.".id_rubrique";
87 87
 
88 88
 	// Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille
89 89
 	// sauf en presence du critere {tout} (vu par phraser_html)
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		. '$hierarchie = calcul_hierarchie_in($id_rubrique,'
97 97
 		. (isset($boucle->modificateur['tout']) ? 'true' : 'false')
98 98
 		. ");\n\t"
99
-		. 'if (!$hierarchie) return "";' . "\n\t";
99
+		. 'if (!$hierarchie) return "";'."\n\t";
100 100
 
101 101
 	$boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"');
102 102
 
Please login to merge, or discard this patch.
ecrire/exec/puce_statut.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/presentation');
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  * @return string Code HTML
33 33
  **/
34 34
 function exec_puce_statut_dist() {
35
-	exec_puce_statut_args(_request('id'), _request('type'));
35
+    exec_puce_statut_args(_request('id'), _request('type'));
36 36
 }
37 37
 
38 38
 /**
@@ -52,25 +52,25 @@  discard block
 block discarded – undo
52 52
  * @return string Code HTML
53 53
  **/
54 54
 function exec_puce_statut_args($id, $type) {
55
-	$id = intval($id);
56
-	if ($table_objet_sql = table_objet_sql($type)
57
-		and $d = lister_tables_objets_sql($table_objet_sql)
58
-		and isset($d['statut_textes_instituer'])
59
-		and $d['statut_textes_instituer']
60
-	) {
61
-		$prim = id_table_objet($type);
62
-		if (isset($d['field']['id_rubrique'])) {
63
-			$select = "id_rubrique,statut";
64
-		} else {
65
-			$select = "0 as id_rubrique,statut";
66
-		}
67
-		$r = sql_fetsel($select, $table_objet_sql, "$prim=$id");
68
-		$statut = $r['statut'];
69
-		$id_rubrique = $r['id_rubrique'];
70
-	} else {
71
-		$id_rubrique = $id;
72
-		$statut = 'prop'; // arbitraire
73
-	}
74
-	$puce_statut = charger_fonction('puce_statut', 'inc');
75
-	ajax_retour($puce_statut($id, $statut, $id_rubrique, $type, true));
55
+    $id = intval($id);
56
+    if ($table_objet_sql = table_objet_sql($type)
57
+        and $d = lister_tables_objets_sql($table_objet_sql)
58
+        and isset($d['statut_textes_instituer'])
59
+        and $d['statut_textes_instituer']
60
+    ) {
61
+        $prim = id_table_objet($type);
62
+        if (isset($d['field']['id_rubrique'])) {
63
+            $select = "id_rubrique,statut";
64
+        } else {
65
+            $select = "0 as id_rubrique,statut";
66
+        }
67
+        $r = sql_fetsel($select, $table_objet_sql, "$prim=$id");
68
+        $statut = $r['statut'];
69
+        $id_rubrique = $r['id_rubrique'];
70
+    } else {
71
+        $id_rubrique = $id;
72
+        $statut = 'prop'; // arbitraire
73
+    }
74
+    $puce_statut = charger_fonction('puce_statut', 'inc');
75
+    ajax_retour($puce_statut($id, $statut, $id_rubrique, $type, true));
76 76
 }
Please login to merge, or discard this patch.
ecrire/exec/install.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/minipres');
@@ -42,28 +42,28 @@  discard block
 block discarded – undo
42 42
  *
43 43
  **/
44 44
 function exec_install_dist() {
45
-	$etape = _request('etape');
46
-	$deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT));
45
+    $etape = _request('etape');
46
+    $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT));
47 47
 
48
-	// Si deja installe, on n'a plus le droit qu'a l'etape chmod
49
-	// pour chgt post-install ou aux etapes supplementaires
50
-	// de declaration de base externes.
51
-	// Mais alors il faut authentifier car ecrire/index.php l'a omis
48
+    // Si deja installe, on n'a plus le droit qu'a l'etape chmod
49
+    // pour chgt post-install ou aux etapes supplementaires
50
+    // de declaration de base externes.
51
+    // Mais alors il faut authentifier car ecrire/index.php l'a omis
52 52
 
53
-	if ($deja and in_array($etape, array('chmod', 'sup1', 'sup2'))) {
53
+    if ($deja and in_array($etape, array('chmod', 'sup1', 'sup2'))) {
54 54
 
55
-		$auth = charger_fonction('auth', 'inc');
56
-		if (!$auth()) {
57
-			verifier_visiteur();
58
-			$deja = (!autoriser('configurer'));
59
-		}
60
-	}
61
-	if ($deja) {
62
-		// Rien a faire ici
63
-		echo minipres();
64
-	} else {
65
-		include_spip('base/create');
66
-		$fonc = charger_fonction("etape_$etape", 'install');
67
-		$fonc();
68
-	}
55
+        $auth = charger_fonction('auth', 'inc');
56
+        if (!$auth()) {
57
+            verifier_visiteur();
58
+            $deja = (!autoriser('configurer'));
59
+        }
60
+    }
61
+    if ($deja) {
62
+        // Rien a faire ici
63
+        echo minipres();
64
+    } else {
65
+        include_spip('base/create');
66
+        $fonc = charger_fonction("etape_$etape", 'install');
67
+        $fonc();
68
+    }
69 69
 }
Please login to merge, or discard this patch.
ecrire/exec/404.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function exec_404_dist() {
27 27
 
28
-	$exec = _request('exec');
28
+    $exec = _request('exec');
29 29
 
30
-	$titre = "exec_$exec";
31
-	$navigation = '';
32
-	$extra = '';
30
+    $titre = "exec_$exec";
31
+    $navigation = '';
32
+    $extra = '';
33 33
 
34
-	include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
35
-	$commencer_page = charger_fonction('commencer_page', 'inc');
36
-	echo $commencer_page($titre);
34
+    include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
35
+    $commencer_page = charger_fonction('commencer_page', 'inc');
36
+    echo $commencer_page($titre);
37 37
 
38
-	echo debut_gauche("404_$exec", true);
39
-	echo pipeline('affiche_gauche', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => ''));
38
+    echo debut_gauche("404_$exec", true);
39
+    echo pipeline('affiche_gauche', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => ''));
40 40
 
41
-	echo creer_colonne_droite('404', true);
42
-	echo pipeline('affiche_droite', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => ''));
41
+    echo creer_colonne_droite('404', true);
42
+    echo pipeline('affiche_droite', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => ''));
43 43
 
44
-	echo debut_droite('404', true);
45
-	echo "<h1 class='grostitre'>" . _T('fichier_introuvable', array('fichier' => $exec)) . '</h1>';
46
-	echo pipeline('affiche_milieu', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => ''));
44
+    echo debut_droite('404', true);
45
+    echo "<h1 class='grostitre'>" . _T('fichier_introuvable', array('fichier' => $exec)) . '</h1>';
46
+    echo pipeline('affiche_milieu', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => ''));
47 47
 
48
-	echo fin_gauche(), fin_page();
48
+    echo fin_gauche(), fin_page();
49 49
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 	echo pipeline('affiche_droite', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => ''));
43 43
 
44 44
 	echo debut_droite('404', true);
45
-	echo "<h1 class='grostitre'>" . _T('fichier_introuvable', array('fichier' => $exec)) . '</h1>';
45
+	echo "<h1 class='grostitre'>"._T('fichier_introuvable', array('fichier' => $exec)).'</h1>';
46 46
 	echo pipeline('affiche_milieu', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => ''));
47 47
 
48 48
 	echo fin_gauche(), fin_page();
Please login to merge, or discard this patch.