Completed
Push — master ( 4c74fa...d9d770 )
by cam
04:23
created
ecrire/xml/indenter.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@
 block discarded – undo
63 63
 	$f = new IndenteurXML();
64 64
 	$sax($page, $apply, $f);
65 65
 	if (!$f->err) {
66
-		return $f->entete . $f->res;
66
+		return $f->entete.$f->res;
67 67
 	}
68
-	spip_log("indentation impossible " . count($f->err) . " erreurs de validation");
68
+	spip_log("indentation impossible ".count($f->err)." erreurs de validation");
69 69
 
70
-	return $f->entete . $f->page;
70
+	return $f->entete.$f->page;
71 71
 }
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -11,61 +11,61 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 class IndenteurXML {
18 18
 
19
-	// https://code.spip.net/@debutElement
20
-	public function debutElement($phraseur, $name, $attrs) {
21
-		xml_debutElement($this, $name, $attrs);
22
-	}
19
+    // https://code.spip.net/@debutElement
20
+    public function debutElement($phraseur, $name, $attrs) {
21
+        xml_debutElement($this, $name, $attrs);
22
+    }
23 23
 
24
-	// https://code.spip.net/@finElement
25
-	public function finElement($phraseur, $name) {
26
-		xml_finElement($this, $name);
27
-	}
24
+    // https://code.spip.net/@finElement
25
+    public function finElement($phraseur, $name) {
26
+        xml_finElement($this, $name);
27
+    }
28 28
 
29
-	// https://code.spip.net/@textElement
30
-	public function textElement($phraseur, $data) {
31
-		xml_textElement($this, $data);
32
-	}
29
+    // https://code.spip.net/@textElement
30
+    public function textElement($phraseur, $data) {
31
+        xml_textElement($this, $data);
32
+    }
33 33
 
34
-	public function piElement($phraseur, $target, $data) {
35
-		xml_PiElement($this, $target, $data);
36
-	}
34
+    public function piElement($phraseur, $target, $data) {
35
+        xml_PiElement($this, $target, $data);
36
+    }
37 37
 
38
-	// https://code.spip.net/@defautElement
39
-	public function defaultElement($phraseur, $data) {
40
-		xml_defaultElement($this, $data);
41
-	}
38
+    // https://code.spip.net/@defautElement
39
+    public function defaultElement($phraseur, $data) {
40
+        xml_defaultElement($this, $data);
41
+    }
42 42
 
43
-	// https://code.spip.net/@phraserTout
44
-	public function phraserTout($phraseur, $data) {
45
-		xml_parsestring($this, $data);
46
-	}
43
+    // https://code.spip.net/@phraserTout
44
+    public function phraserTout($phraseur, $data) {
45
+        xml_parsestring($this, $data);
46
+    }
47 47
 
48
-	public $depth = "";
49
-	public $res = "";
50
-	public $err = array();
51
-	public $contenu = array();
52
-	public $ouvrant = array();
53
-	public $reperes = array();
54
-	public $entete = '';
55
-	public $page = '';
56
-	public $dtc = null;
57
-	public $sax = null;
48
+    public $depth = "";
49
+    public $res = "";
50
+    public $err = array();
51
+    public $contenu = array();
52
+    public $ouvrant = array();
53
+    public $reperes = array();
54
+    public $entete = '';
55
+    public $page = '';
56
+    public $dtc = null;
57
+    public $sax = null;
58 58
 }
59 59
 
60 60
 // https://code.spip.net/@xml_indenter_dist
61 61
 function xml_indenter_dist($page, $apply = false) {
62
-	$sax = charger_fonction('sax', 'xml');
63
-	$f = new IndenteurXML();
64
-	$sax($page, $apply, $f);
65
-	if (!$f->err) {
66
-		return $f->entete . $f->res;
67
-	}
68
-	spip_log("indentation impossible " . count($f->err) . " erreurs de validation");
62
+    $sax = charger_fonction('sax', 'xml');
63
+    $f = new IndenteurXML();
64
+    $sax($page, $apply, $f);
65
+    if (!$f->err) {
66
+        return $f->entete . $f->res;
67
+    }
68
+    spip_log("indentation impossible " . count($f->err) . " erreurs de validation");
69 69
 
70
-	return $f->entete . $f->page;
70
+    return $f->entete . $f->page;
71 71
 }
Please login to merge, or discard this patch.
ecrire/xml/sax.php 3 patches
Spacing   +21 added lines, -22 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	$t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' ';
46 46
 	// espace initial signifie: deja integree au resultat
47 47
 	if ($t[0] != ' ') {
48
-		$phraseur->res .= '<' . $t . '>';
49
-		$phraseur->ouvrant[$depth] = ' ' . $t;
48
+		$phraseur->res .= '<'.$t.'>';
49
+		$phraseur->ouvrant[$depth] = ' '.$t;
50 50
 	}
51 51
 	$t = $phraseur->contenu[$depth];
52 52
 	// n'indenter que s'il y a un separateur avant
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 	foreach ($attrs as $k => $v) {
58 58
 		$delim = strpos($v, "'") === false ? "'" : '"';
59 59
 		$val = xml_entites_html($v);
60
-		$att .= $sep . $k . "=" . $delim
60
+		$att .= $sep.$k."=".$delim
61 61
 			. ($delim !== '"' ? str_replace('&quot;', '"', $val) : $val)
62 62
 			. $delim;
63 63
 		$sep = "\n $depth";
64 64
 	}
65 65
 	$phraseur->depth .= '  ';
66 66
 	$phraseur->contenu[$phraseur->depth] = "";
67
-	$phraseur->ouvrant[$phraseur->depth] = $name . $att;
67
+	$phraseur->ouvrant[$phraseur->depth] = $name.$att;
68 68
 	$phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax);
69 69
 }
70 70
 
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 	$ouv = $phraseur->ouvrant[$phraseur->depth];
74 74
 
75 75
 	if ($ouv[0] != ' ') {
76
-		$phraseur->ouvrant[$phraseur->depth] = ' ' . $ouv;
76
+		$phraseur->ouvrant[$phraseur->depth] = ' '.$ouv;
77 77
 	} else {
78 78
 		$ouv = "";
79 79
 	}
80 80
 	$t = $phraseur->contenu[$phraseur->depth];
81 81
 	$phraseur->depth = substr($phraseur->depth, 2);
82
-	$t = preg_replace("/[\n\t ]+$/", "\n" . $phraseur->depth, $t);
82
+	$t = preg_replace("/[\n\t ]+$/", "\n".$phraseur->depth, $t);
83 83
 
84 84
 	// fusion <balise></balise> en <balise />.
85 85
 	// ATTENTION,  certains clients http croient que fusion ==> pas d'atttributs
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 	// (param fusion_bal)
89 89
 
90 90
 	if ($t || (($ouv != $name) and !$fusion_bal)) {
91
-		$phraseur->res .= ($ouv ? ('<' . $ouv . '>') : '') . $t . "</" . $name . ">";
91
+		$phraseur->res .= ($ouv ? ('<'.$ouv.'>') : '').$t."</".$name.">";
92 92
 	} else {
93
-		$phraseur->res .= ($ouv ? ('<' . $ouv . ' />') : ("</" . $name . ">"));
93
+		$phraseur->res .= ($ouv ? ('<'.$ouv.' />') : ("</".$name.">"));
94 94
 	}
95 95
 }
96 96
 
@@ -134,16 +134,15 @@  discard block
 block discarded – undo
134 134
 	if (!xml_parse($phraseur->sax, $data, true)) {
135 135
 		coordonnees_erreur($phraseur,
136 136
 			xml_error_string(xml_get_error_code($phraseur->sax))
137
-			. "<br />\n" .
138
-			(!$phraseur->depth ? '' :
139
-				('(' .
140
-					_T('erreur_balise_non_fermee') .
141
-					" <tt>" .
142
-					$phraseur->ouvrant[$phraseur->depth] .
143
-					"</tt> " .
144
-					_T('ligne') .
145
-					" " .
146
-					$phraseur->reperes[$phraseur->depth] .
137
+			. "<br />\n".
138
+			(!$phraseur->depth ? '' : ('('.
139
+					_T('erreur_balise_non_fermee').
140
+					" <tt>".
141
+					$phraseur->ouvrant[$phraseur->depth].
142
+					"</tt> ".
143
+					_T('ligne').
144
+					" ".
145
+					$phraseur->reperes[$phraseur->depth].
147 146
 					") <br />\n")));
148 147
 	}
149 148
 }
@@ -185,7 +184,7 @@  discard block
 block discarded – undo
185 184
 	// et escamoter le doctype que sax mange en php5 mais pas en  php4
186 185
 	if (!$doctype) {
187 186
 		if (!$r = analyser_doctype($page)) {
188
-			$page = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE
187
+			$page = _MESSAGE_DOCTYPE._DOCTYPE_ECRIRE
189 188
 				. preg_replace(_REGEXP_DOCTYPE, '', $page);
190 189
 			$r = analyser_doctype($page);
191 190
 		}
@@ -286,18 +285,18 @@  discard block
 block discarded – undo
286 285
 					'rss-0.91.dtd'
287 286
 				);
288 287
 			} else {
289
-				$dtd = $topelement . '.dtd';
288
+				$dtd = $topelement.'.dtd';
290 289
 				$f = find_in_path($dtd);
291 290
 				if (file_exists($f)) {
292 291
 					return array($entete, 'SYSTEM', $f, $dtd);
293 292
 				}
294 293
 			}
295 294
 		}
296
-		spip_log("Dtd pas vu pour " . substr($data, 0, 100));
295
+		spip_log("Dtd pas vu pour ".substr($data, 0, 100));
297 296
 
298 297
 		return array();
299 298
 	}
300
-	list($entete, , $topelement, $avail, $suite) = $page;
299
+	list($entete,, $topelement, $avail, $suite) = $page;
301 300
 
302 301
 	if (!preg_match('/^"([^"]*)"\s*(.*)$/', $suite, $r)) {
303 302
 		if (!preg_match("/^'([^']*)'\s*(.*)$/", $suite, $r)) {
Please login to merge, or discard this patch.
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -102,6 +102,9 @@  discard block
 block discarded – undo
102 102
 		: xml_entites_html($data);
103 103
 }
104 104
 
105
+/**
106
+ * @param IndenteurXML $phraseur
107
+ */
105 108
 function xml_piElement($phraseur, $target, $data) {
106 109
 	$depth = $phraseur->depth;
107 110
 
@@ -118,6 +121,9 @@  discard block
 block discarded – undo
118 121
 
119 122
 
120 123
 // https://code.spip.net/@xml_defautElement
124
+/**
125
+ * @param IndenteurXML $phraseur
126
+ */
121 127
 function xml_defaultElement($phraseur, $data) {
122 128
 	$depth = $phraseur->depth;
123 129
 
@@ -149,6 +155,9 @@  discard block
 block discarded – undo
149 155
 }
150 156
 
151 157
 // https://code.spip.net/@coordonnees_erreur
158
+/**
159
+ * @param string $msg
160
+ */
152 161
 function coordonnees_erreur($phraseur, $msg) {
153 162
 	$entete_length = substr_count($phraseur->entete, "\n");
154 163
 	$phraseur->err[] = array(
Please login to merge, or discard this patch.
Indentation   +246 added lines, -246 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
 include_spip('inc/charsets');
@@ -24,218 +24,218 @@  discard block
 block discarded – undo
24 24
  * @return string
25 25
  */
26 26
 function xml_entites_html($texte) {
27
-	if (!is_string($texte) or !$texte
28
-		or strpbrk($texte, "&\"'<>") == false
29
-	) {
30
-		return $texte;
31
-	}
32
-
33
-	if (!function_exists('spip_htmlspecialchars')) {
34
-		include_spip("inc/filtres_mini");
35
-	}
36
-	$texte = spip_htmlspecialchars($texte, ENT_QUOTES);
37
-
38
-	return $texte;
27
+    if (!is_string($texte) or !$texte
28
+        or strpbrk($texte, "&\"'<>") == false
29
+    ) {
30
+        return $texte;
31
+    }
32
+
33
+    if (!function_exists('spip_htmlspecialchars')) {
34
+        include_spip("inc/filtres_mini");
35
+    }
36
+    $texte = spip_htmlspecialchars($texte, ENT_QUOTES);
37
+
38
+    return $texte;
39 39
 }
40 40
 
41 41
 // https://code.spip.net/@xml_debutElement
42 42
 function xml_debutElement($phraseur, $name, $attrs) {
43
-	$depth = $phraseur->depth;
44
-
45
-	$t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' ';
46
-	// espace initial signifie: deja integree au resultat
47
-	if ($t[0] != ' ') {
48
-		$phraseur->res .= '<' . $t . '>';
49
-		$phraseur->ouvrant[$depth] = ' ' . $t;
50
-	}
51
-	$t = $phraseur->contenu[$depth];
52
-	// n'indenter que s'il y a un separateur avant
53
-	$phraseur->res .= preg_replace("/[\n\t ]+$/", "\n$depth", $t);
54
-	$phraseur->contenu[$depth] = "";
55
-	$att = '';
56
-	$sep = ' ';
57
-	foreach ($attrs as $k => $v) {
58
-		$delim = strpos($v, "'") === false ? "'" : '"';
59
-		$val = xml_entites_html($v);
60
-		$att .= $sep . $k . "=" . $delim
61
-			. ($delim !== '"' ? str_replace('&quot;', '"', $val) : $val)
62
-			. $delim;
63
-		$sep = "\n $depth";
64
-	}
65
-	$phraseur->depth .= '  ';
66
-	$phraseur->contenu[$phraseur->depth] = "";
67
-	$phraseur->ouvrant[$phraseur->depth] = $name . $att;
68
-	$phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax);
43
+    $depth = $phraseur->depth;
44
+
45
+    $t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' ';
46
+    // espace initial signifie: deja integree au resultat
47
+    if ($t[0] != ' ') {
48
+        $phraseur->res .= '<' . $t . '>';
49
+        $phraseur->ouvrant[$depth] = ' ' . $t;
50
+    }
51
+    $t = $phraseur->contenu[$depth];
52
+    // n'indenter que s'il y a un separateur avant
53
+    $phraseur->res .= preg_replace("/[\n\t ]+$/", "\n$depth", $t);
54
+    $phraseur->contenu[$depth] = "";
55
+    $att = '';
56
+    $sep = ' ';
57
+    foreach ($attrs as $k => $v) {
58
+        $delim = strpos($v, "'") === false ? "'" : '"';
59
+        $val = xml_entites_html($v);
60
+        $att .= $sep . $k . "=" . $delim
61
+            . ($delim !== '"' ? str_replace('&quot;', '"', $val) : $val)
62
+            . $delim;
63
+        $sep = "\n $depth";
64
+    }
65
+    $phraseur->depth .= '  ';
66
+    $phraseur->contenu[$phraseur->depth] = "";
67
+    $phraseur->ouvrant[$phraseur->depth] = $name . $att;
68
+    $phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax);
69 69
 }
70 70
 
71 71
 // https://code.spip.net/@xml_finElement
72 72
 function xml_finElement($phraseur, $name, $fusion_bal = false) {
73
-	$ouv = $phraseur->ouvrant[$phraseur->depth];
74
-
75
-	if ($ouv[0] != ' ') {
76
-		$phraseur->ouvrant[$phraseur->depth] = ' ' . $ouv;
77
-	} else {
78
-		$ouv = "";
79
-	}
80
-	$t = $phraseur->contenu[$phraseur->depth];
81
-	$phraseur->depth = substr($phraseur->depth, 2);
82
-	$t = preg_replace("/[\n\t ]+$/", "\n" . $phraseur->depth, $t);
83
-
84
-	// fusion <balise></balise> en <balise />.
85
-	// ATTENTION,  certains clients http croient que fusion ==> pas d'atttributs
86
-	// en particulier pour les balises Script et A.
87
-	// en presence d'attributs ne le faire que si la DTD est dispo et d'accord
88
-	// (param fusion_bal)
89
-
90
-	if ($t || (($ouv != $name) and !$fusion_bal)) {
91
-		$phraseur->res .= ($ouv ? ('<' . $ouv . '>') : '') . $t . "</" . $name . ">";
92
-	} else {
93
-		$phraseur->res .= ($ouv ? ('<' . $ouv . ' />') : ("</" . $name . ">"));
94
-	}
73
+    $ouv = $phraseur->ouvrant[$phraseur->depth];
74
+
75
+    if ($ouv[0] != ' ') {
76
+        $phraseur->ouvrant[$phraseur->depth] = ' ' . $ouv;
77
+    } else {
78
+        $ouv = "";
79
+    }
80
+    $t = $phraseur->contenu[$phraseur->depth];
81
+    $phraseur->depth = substr($phraseur->depth, 2);
82
+    $t = preg_replace("/[\n\t ]+$/", "\n" . $phraseur->depth, $t);
83
+
84
+    // fusion <balise></balise> en <balise />.
85
+    // ATTENTION,  certains clients http croient que fusion ==> pas d'atttributs
86
+    // en particulier pour les balises Script et A.
87
+    // en presence d'attributs ne le faire que si la DTD est dispo et d'accord
88
+    // (param fusion_bal)
89
+
90
+    if ($t || (($ouv != $name) and !$fusion_bal)) {
91
+        $phraseur->res .= ($ouv ? ('<' . $ouv . '>') : '') . $t . "</" . $name . ">";
92
+    } else {
93
+        $phraseur->res .= ($ouv ? ('<' . $ouv . ' />') : ("</" . $name . ">"));
94
+    }
95 95
 }
96 96
 
97 97
 // https://code.spip.net/@xml_textElement
98 98
 function xml_textElement($phraseur, $data) {
99
-	$depth = $phraseur->depth;
100
-	$phraseur->contenu[$depth] .= preg_match('/^script/', $phraseur->ouvrant[$depth])
101
-		? $data
102
-		: xml_entites_html($data);
99
+    $depth = $phraseur->depth;
100
+    $phraseur->contenu[$depth] .= preg_match('/^script/', $phraseur->ouvrant[$depth])
101
+        ? $data
102
+        : xml_entites_html($data);
103 103
 }
104 104
 
105 105
 function xml_piElement($phraseur, $target, $data) {
106
-	$depth = $phraseur->depth;
107
-
108
-	if (strtolower($target) != "php") {
109
-		$phraseur->contenu[$depth] .= $data;
110
-	} else {
111
-		ob_start();
112
-		eval($data);
113
-		$data = ob_get_contents();
114
-		ob_end_clean();
115
-		$phraseur->contenu[$depth] .= $data;
116
-	}
106
+    $depth = $phraseur->depth;
107
+
108
+    if (strtolower($target) != "php") {
109
+        $phraseur->contenu[$depth] .= $data;
110
+    } else {
111
+        ob_start();
112
+        eval($data);
113
+        $data = ob_get_contents();
114
+        ob_end_clean();
115
+        $phraseur->contenu[$depth] .= $data;
116
+    }
117 117
 }
118 118
 
119 119
 
120 120
 // https://code.spip.net/@xml_defautElement
121 121
 function xml_defaultElement($phraseur, $data) {
122
-	$depth = $phraseur->depth;
122
+    $depth = $phraseur->depth;
123 123
 
124
-	if (!isset($phraseur->contenu[$depth])) {
125
-		$phraseur->contenu[$depth] = '';
126
-	}
127
-	$phraseur->contenu[$depth] .= $data;
124
+    if (!isset($phraseur->contenu[$depth])) {
125
+        $phraseur->contenu[$depth] = '';
126
+    }
127
+    $phraseur->contenu[$depth] .= $data;
128 128
 }
129 129
 
130 130
 // https://code.spip.net/@xml_parsestring
131 131
 function xml_parsestring($phraseur, $data) {
132
-	$phraseur->contenu[$phraseur->depth] = '';
133
-
134
-	if (!xml_parse($phraseur->sax, $data, true)) {
135
-		coordonnees_erreur($phraseur,
136
-			xml_error_string(xml_get_error_code($phraseur->sax))
137
-			. "<br />\n" .
138
-			(!$phraseur->depth ? '' :
139
-				('(' .
140
-					_T('erreur_balise_non_fermee') .
141
-					" <tt>" .
142
-					$phraseur->ouvrant[$phraseur->depth] .
143
-					"</tt> " .
144
-					_T('ligne') .
145
-					" " .
146
-					$phraseur->reperes[$phraseur->depth] .
147
-					") <br />\n")));
148
-	}
132
+    $phraseur->contenu[$phraseur->depth] = '';
133
+
134
+    if (!xml_parse($phraseur->sax, $data, true)) {
135
+        coordonnees_erreur($phraseur,
136
+            xml_error_string(xml_get_error_code($phraseur->sax))
137
+            . "<br />\n" .
138
+            (!$phraseur->depth ? '' :
139
+                ('(' .
140
+                    _T('erreur_balise_non_fermee') .
141
+                    " <tt>" .
142
+                    $phraseur->ouvrant[$phraseur->depth] .
143
+                    "</tt> " .
144
+                    _T('ligne') .
145
+                    " " .
146
+                    $phraseur->reperes[$phraseur->depth] .
147
+                    ") <br />\n")));
148
+    }
149 149
 }
150 150
 
151 151
 // https://code.spip.net/@coordonnees_erreur
152 152
 function coordonnees_erreur($phraseur, $msg) {
153
-	$entete_length = substr_count($phraseur->entete, "\n");
154
-	$phraseur->err[] = array(
155
-		$msg,
156
-		xml_get_current_line_number($phraseur->sax) + $entete_length,
157
-		xml_get_current_column_number($phraseur->sax)
158
-	);
153
+    $entete_length = substr_count($phraseur->entete, "\n");
154
+    $phraseur->err[] = array(
155
+        $msg,
156
+        xml_get_current_line_number($phraseur->sax) + $entete_length,
157
+        xml_get_current_column_number($phraseur->sax)
158
+    );
159 159
 }
160 160
 
161 161
 // https://code.spip.net/@xml_sax_dist
162 162
 function xml_sax_dist($page, $apply = false, $phraseur = null, $doctype = '', $charset = null) {
163
-	if (is_null($charset)) {
164
-		$charset = $GLOBALS['meta']['charset'];
165
-	}
166
-	if ($apply) {
167
-		ob_start();
168
-		if (is_array($apply)) {
169
-			$r = call_user_func_array($page, $apply);
170
-		} else {
171
-			$r = $page();
172
-		}
173
-		$page = ob_get_contents();
174
-		ob_end_clean();
175
-		// fonction sans aucun "echo", ca doit etre le resultat
176
-		if (!$page) {
177
-			$page = $r;
178
-		}
179
-	}
180
-
181
-	if (!$page) {
182
-		return '';
183
-	}
184
-	// charger la DTD et transcoder les entites,
185
-	// et escamoter le doctype que sax mange en php5 mais pas en  php4
186
-	if (!$doctype) {
187
-		if (!$r = analyser_doctype($page)) {
188
-			$page = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE
189
-				. preg_replace(_REGEXP_DOCTYPE, '', $page);
190
-			$r = analyser_doctype($page);
191
-		}
192
-		list($entete, $avail, $grammaire, $rotlvl) = array_pad($r, 4, null);
193
-		$page = substr($page, strlen($entete));
194
-	} else {
195
-		$avail = 'SYSTEM';
196
-		$grammaire = $doctype;
197
-		$rotlvl = basename($grammaire);
198
-	}
199
-
200
-	include_spip('xml/analyser_dtd');
201
-	$dtc = charger_dtd($grammaire, $avail, $rotlvl);
202
-	$page = sax_bug($page, $dtc, $charset);
203
-
204
-	// compatibilite Tidy espace public
205
-	if (!$phraseur) {
206
-		$indenter_xml = charger_fonction('indenter', 'xml');
207
-
208
-		return $indenter_xml($page, $apply);
209
-	}
210
-
211
-	$xml_parser = xml_parser_create($charset);
212
-
213
-	xml_set_element_handler($xml_parser,
214
-		array($phraseur, "debutElement"),
215
-		array($phraseur, "finElement"));
216
-
217
-	xml_set_character_data_handler($xml_parser,
218
-		array($phraseur, "textElement"));
219
-
220
-	xml_set_processing_instruction_handler($xml_parser,
221
-		array($phraseur, 'piElement'));
222
-
223
-	xml_set_default_handler($xml_parser,
224
-		array($phraseur, "defaultElement"));
225
-
226
-	xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
227
-
228
-	$phraseur->sax = $xml_parser;
229
-	if (isset($entete)) {
230
-		$phraseur->entete = $entete;
231
-	}
232
-	$phraseur->page = $page;
233
-	$phraseur->dtc = $dtc;
234
-	$phraseur->phraserTout($xml_parser, $page);
235
-	xml_parser_free($xml_parser);
236
-	$phraseur->sax = '';
237
-
238
-	return $phraseur;
163
+    if (is_null($charset)) {
164
+        $charset = $GLOBALS['meta']['charset'];
165
+    }
166
+    if ($apply) {
167
+        ob_start();
168
+        if (is_array($apply)) {
169
+            $r = call_user_func_array($page, $apply);
170
+        } else {
171
+            $r = $page();
172
+        }
173
+        $page = ob_get_contents();
174
+        ob_end_clean();
175
+        // fonction sans aucun "echo", ca doit etre le resultat
176
+        if (!$page) {
177
+            $page = $r;
178
+        }
179
+    }
180
+
181
+    if (!$page) {
182
+        return '';
183
+    }
184
+    // charger la DTD et transcoder les entites,
185
+    // et escamoter le doctype que sax mange en php5 mais pas en  php4
186
+    if (!$doctype) {
187
+        if (!$r = analyser_doctype($page)) {
188
+            $page = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE
189
+                . preg_replace(_REGEXP_DOCTYPE, '', $page);
190
+            $r = analyser_doctype($page);
191
+        }
192
+        list($entete, $avail, $grammaire, $rotlvl) = array_pad($r, 4, null);
193
+        $page = substr($page, strlen($entete));
194
+    } else {
195
+        $avail = 'SYSTEM';
196
+        $grammaire = $doctype;
197
+        $rotlvl = basename($grammaire);
198
+    }
199
+
200
+    include_spip('xml/analyser_dtd');
201
+    $dtc = charger_dtd($grammaire, $avail, $rotlvl);
202
+    $page = sax_bug($page, $dtc, $charset);
203
+
204
+    // compatibilite Tidy espace public
205
+    if (!$phraseur) {
206
+        $indenter_xml = charger_fonction('indenter', 'xml');
207
+
208
+        return $indenter_xml($page, $apply);
209
+    }
210
+
211
+    $xml_parser = xml_parser_create($charset);
212
+
213
+    xml_set_element_handler($xml_parser,
214
+        array($phraseur, "debutElement"),
215
+        array($phraseur, "finElement"));
216
+
217
+    xml_set_character_data_handler($xml_parser,
218
+        array($phraseur, "textElement"));
219
+
220
+    xml_set_processing_instruction_handler($xml_parser,
221
+        array($phraseur, 'piElement'));
222
+
223
+    xml_set_default_handler($xml_parser,
224
+        array($phraseur, "defaultElement"));
225
+
226
+    xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
227
+
228
+    $phraseur->sax = $xml_parser;
229
+    if (isset($entete)) {
230
+        $phraseur->entete = $entete;
231
+    }
232
+    $phraseur->page = $page;
233
+    $phraseur->dtc = $dtc;
234
+    $phraseur->phraserTout($xml_parser, $page);
235
+    xml_parser_free($xml_parser);
236
+    $phraseur->sax = '';
237
+
238
+    return $phraseur;
239 239
 }
240 240
 
241 241
 // SAX ne dit pas si une Entite est dans un attribut ou non.
@@ -247,24 +247,24 @@  discard block
 block discarded – undo
247 247
 
248 248
 // https://code.spip.net/@sax_bug
249 249
 function sax_bug($data, $dtc, $charset = null) {
250
-	if (is_null($charset)) {
251
-		$charset = $GLOBALS['meta']['charset'];
252
-	}
253
-
254
-	if ($dtc) {
255
-		$trans = array();
256
-
257
-		foreach ($dtc->entites as $k => $v) {
258
-			if (!strpos(" amp lt gt quot ", $k)) {
259
-				$trans["&$k;"] = $v;
260
-			}
261
-		}
262
-		$data = strtr($data, $trans);
263
-	} else {
264
-		$data = html2unicode($data, true);
265
-	}
266
-
267
-	return unicode2charset($data, $charset);
250
+    if (is_null($charset)) {
251
+        $charset = $GLOBALS['meta']['charset'];
252
+    }
253
+
254
+    if ($dtc) {
255
+        $trans = array();
256
+
257
+        foreach ($dtc->entites as $k => $v) {
258
+            if (!strpos(" amp lt gt quot ", $k)) {
259
+                $trans["&$k;"] = $v;
260
+            }
261
+        }
262
+        $data = strtr($data, $trans);
263
+    } else {
264
+        $data = html2unicode($data, true);
265
+    }
266
+
267
+    return unicode2charset($data, $charset);
268 268
 }
269 269
 
270 270
 // Retirer < ? xml... ? > et autre PI, ainsi que les commentaires en debut
@@ -275,52 +275,52 @@  discard block
 block discarded – undo
275 275
 // mais un XML Schema que SPIP ne fait pas encore lire.
276 276
 // https://code.spip.net/@analyser_doctype
277 277
 function analyser_doctype($data) {
278
-	if (!preg_match(_REGEXP_DOCTYPE, $data, $page)) {
279
-		if (preg_match(_REGEXP_XML, $data, $page)) {
280
-			list(, $entete, $topelement) = $page;
281
-			if ($topelement == 'rss') {
282
-				return array(
283
-					$entete,
284
-					'PUBLIC',
285
-					_DOCTYPE_RSS,
286
-					'rss-0.91.dtd'
287
-				);
288
-			} else {
289
-				$dtd = $topelement . '.dtd';
290
-				$f = find_in_path($dtd);
291
-				if (file_exists($f)) {
292
-					return array($entete, 'SYSTEM', $f, $dtd);
293
-				}
294
-			}
295
-		}
296
-		spip_log("Dtd pas vu pour " . substr($data, 0, 100));
297
-
298
-		return array();
299
-	}
300
-	list($entete, , $topelement, $avail, $suite) = $page;
301
-
302
-	if (!preg_match('/^"([^"]*)"\s*(.*)$/', $suite, $r)) {
303
-		if (!preg_match("/^'([^']*)'\s*(.*)$/", $suite, $r)) {
304
-			return array();
305
-		}
306
-	}
307
-	list(, $rotlvl, $suite) = $r;
308
-
309
-	if (!$suite) {
310
-		if ($avail != 'SYSTEM') {
311
-			return array();
312
-		}
313
-		$grammaire = $rotlvl;
314
-		$rotlvl = '';
315
-	} else {
316
-		if (!preg_match('/^"([^"]*)"\s*$/', $suite, $r)) {
317
-			if (!preg_match("/^'([^']*)'\s*$/", $suite, $r)) {
318
-				return array();
319
-			}
320
-		}
321
-
322
-		$grammaire = $r[1];
323
-	}
324
-
325
-	return array($entete, $avail, $grammaire, $rotlvl);
278
+    if (!preg_match(_REGEXP_DOCTYPE, $data, $page)) {
279
+        if (preg_match(_REGEXP_XML, $data, $page)) {
280
+            list(, $entete, $topelement) = $page;
281
+            if ($topelement == 'rss') {
282
+                return array(
283
+                    $entete,
284
+                    'PUBLIC',
285
+                    _DOCTYPE_RSS,
286
+                    'rss-0.91.dtd'
287
+                );
288
+            } else {
289
+                $dtd = $topelement . '.dtd';
290
+                $f = find_in_path($dtd);
291
+                if (file_exists($f)) {
292
+                    return array($entete, 'SYSTEM', $f, $dtd);
293
+                }
294
+            }
295
+        }
296
+        spip_log("Dtd pas vu pour " . substr($data, 0, 100));
297
+
298
+        return array();
299
+    }
300
+    list($entete, , $topelement, $avail, $suite) = $page;
301
+
302
+    if (!preg_match('/^"([^"]*)"\s*(.*)$/', $suite, $r)) {
303
+        if (!preg_match("/^'([^']*)'\s*(.*)$/", $suite, $r)) {
304
+            return array();
305
+        }
306
+    }
307
+    list(, $rotlvl, $suite) = $r;
308
+
309
+    if (!$suite) {
310
+        if ($avail != 'SYSTEM') {
311
+            return array();
312
+        }
313
+        $grammaire = $rotlvl;
314
+        $rotlvl = '';
315
+    } else {
316
+        if (!preg_match('/^"([^"]*)"\s*$/', $suite, $r)) {
317
+            if (!preg_match("/^'([^']*)'\s*$/", $suite, $r)) {
318
+                return array();
319
+            }
320
+        }
321
+
322
+        $grammaire = $r[1];
323
+    }
324
+
325
+    return array($entete, $avail, $grammaire, $rotlvl);
326 326
 }
Please login to merge, or discard this patch.
ecrire/public/balises.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2884,8 +2884,7 @@
 block discarded – undo
2884 2884
 	$_const = interprete_argument_balise(1, $p);
2885 2885
 	if (!strlen($_const)) {
2886 2886
 		$p->code = "''";
2887
-	}
2888
-	else {
2887
+	} else {
2889 2888
 		$p->code = "(defined($_const)?constant($_const):'')";
2890 2889
 	}
2891 2890
 	$p->interdire_scripts = false;
Please login to merge, or discard this patch.
Indentation   +918 added lines, -918 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  **/
27 27
 
28 28
 if (!defined('_ECRIRE_INC_VERSION')) {
29
-	return;
29
+    return;
30 30
 }
31 31
 
32 32
 /**
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
  *     Code PHP si cet argument est présent, sinon null
49 49
  **/
50 50
 function interprete_argument_balise($n, $p) {
51
-	if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) {
52
-		return calculer_liste($p->param[0][$n],
53
-			$p->descr,
54
-			$p->boucles,
55
-			$p->id_boucle);
56
-	} else {
57
-		return null;
58
-	}
51
+    if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) {
52
+        return calculer_liste($p->param[0][$n],
53
+            $p->descr,
54
+            $p->boucles,
55
+            $p->id_boucle);
56
+    } else {
57
+        return null;
58
+    }
59 59
 }
60 60
 
61 61
 
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
  *     Pile complétée par le code à générer
76 76
  **/
77 77
 function balise_NOM_SITE_SPIP_dist($p) {
78
-	$p->code = "\$GLOBALS['meta']['nom_site']";
78
+    $p->code = "\$GLOBALS['meta']['nom_site']";
79 79
 
80
-	#$p->interdire_scripts = true;
81
-	return $p;
80
+    #$p->interdire_scripts = true;
81
+    return $p;
82 82
 }
83 83
 
84 84
 /**
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
  *     Pile complétée par le code à générer
95 95
  **/
96 96
 function balise_EMAIL_WEBMASTER_dist($p) {
97
-	$p->code = "\$GLOBALS['meta']['email_webmaster']";
97
+    $p->code = "\$GLOBALS['meta']['email_webmaster']";
98 98
 
99
-	#$p->interdire_scripts = true;
100
-	return $p;
99
+    #$p->interdire_scripts = true;
100
+    return $p;
101 101
 }
102 102
 
103 103
 /**
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
  *     Pile complétée par le code à générer
114 114
  **/
115 115
 function balise_DESCRIPTIF_SITE_SPIP_dist($p) {
116
-	$p->code = "\$GLOBALS['meta']['descriptif_site']";
116
+    $p->code = "\$GLOBALS['meta']['descriptif_site']";
117 117
 
118
-	#$p->interdire_scripts = true;
119
-	return $p;
118
+    #$p->interdire_scripts = true;
119
+    return $p;
120 120
 }
121 121
 
122 122
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
  *     Pile complétée par le code à générer
138 138
  **/
139 139
 function balise_CHARSET_dist($p) {
140
-	$p->code = "\$GLOBALS['meta']['charset']";
140
+    $p->code = "\$GLOBALS['meta']['charset']";
141 141
 
142
-	#$p->interdire_scripts = true;
143
-	return $p;
142
+    #$p->interdire_scripts = true;
143
+    return $p;
144 144
 }
145 145
 
146 146
 /**
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
  *     Pile complétée par le code à générer
166 166
  **/
167 167
 function balise_LANG_LEFT_dist($p) {
168
-	$_lang = champ_sql('lang', $p);
169
-	$p->code = "lang_dir($_lang, 'left','right')";
170
-	$p->interdire_scripts = false;
168
+    $_lang = champ_sql('lang', $p);
169
+    $p->code = "lang_dir($_lang, 'left','right')";
170
+    $p->interdire_scripts = false;
171 171
 
172
-	return $p;
172
+    return $p;
173 173
 }
174 174
 
175 175
 /**
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
  *     Pile complétée par le code à générer
190 190
  **/
191 191
 function balise_LANG_RIGHT_dist($p) {
192
-	$_lang = champ_sql('lang', $p);
193
-	$p->code = "lang_dir($_lang, 'right','left')";
194
-	$p->interdire_scripts = false;
192
+    $_lang = champ_sql('lang', $p);
193
+    $p->code = "lang_dir($_lang, 'right','left')";
194
+    $p->interdire_scripts = false;
195 195
 
196
-	return $p;
196
+    return $p;
197 197
 }
198 198
 
199 199
 /**
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
  *     Pile complétée par le code à générer
219 219
  **/
220 220
 function balise_LANG_DIR_dist($p) {
221
-	$_lang = champ_sql('lang', $p);
222
-	$p->code = "lang_dir($_lang, 'ltr','rtl')";
223
-	$p->interdire_scripts = false;
221
+    $_lang = champ_sql('lang', $p);
222
+    $p->code = "lang_dir($_lang, 'ltr','rtl')";
223
+    $p->interdire_scripts = false;
224 224
 
225
-	return $p;
225
+    return $p;
226 226
 }
227 227
 
228 228
 
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
  *     Pile complétée par le code à générer
240 240
  **/
241 241
 function balise_PUCE_dist($p) {
242
-	$p->code = "definir_puce()";
243
-	$p->interdire_scripts = false;
242
+    $p->code = "definir_puce()";
243
+    $p->interdire_scripts = false;
244 244
 
245
-	return $p;
245
+    return $p;
246 246
 }
247 247
 
248 248
 
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
  *     Pile completée du code PHP d'exécution de la balise
267 267
  */
268 268
 function balise_DATE_dist($p) {
269
-	$d = champ_sql('date', $p);
269
+    $d = champ_sql('date', $p);
270 270
 #	if ($d === "@\$Pile[0]['date']")
271 271
 #		$d = "isset(\$Pile[0]['date']) ? $d : time()";
272
-	$p->code = $d;
272
+    $p->code = $d;
273 273
 
274
-	return $p;
274
+    return $p;
275 275
 }
276 276
 
277 277
 
@@ -291,13 +291,13 @@  discard block
 block discarded – undo
291 291
  *     Pile completée du code PHP d'exécution de la balise
292 292
  */
293 293
 function balise_DATE_REDAC_dist($p) {
294
-	$d = champ_sql('date_redac', $p);
294
+    $d = champ_sql('date_redac', $p);
295 295
 #	if ($d === "@\$Pile[0]['date_redac']")
296 296
 #		$d = "isset(\$Pile[0]['date_redac']) ? $d : time()";
297
-	$p->code = $d;
298
-	$p->interdire_scripts = false;
297
+    $p->code = $d;
298
+    $p->interdire_scripts = false;
299 299
 
300
-	return $p;
300
+    return $p;
301 301
 }
302 302
 
303 303
 /**
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
  *     Pile completée du code PHP d'exécution de la balise
317 317
  */
318 318
 function balise_DATE_MODIF_dist($p) {
319
-	$p->code = champ_sql('date_modif', $p);
320
-	$p->interdire_scripts = false;
319
+    $p->code = champ_sql('date_modif', $p);
320
+    $p->interdire_scripts = false;
321 321
 
322
-	return $p;
322
+    return $p;
323 323
 }
324 324
 
325 325
 /**
@@ -337,13 +337,13 @@  discard block
 block discarded – undo
337 337
  *     Pile completée du code PHP d'exécution de la balise
338 338
  */
339 339
 function balise_DATE_NOUVEAUTES_dist($p) {
340
-	$p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui'
340
+    $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui'
341 341
 	AND isset(\$GLOBALS['meta']['dernier_envoi_neuf'])) ?
342 342
 	\$GLOBALS['meta']['dernier_envoi_neuf'] :
343 343
 	\"'0000-00-00'\")";
344
-	$p->interdire_scripts = false;
344
+    $p->interdire_scripts = false;
345 345
 
346
-	return $p;
346
+    return $p;
347 347
 }
348 348
 
349 349
 
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
  *     Pile completée du code PHP d'exécution de la balise
362 362
  */
363 363
 function balise_DOSSIER_SQUELETTE_dist($p) {
364
-	$code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));
365
-	$p->code = "_DIR_RACINE . '$code'" .
366
-		$p->interdire_scripts = false;
364
+    $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));
365
+    $p->code = "_DIR_RACINE . '$code'" .
366
+        $p->interdire_scripts = false;
367 367
 
368
-	return $p;
368
+    return $p;
369 369
 }
370 370
 
371 371
 /**
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
  *     Pile completée du code PHP d'exécution de la balise
381 381
  */
382 382
 function balise_SQUELETTE_dist($p) {
383
-	$code = addslashes($p->descr['sourcefile']);
384
-	$p->code = "'$code'" .
385
-		$p->interdire_scripts = false;
383
+    $code = addslashes($p->descr['sourcefile']);
384
+    $p->code = "'$code'" .
385
+        $p->interdire_scripts = false;
386 386
 
387
-	return $p;
387
+    return $p;
388 388
 }
389 389
 
390 390
 /**
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
  *     Pile completée du code PHP d'exécution de la balise
404 404
  */
405 405
 function balise_SPIP_VERSION_dist($p) {
406
-	$p->code = "spip_version()";
407
-	$p->interdire_scripts = false;
406
+    $p->code = "spip_version()";
407
+    $p->interdire_scripts = false;
408 408
 
409
-	return $p;
409
+    return $p;
410 410
 }
411 411
 
412 412
 
@@ -432,18 +432,18 @@  discard block
 block discarded – undo
432 432
  *     Pile complétée par le code à générer
433 433
  **/
434 434
 function balise_NOM_SITE_dist($p) {
435
-	if (!$p->etoile) {
436
-		$p->code = "supprimer_numero(calculer_url(" .
437
-			champ_sql('url_site', $p) . "," .
438
-			champ_sql('nom_site', $p) .
439
-			", 'titre', \$connect, false))";
440
-	} else {
441
-		$p->code = champ_sql('nom_site', $p);
442
-	}
435
+    if (!$p->etoile) {
436
+        $p->code = "supprimer_numero(calculer_url(" .
437
+            champ_sql('url_site', $p) . "," .
438
+            champ_sql('nom_site', $p) .
439
+            ", 'titre', \$connect, false))";
440
+    } else {
441
+        $p->code = champ_sql('nom_site', $p);
442
+    }
443 443
 
444
-	$p->interdire_scripts = true;
444
+    $p->interdire_scripts = true;
445 445
 
446
-	return $p;
446
+    return $p;
447 447
 }
448 448
 
449 449
 
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
  *     Pile complétée par le code à générer
461 461
  **/
462 462
 function balise_NOTES_dist($p) {
463
-	// Recuperer les notes
464
-	$p->code = 'calculer_notes()';
463
+    // Recuperer les notes
464
+    $p->code = 'calculer_notes()';
465 465
 
466
-	#$p->interdire_scripts = true;
467
-	return $p;
466
+    #$p->interdire_scripts = true;
467
+    return $p;
468 468
 }
469 469
 
470 470
 
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
  *     Pile complétée par le code à générer
487 487
  **/
488 488
 function balise_RECHERCHE_dist($p) {
489
-	$p->code = 'entites_html(_request("recherche"))';
490
-	$p->interdire_scripts = false;
489
+    $p->code = 'entites_html(_request("recherche"))';
490
+    $p->interdire_scripts = false;
491 491
 
492
-	return $p;
492
+    return $p;
493 493
 }
494 494
 
495 495
 
@@ -507,17 +507,17 @@  discard block
 block discarded – undo
507 507
  *     Pile complétée par le code à générer
508 508
  **/
509 509
 function balise_COMPTEUR_BOUCLE_dist($p) {
510
-	$b = index_boucle_mere($p);
511
-	if ($b === '') {
512
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
513
-		erreur_squelette($msg, $p);
514
-	} else {
515
-		$p->code = "\$Numrows['$b']['compteur_boucle']";
516
-		$p->boucles[$b]->cptrows = true;
517
-		$p->interdire_scripts = false;
510
+    $b = index_boucle_mere($p);
511
+    if ($b === '') {
512
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
513
+        erreur_squelette($msg, $p);
514
+    } else {
515
+        $p->code = "\$Numrows['$b']['compteur_boucle']";
516
+        $p->boucles[$b]->cptrows = true;
517
+        $p->interdire_scripts = false;
518 518
 
519
-		return $p;
520
-	}
519
+        return $p;
520
+    }
521 521
 }
522 522
 
523 523
 /**
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
  *     Pile complétée par le code à générer
536 536
  **/
537 537
 function balise_TOTAL_BOUCLE_dist($p) {
538
-	$b = index_boucle_mere($p);
539
-	if ($b === '') {
540
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
541
-		erreur_squelette($msg, $p);
542
-	} else {
543
-		$p->code = "\$Numrows['$b']['total']";
544
-		$p->boucles[$b]->numrows = true;
545
-		$p->interdire_scripts = false;
546
-	}
538
+    $b = index_boucle_mere($p);
539
+    if ($b === '') {
540
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
541
+        erreur_squelette($msg, $p);
542
+    } else {
543
+        $p->code = "\$Numrows['$b']['total']";
544
+        $p->boucles[$b]->numrows = true;
545
+        $p->interdire_scripts = false;
546
+    }
547 547
 
548
-	return $p;
548
+    return $p;
549 549
 }
550 550
 
551 551
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
  *     Pile complétée par le code à générer
566 566
  **/
567 567
 function balise_POINTS_dist($p) {
568
-	return rindex_pile($p, 'points', 'recherche');
568
+    return rindex_pile($p, 'points', 'recherche');
569 569
 }
570 570
 
571 571
 
@@ -586,12 +586,12 @@  discard block
 block discarded – undo
586 586
  *     Pile complétée par le code à générer
587 587
  **/
588 588
 function balise_POPULARITE_ABSOLUE_dist($p) {
589
-	$p->code = 'ceil(' .
590
-		champ_sql('popularite', $p) .
591
-		')';
592
-	$p->interdire_scripts = false;
589
+    $p->code = 'ceil(' .
590
+        champ_sql('popularite', $p) .
591
+        ')';
592
+    $p->interdire_scripts = false;
593 593
 
594
-	return $p;
594
+    return $p;
595 595
 }
596 596
 
597 597
 /**
@@ -611,10 +611,10 @@  discard block
 block discarded – undo
611 611
  *     Pile complétée par le code à générer
612 612
  **/
613 613
 function balise_POPULARITE_SITE_dist($p) {
614
-	$p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])';
615
-	$p->interdire_scripts = false;
614
+    $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])';
615
+    $p->interdire_scripts = false;
616 616
 
617
-	return $p;
617
+    return $p;
618 618
 }
619 619
 
620 620
 /**
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
  *     Pile complétée par le code à générer
636 636
  **/
637 637
 function balise_POPULARITE_MAX_dist($p) {
638
-	$p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])';
639
-	$p->interdire_scripts = false;
638
+    $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])';
639
+    $p->interdire_scripts = false;
640 640
 
641
-	return $p;
641
+    return $p;
642 642
 }
643 643
 
644 644
 
@@ -664,14 +664,14 @@  discard block
 block discarded – undo
664 664
  *     Pile complétée par le code à générer
665 665
  **/
666 666
 function balise_VALEUR_dist($p) {
667
-	$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
668
-	$p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;
669
-	if (($v = interprete_argument_balise(1, $p)) !== null) {
670
-		$p->code = 'table_valeur(' . $p->code . ', ' . $v . ')';
671
-	}
672
-	$p->interdire_scripts = true;
667
+    $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
668
+    $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;
669
+    if (($v = interprete_argument_balise(1, $p)) !== null) {
670
+        $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')';
671
+    }
672
+    $p->interdire_scripts = true;
673 673
 
674
-	return $p;
674
+    return $p;
675 675
 }
676 676
 
677 677
 /**
@@ -700,17 +700,17 @@  discard block
 block discarded – undo
700 700
  *     Pile complétée par le code à générer
701 701
  **/
702 702
 function balise_EXPOSE_dist($p) {
703
-	$on = "'on'";
704
-	$off = "''";
705
-	if (($v = interprete_argument_balise(1, $p)) !== null) {
706
-		$on = $v;
707
-		if (($v = interprete_argument_balise(2, $p)) !== null) {
708
-			$off = $v;
709
-		}
703
+    $on = "'on'";
704
+    $off = "''";
705
+    if (($v = interprete_argument_balise(1, $p)) !== null) {
706
+        $on = $v;
707
+        if (($v = interprete_argument_balise(2, $p)) !== null) {
708
+            $off = $v;
709
+        }
710 710
 
711
-	}
711
+    }
712 712
 
713
-	return calculer_balise_expose($p, $on, $off);
713
+    return calculer_balise_expose($p, $on, $off);
714 714
 }
715 715
 
716 716
 /**
@@ -728,36 +728,36 @@  discard block
 block discarded – undo
728 728
  *     Pile complétée par le code à générer
729 729
  **/
730 730
 function calculer_balise_expose($p, $on, $off) {
731
-	$b = index_boucle($p);
732
-	if (empty($p->boucles[$b]->primary)) {
733
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
734
-		erreur_squelette($msg, $p);
735
-	} else {
731
+    $b = index_boucle($p);
732
+    if (empty($p->boucles[$b]->primary)) {
733
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
734
+        erreur_squelette($msg, $p);
735
+    } else {
736 736
 
737
-		$key = $p->boucles[$b]->primary;
738
-		$type = $p->boucles[$p->id_boucle]->primary;
739
-		$desc = $p->boucles[$b]->show;
740
-		$connect = sql_quote($p->boucles[$b]->sql_serveur);
737
+        $key = $p->boucles[$b]->primary;
738
+        $type = $p->boucles[$p->id_boucle]->primary;
739
+        $desc = $p->boucles[$b]->show;
740
+        $connect = sql_quote($p->boucles[$b]->sql_serveur);
741 741
 
742
-		// Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite
743
-		$c = index_pile($p->id_boucle, $type, $p->boucles);
742
+        // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite
743
+        $c = index_pile($p->id_boucle, $type, $p->boucles);
744 744
 
745
-		if (isset($desc['field']['id_parent'])) {
746
-			$parent = 0; // pour if (!$parent) dans calculer_expose
747
-		} elseif (isset($desc['field']['id_rubrique'])) {
748
-			$parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b);
749
-		} elseif (isset($desc['field']['id_groupe'])) {
750
-			$parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b);
751
-		} else {
752
-			$parent = "''";
753
-		}
745
+        if (isset($desc['field']['id_parent'])) {
746
+            $parent = 0; // pour if (!$parent) dans calculer_expose
747
+        } elseif (isset($desc['field']['id_rubrique'])) {
748
+            $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b);
749
+        } elseif (isset($desc['field']['id_groupe'])) {
750
+            $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b);
751
+        } else {
752
+            $parent = "''";
753
+        }
754 754
 
755
-		$p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)";
756
-	}
755
+        $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)";
756
+    }
757 757
 
758
-	$p->interdire_scripts = false;
758
+    $p->interdire_scripts = false;
759 759
 
760
-	return $p;
760
+    return $p;
761 761
 }
762 762
 
763 763
 
@@ -797,46 +797,46 @@  discard block
 block discarded – undo
797 797
  **/
798 798
 function balise_INTRODUCTION_dist($p) {
799 799
 
800
-	$type_objet = $p->type_requete;
801
-	$cle_objet = id_table_objet($type_objet);
802
-	$_id_objet = champ_sql($cle_objet, $p);
803
-
804
-	// Récupérer les valeurs sql nécessaires : descriptif, texte et chapo
805
-	// ainsi que le longueur d'introduction donnée dans la description de l'objet.
806
-	$_introduction_longueur = 'null';
807
-	$_ligne = 'array(';
808
-	$trouver_table = charger_fonction('trouver_table', 'base');
809
-	if ($desc = $trouver_table(table_objet_sql($type_objet))) {
810
-		if (isset($desc['field']['descriptif'])) {
811
-			$_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ',';
812
-		}
813
-		if (isset($desc['field']['texte'])) {
814
-			$_ligne .= "'texte' => " . champ_sql('texte', $p) . ',';
815
-		}
816
-		if (isset($desc['field']['chapo'])) {
817
-			$_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ',';
818
-		}
819
-		if (isset($desc['introduction_longueur'])) {
820
-			$_introduction_longueur = "'" . $desc['introduction_longueur'] . "'";
821
-		}
822
-	}
823
-	$_ligne .= ')';
824
-
825
-	// Récupérer la longueur et la suite passés en paramètres
826
-	$_longueur_ou_suite = 'null';
827
-	if (($v1 = interprete_argument_balise(1, $p)) !== null) {
828
-		$_longueur_ou_suite = $v1;
829
-	}
830
-	$_suite = 'null';
831
-	if (($v2 = interprete_argument_balise(2, $p)) !== null) {
832
-		$_suite = $v2;
833
-	}
834
-
835
-	$p->code = "generer_introduction_entite($_id_objet, '$type_objet', $_ligne, $_introduction_longueur, $_longueur_ou_suite, $_suite, \$connect)";
836
-
837
-	#$p->interdire_scripts = true;
838
-	$p->etoile = '*'; // propre est deja fait dans le calcul de l'intro
839
-	return $p;
800
+    $type_objet = $p->type_requete;
801
+    $cle_objet = id_table_objet($type_objet);
802
+    $_id_objet = champ_sql($cle_objet, $p);
803
+
804
+    // Récupérer les valeurs sql nécessaires : descriptif, texte et chapo
805
+    // ainsi que le longueur d'introduction donnée dans la description de l'objet.
806
+    $_introduction_longueur = 'null';
807
+    $_ligne = 'array(';
808
+    $trouver_table = charger_fonction('trouver_table', 'base');
809
+    if ($desc = $trouver_table(table_objet_sql($type_objet))) {
810
+        if (isset($desc['field']['descriptif'])) {
811
+            $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ',';
812
+        }
813
+        if (isset($desc['field']['texte'])) {
814
+            $_ligne .= "'texte' => " . champ_sql('texte', $p) . ',';
815
+        }
816
+        if (isset($desc['field']['chapo'])) {
817
+            $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ',';
818
+        }
819
+        if (isset($desc['introduction_longueur'])) {
820
+            $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'";
821
+        }
822
+    }
823
+    $_ligne .= ')';
824
+
825
+    // Récupérer la longueur et la suite passés en paramètres
826
+    $_longueur_ou_suite = 'null';
827
+    if (($v1 = interprete_argument_balise(1, $p)) !== null) {
828
+        $_longueur_ou_suite = $v1;
829
+    }
830
+    $_suite = 'null';
831
+    if (($v2 = interprete_argument_balise(2, $p)) !== null) {
832
+        $_suite = $v2;
833
+    }
834
+
835
+    $p->code = "generer_introduction_entite($_id_objet, '$type_objet', $_ligne, $_introduction_longueur, $_longueur_ou_suite, $_suite, \$connect)";
836
+
837
+    #$p->interdire_scripts = true;
838
+    $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro
839
+    return $p;
840 840
 }
841 841
 
842 842
 
@@ -856,15 +856,15 @@  discard block
 block discarded – undo
856 856
  *     Pile complétée par le code à générer
857 857
  **/
858 858
 function balise_LANG_dist($p) {
859
-	$_lang = champ_sql('lang', $p);
860
-	if (!$p->etoile) {
861
-		$p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";
862
-	} else {
863
-		$p->code = "spip_htmlentities($_lang)";
864
-	}
865
-	$p->interdire_scripts = false;
859
+    $_lang = champ_sql('lang', $p);
860
+    if (!$p->etoile) {
861
+        $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";
862
+    } else {
863
+        $p->code = "spip_htmlentities($_lang)";
864
+    }
865
+    $p->interdire_scripts = false;
866 866
 
867
-	return $p;
867
+    return $p;
868 868
 }
869 869
 
870 870
 /**
@@ -886,44 +886,44 @@  discard block
 block discarded – undo
886 886
  *     Pile complétée par le code à générer
887 887
  */
888 888
 function balise_LESAUTEURS_dist($p) {
889
-	// Cherche le champ 'lesauteurs' dans la pile
890
-	$_lesauteurs = champ_sql('lesauteurs', $p, false);
891
-
892
-	// Si le champ n'existe pas (cas de spip_articles), on applique
893
-	// le modele lesauteurs.html en passant id_article dans le contexte;
894
-	// dans le cas contraire on prend le champ 'lesauteurs'
895
-	// (cf extension sites/)
896
-	if ($_lesauteurs
897
-		and $_lesauteurs != '@$Pile[0][\'lesauteurs\']'
898
-	) {
899
-		$p->code = "safehtml($_lesauteurs)";
900
-		// $p->interdire_scripts = true;
901
-	} else {
902
-		if (!$p->id_boucle) {
903
-			$connect = '';
904
-			$objet = 'article';
905
-			$id_table_objet = 'id_article';
906
-		} else {
907
-			$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
908
-			$connect = $p->boucles[$b]->sql_serveur;
909
-			$type_boucle = $p->boucles[$b]->type_requete;
910
-			$objet = objet_type($type_boucle);
911
-			$id_table_objet = id_table_objet($type_boucle);
912
-		}
913
-		$c = memoriser_contexte_compil($p);
914
-
915
-		$p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",
916
-			"array('objet'=>'" . $objet .
917
-			"','id_objet' => " . champ_sql($id_table_objet, $p) .
918
-			",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .
919
-			($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) .
920
-			")",
921
-			"'trim'=>true, 'compil'=>array($c)",
922
-			_q($connect));
923
-		$p->interdire_scripts = false; // securite apposee par recuperer_fond()
924
-	}
925
-
926
-	return $p;
889
+    // Cherche le champ 'lesauteurs' dans la pile
890
+    $_lesauteurs = champ_sql('lesauteurs', $p, false);
891
+
892
+    // Si le champ n'existe pas (cas de spip_articles), on applique
893
+    // le modele lesauteurs.html en passant id_article dans le contexte;
894
+    // dans le cas contraire on prend le champ 'lesauteurs'
895
+    // (cf extension sites/)
896
+    if ($_lesauteurs
897
+        and $_lesauteurs != '@$Pile[0][\'lesauteurs\']'
898
+    ) {
899
+        $p->code = "safehtml($_lesauteurs)";
900
+        // $p->interdire_scripts = true;
901
+    } else {
902
+        if (!$p->id_boucle) {
903
+            $connect = '';
904
+            $objet = 'article';
905
+            $id_table_objet = 'id_article';
906
+        } else {
907
+            $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
908
+            $connect = $p->boucles[$b]->sql_serveur;
909
+            $type_boucle = $p->boucles[$b]->type_requete;
910
+            $objet = objet_type($type_boucle);
911
+            $id_table_objet = id_table_objet($type_boucle);
912
+        }
913
+        $c = memoriser_contexte_compil($p);
914
+
915
+        $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",
916
+            "array('objet'=>'" . $objet .
917
+            "','id_objet' => " . champ_sql($id_table_objet, $p) .
918
+            ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .
919
+            ($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) .
920
+            ")",
921
+            "'trim'=>true, 'compil'=>array($c)",
922
+            _q($connect));
923
+        $p->interdire_scripts = false; // securite apposee par recuperer_fond()
924
+    }
925
+
926
+    return $p;
927 927
 }
928 928
 
929 929
 
@@ -950,75 +950,75 @@  discard block
 block discarded – undo
950 950
  *     Pile complétée par le code à générer
951 951
  */
952 952
 function balise_RANG_dist($p) {
953
-	$b = index_boucle($p);
954
-	if ($b === '') {
955
-		$msg = array(
956
-			'zbug_champ_hors_boucle',
957
-			array('champ' => '#RANG')
958
-		);
959
-		erreur_squelette($msg, $p);
960
-	} else {
961
-		// chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql)
962
-		// dans la boucle immediatement englobante uniquement
963
-		// sinon on compose le champ calcule
964
-		$_rang = champ_sql('rang', $p, '', false);
965
-
966
-		// si pas trouve de champ sql rang :
967
-		if (!$_rang or $_rang == "''") {
968
-			$boucle = &$p->boucles[$b];
969
-
970
-			// on gere le cas ou #RANG est une extraction du numero dans le titre
971
-			$trouver_table = charger_fonction('trouver_table', 'base');
972
-			$desc = $trouver_table($boucle->id_table);
973
-			$_titre = ''; # où extraire le numero ?
953
+    $b = index_boucle($p);
954
+    if ($b === '') {
955
+        $msg = array(
956
+            'zbug_champ_hors_boucle',
957
+            array('champ' => '#RANG')
958
+        );
959
+        erreur_squelette($msg, $p);
960
+    } else {
961
+        // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql)
962
+        // dans la boucle immediatement englobante uniquement
963
+        // sinon on compose le champ calcule
964
+        $_rang = champ_sql('rang', $p, '', false);
965
+
966
+        // si pas trouve de champ sql rang :
967
+        if (!$_rang or $_rang == "''") {
968
+            $boucle = &$p->boucles[$b];
969
+
970
+            // on gere le cas ou #RANG est une extraction du numero dans le titre
971
+            $trouver_table = charger_fonction('trouver_table', 'base');
972
+            $desc = $trouver_table($boucle->id_table);
973
+            $_titre = ''; # où extraire le numero ?
974 974
 			
975
-			if (isset($desc['titre'])) {
976
-				$t = $desc['titre'];
977
-				if (
978
-					// Soit on trouve avec la déclaration de la lang AVANT
979
-					preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m)
980
-					// Soit on prend depuis le début
981
-					or preg_match(';^(.*?titre)\s*(,|$);', $t, $m)
982
-				) {
983
-					$m = preg_replace(',as\s+titre$,i', '', $m[1]);
984
-					$m = trim($m);
985
-					if ($m != "''") {
986
-						if (!preg_match(",\W,", $m)) {
987
-							$m = $boucle->id_table . ".$m";
988
-						}
975
+            if (isset($desc['titre'])) {
976
+                $t = $desc['titre'];
977
+                if (
978
+                    // Soit on trouve avec la déclaration de la lang AVANT
979
+                    preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m)
980
+                    // Soit on prend depuis le début
981
+                    or preg_match(';^(.*?titre)\s*(,|$);', $t, $m)
982
+                ) {
983
+                    $m = preg_replace(',as\s+titre$,i', '', $m[1]);
984
+                    $m = trim($m);
985
+                    if ($m != "''") {
986
+                        if (!preg_match(",\W,", $m)) {
987
+                            $m = $boucle->id_table . ".$m";
988
+                        }
989 989
 						
990
-						$m .= " AS titre_rang";
991
-
992
-						$boucle->select[] = $m;
993
-						$_titre = '$Pile[$SP][\'titre_rang\']';
994
-					}
995
-				}
996
-			}
997
-
998
-			// si on n'a rien trouvé, on utilise le champ titre classique
999
-			if (!$_titre) {
1000
-				$_titre = champ_sql('titre', $p);
1001
-			}
1002
-
1003
-			// et on recupere aussi les infos de liaison si on est en train d'editer les liens justement
1004
-			// cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS
1005
-			$type_boucle = $boucle->type_requete;
1006
-			$objet = objet_type($type_boucle);
1007
-			$id_table_objet = id_table_objet($type_boucle);
1008
-			$_primary = champ_sql($id_table_objet, $p, '', false);
1009
-			$_env = '$Pile[0]';
1010
-
1011
-			if (!$_titre) {$_titre = "''";}
1012
-			if (!$_primary) {$_primary = "''";}
1013
-			$_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)";
1014
-
1015
-		}
990
+                        $m .= " AS titre_rang";
991
+
992
+                        $boucle->select[] = $m;
993
+                        $_titre = '$Pile[$SP][\'titre_rang\']';
994
+                    }
995
+                }
996
+            }
997
+
998
+            // si on n'a rien trouvé, on utilise le champ titre classique
999
+            if (!$_titre) {
1000
+                $_titre = champ_sql('titre', $p);
1001
+            }
1002
+
1003
+            // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement
1004
+            // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS
1005
+            $type_boucle = $boucle->type_requete;
1006
+            $objet = objet_type($type_boucle);
1007
+            $id_table_objet = id_table_objet($type_boucle);
1008
+            $_primary = champ_sql($id_table_objet, $p, '', false);
1009
+            $_env = '$Pile[0]';
1010
+
1011
+            if (!$_titre) {$_titre = "''";}
1012
+            if (!$_primary) {$_primary = "''";}
1013
+            $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)";
1014
+
1015
+        }
1016 1016
 		
1017
-		$p->code = $_rang;
1018
-		$p->interdire_scripts = false;
1019
-	}
1017
+        $p->code = $_rang;
1018
+        $p->interdire_scripts = false;
1019
+    }
1020 1020
 	
1021
-	return $p;
1021
+    return $p;
1022 1022
 }
1023 1023
 
1024 1024
 
@@ -1040,12 +1040,12 @@  discard block
 block discarded – undo
1040 1040
  *     Pile complétée par le code à générer
1041 1041
  **/
1042 1042
 function balise_POPULARITE_dist($p) {
1043
-	$_popularite = champ_sql('popularite', $p);
1044
-	$p->code = "(ceil(min(100, 100 * $_popularite
1043
+    $_popularite = champ_sql('popularite', $p);
1044
+    $p->code = "(ceil(min(100, 100 * $_popularite
1045 1045
 	/ max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))";
1046
-	$p->interdire_scripts = false;
1046
+    $p->interdire_scripts = false;
1047 1047
 
1048
-	return $p;
1048
+    return $p;
1049 1049
 }
1050 1050
 
1051 1051
 /**
@@ -1092,65 +1092,65 @@  discard block
 block discarded – undo
1092 1092
  *     Pile complétée par le code à générer
1093 1093
  */
1094 1094
 function balise_PAGINATION_dist($p, $liste = 'true') {
1095
-	$b = index_boucle_mere($p);
1096
-
1097
-	// s'il n'y a pas de nom de boucle, on ne peut pas paginer
1098
-	if ($b === '') {
1099
-		$msg = array(
1100
-			'zbug_champ_hors_boucle',
1101
-			array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION')
1102
-		);
1103
-		erreur_squelette($msg, $p);
1104
-
1105
-		return $p;
1106
-	}
1107
-
1108
-	// s'il n'y a pas de mode_partie, c'est qu'on se trouve
1109
-	// dans un boucle recursive ou qu'on a oublie le critere {pagination}
1110
-	if (!$p->boucles[$b]->mode_partie) {
1111
-		if (!$p->boucles[$b]->table_optionnelle) {
1112
-			$msg = array(
1113
-				'zbug_pagination_sans_critere',
1114
-				array('champ' => '#PAGINATION')
1115
-			);
1116
-			erreur_squelette($msg, $p);
1117
-		}
1118
-
1119
-		return $p;
1120
-	}
1121
-
1122
-	// a priori true
1123
-	// si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise
1124
-	// si true, les arguments simples (sans truc=chose) vont degager
1125
-	$_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false);
1126
-	if (count($_contexte)) {
1127
-		$key = key($_contexte);
1128
-		if (is_numeric($key)) {
1129
-			array_shift($_contexte);
1130
-			$__modele = interprete_argument_balise(1, $p);
1131
-		}
1132
-	}
1133
-
1134
-	if (count($_contexte)) {
1135
-		$code_contexte = implode(',', $_contexte);
1136
-	} else {
1137
-		$code_contexte = '';
1138
-	}
1139
-
1140
-	$connect = $p->boucles[$b]->sql_serveur;
1141
-	$pas = $p->boucles[$b]->total_parties;
1142
-	$f_pagination = chercher_filtre('pagination');
1143
-	$type = $p->boucles[$b]->modificateur['debut_nom'];
1144
-	$modif = ($type[0] !== "'") ? "'debut'.$type"
1145
-		: ("'debut" . substr($type, 1));
1146
-
1147
-	$p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,
1148
-		((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);
1149
-
1150
-	$p->boucles[$b]->numrows = true;
1151
-	$p->interdire_scripts = false;
1152
-
1153
-	return $p;
1095
+    $b = index_boucle_mere($p);
1096
+
1097
+    // s'il n'y a pas de nom de boucle, on ne peut pas paginer
1098
+    if ($b === '') {
1099
+        $msg = array(
1100
+            'zbug_champ_hors_boucle',
1101
+            array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION')
1102
+        );
1103
+        erreur_squelette($msg, $p);
1104
+
1105
+        return $p;
1106
+    }
1107
+
1108
+    // s'il n'y a pas de mode_partie, c'est qu'on se trouve
1109
+    // dans un boucle recursive ou qu'on a oublie le critere {pagination}
1110
+    if (!$p->boucles[$b]->mode_partie) {
1111
+        if (!$p->boucles[$b]->table_optionnelle) {
1112
+            $msg = array(
1113
+                'zbug_pagination_sans_critere',
1114
+                array('champ' => '#PAGINATION')
1115
+            );
1116
+            erreur_squelette($msg, $p);
1117
+        }
1118
+
1119
+        return $p;
1120
+    }
1121
+
1122
+    // a priori true
1123
+    // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise
1124
+    // si true, les arguments simples (sans truc=chose) vont degager
1125
+    $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false);
1126
+    if (count($_contexte)) {
1127
+        $key = key($_contexte);
1128
+        if (is_numeric($key)) {
1129
+            array_shift($_contexte);
1130
+            $__modele = interprete_argument_balise(1, $p);
1131
+        }
1132
+    }
1133
+
1134
+    if (count($_contexte)) {
1135
+        $code_contexte = implode(',', $_contexte);
1136
+    } else {
1137
+        $code_contexte = '';
1138
+    }
1139
+
1140
+    $connect = $p->boucles[$b]->sql_serveur;
1141
+    $pas = $p->boucles[$b]->total_parties;
1142
+    $f_pagination = chercher_filtre('pagination');
1143
+    $type = $p->boucles[$b]->modificateur['debut_nom'];
1144
+    $modif = ($type[0] !== "'") ? "'debut'.$type"
1145
+        : ("'debut" . substr($type, 1));
1146
+
1147
+    $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,
1148
+        ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);
1149
+
1150
+    $p->boucles[$b]->numrows = true;
1151
+    $p->interdire_scripts = false;
1152
+
1153
+    return $p;
1154 1154
 }
1155 1155
 
1156 1156
 
@@ -1177,11 +1177,11 @@  discard block
 block discarded – undo
1177 1177
  *     Pile complétée par le code à générer
1178 1178
  **/
1179 1179
 function balise_ANCRE_PAGINATION_dist($p) {
1180
-	if ($f = charger_fonction('PAGINATION', 'balise', true)) {
1181
-		return $f($p, $liste = 'false');
1182
-	} else {
1183
-		return null;
1184
-	} // ou une erreur ?
1180
+    if ($f = charger_fonction('PAGINATION', 'balise', true)) {
1181
+        return $f($p, $liste = 'false');
1182
+    } else {
1183
+        return null;
1184
+    } // ou une erreur ?
1185 1185
 }
1186 1186
 
1187 1187
 
@@ -1202,18 +1202,18 @@  discard block
 block discarded – undo
1202 1202
  *     Pile complétée par le code à générer
1203 1203
  **/
1204 1204
 function balise_GRAND_TOTAL_dist($p) {
1205
-	$b = index_boucle_mere($p);
1206
-	if ($b === '') {
1207
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
1208
-		erreur_squelette($msg, $p);
1209
-	} else {
1210
-		$p->code = "(isset(\$Numrows['$b']['grand_total'])
1205
+    $b = index_boucle_mere($p);
1206
+    if ($b === '') {
1207
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
1208
+        erreur_squelette($msg, $p);
1209
+    } else {
1210
+        $p->code = "(isset(\$Numrows['$b']['grand_total'])
1211 1211
 			? \$Numrows['$b']['grand_total'] : \$Numrows['$b']['total'])";
1212
-		$p->boucles[$b]->numrows = true;
1213
-		$p->interdire_scripts = false;
1214
-	}
1212
+        $p->boucles[$b]->numrows = true;
1213
+        $p->interdire_scripts = false;
1214
+    }
1215 1215
 
1216
-	return $p;
1216
+    return $p;
1217 1217
 }
1218 1218
 
1219 1219
 
@@ -1241,10 +1241,10 @@  discard block
 block discarded – undo
1241 1241
  *     Pile complétée par le code à générer
1242 1242
  **/
1243 1243
 function balise_SELF_dist($p) {
1244
-	$p->code = 'self()';
1245
-	$p->interdire_scripts = false;
1244
+    $p->code = 'self()';
1245
+    $p->interdire_scripts = false;
1246 1246
 
1247
-	return $p;
1247
+    return $p;
1248 1248
 }
1249 1249
 
1250 1250
 
@@ -1271,17 +1271,17 @@  discard block
 block discarded – undo
1271 1271
  *     Pile complétée par le code à générer
1272 1272
  **/
1273 1273
 function balise_CHEMIN_dist($p) {
1274
-	$arg = interprete_argument_balise(1, $p);
1275
-	if (!$arg) {
1276
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN'));
1277
-		erreur_squelette($msg, $p);
1278
-	} else {
1279
-		$p->code = 'find_in_path(' . $arg . ')';
1280
-	}
1274
+    $arg = interprete_argument_balise(1, $p);
1275
+    if (!$arg) {
1276
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN'));
1277
+        erreur_squelette($msg, $p);
1278
+    } else {
1279
+        $p->code = 'find_in_path(' . $arg . ')';
1280
+    }
1281 1281
 
1282
-	$p->interdire_scripts = false;
1282
+    $p->interdire_scripts = false;
1283 1283
 
1284
-	return $p;
1284
+    return $p;
1285 1285
 }
1286 1286
 
1287 1287
 /**
@@ -1306,16 +1306,16 @@  discard block
 block discarded – undo
1306 1306
  *     Pile complétée par le code à générer
1307 1307
  **/
1308 1308
 function balise_CHEMIN_IMAGE_dist($p) {
1309
-	$arg = interprete_argument_balise(1, $p);
1310
-	if (!$arg) {
1311
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE'));
1312
-		erreur_squelette($msg, $p);
1313
-	} else {
1314
-		$p->code = 'chemin_image(' . $arg . ')';
1315
-	}
1309
+    $arg = interprete_argument_balise(1, $p);
1310
+    if (!$arg) {
1311
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE'));
1312
+        erreur_squelette($msg, $p);
1313
+    } else {
1314
+        $p->code = 'chemin_image(' . $arg . ')';
1315
+    }
1316 1316
 
1317
-	$p->interdire_scripts = false;
1318
-	return $p;
1317
+    $p->interdire_scripts = false;
1318
+    return $p;
1319 1319
 }
1320 1320
 
1321 1321
 
@@ -1353,36 +1353,36 @@  discard block
 block discarded – undo
1353 1353
  **/
1354 1354
 function balise_ENV_dist($p, $src = null) {
1355 1355
 
1356
-	// cle du tableau desiree
1357
-	$_nom = interprete_argument_balise(1, $p);
1358
-	// valeur par defaut
1359
-	$_sinon = interprete_argument_balise(2, $p);
1356
+    // cle du tableau desiree
1357
+    $_nom = interprete_argument_balise(1, $p);
1358
+    // valeur par defaut
1359
+    $_sinon = interprete_argument_balise(2, $p);
1360 1360
 
1361
-	// $src est un tableau de donnees sources eventuellement transmis
1362
-	// en absence, on utilise l'environnement du squelette $Pile[0]
1361
+    // $src est un tableau de donnees sources eventuellement transmis
1362
+    // en absence, on utilise l'environnement du squelette $Pile[0]
1363 1363
 
1364
-	if (!$_nom) {
1365
-		// cas de #ENV sans argument : on retourne le serialize() du tableau
1366
-		// une belle fonction [(#ENV|affiche_env)] serait pratique
1367
-		if ($src) {
1368
-			$p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")';
1369
-		} else {
1370
-			$p->code = '@serialize($Pile[0])';
1371
-		}
1372
-	} else {
1373
-		if (!$src) {
1374
-			$src = '@$Pile[0]';
1375
-		}
1376
-		if ($_sinon) {
1377
-			$p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)";
1378
-		} else {
1379
-			$p->code = "table_valeur($src, (string)$_nom, null)";
1380
-		}
1381
-	}
1364
+    if (!$_nom) {
1365
+        // cas de #ENV sans argument : on retourne le serialize() du tableau
1366
+        // une belle fonction [(#ENV|affiche_env)] serait pratique
1367
+        if ($src) {
1368
+            $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")';
1369
+        } else {
1370
+            $p->code = '@serialize($Pile[0])';
1371
+        }
1372
+    } else {
1373
+        if (!$src) {
1374
+            $src = '@$Pile[0]';
1375
+        }
1376
+        if ($_sinon) {
1377
+            $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)";
1378
+        } else {
1379
+            $p->code = "table_valeur($src, (string)$_nom, null)";
1380
+        }
1381
+    }
1382 1382
 
1383
-	#$p->interdire_scripts = true;
1383
+    #$p->interdire_scripts = true;
1384 1384
 
1385
-	return $p;
1385
+    return $p;
1386 1386
 }
1387 1387
 
1388 1388
 /**
@@ -1412,16 +1412,16 @@  discard block
 block discarded – undo
1412 1412
  *     Pile completée du code PHP d'exécution de la balise
1413 1413
  */
1414 1414
 function balise_CONFIG_dist($p) {
1415
-	if (!$arg = interprete_argument_balise(1, $p)) {
1416
-		$arg = "''";
1417
-	}
1418
-	$_sinon = interprete_argument_balise(2, $p);
1419
-	$_unserialize = sinon(interprete_argument_balise(3, $p), "false");
1415
+    if (!$arg = interprete_argument_balise(1, $p)) {
1416
+        $arg = "''";
1417
+    }
1418
+    $_sinon = interprete_argument_balise(2, $p);
1419
+    $_unserialize = sinon(interprete_argument_balise(3, $p), "false");
1420 1420
 
1421
-	$p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' .
1422
-		($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";
1421
+    $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' .
1422
+        ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";
1423 1423
 
1424
-	return $p;
1424
+    return $p;
1425 1425
 }
1426 1426
 
1427 1427
 
@@ -1444,10 +1444,10 @@  discard block
 block discarded – undo
1444 1444
  *     Pile completée du code PHP d'exécution de la balise
1445 1445
  */
1446 1446
 function balise_CONNECT_dist($p) {
1447
-	$p->code = '($connect ? $connect : NULL)';
1448
-	$p->interdire_scripts = false;
1447
+    $p->code = '($connect ? $connect : NULL)';
1448
+    $p->interdire_scripts = false;
1449 1449
 
1450
-	return $p;
1450
+    return $p;
1451 1451
 }
1452 1452
 
1453 1453
 
@@ -1475,15 +1475,15 @@  discard block
 block discarded – undo
1475 1475
  *     Pile completée du code PHP d'exécution de la balise
1476 1476
  **/
1477 1477
 function balise_SESSION_dist($p) {
1478
-	$p->descr['session'] = true;
1478
+    $p->descr['session'] = true;
1479 1479
 
1480
-	$f = function_exists('balise_ENV')
1481
-		? 'balise_ENV'
1482
-		: 'balise_ENV_dist';
1480
+    $f = function_exists('balise_ENV')
1481
+        ? 'balise_ENV'
1482
+        : 'balise_ENV_dist';
1483 1483
 
1484
-	$p = $f($p, '$GLOBALS["visiteur_session"]');
1484
+    $p = $f($p, '$GLOBALS["visiteur_session"]');
1485 1485
 
1486
-	return $p;
1486
+    return $p;
1487 1487
 }
1488 1488
 
1489 1489
 
@@ -1506,18 +1506,18 @@  discard block
 block discarded – undo
1506 1506
  *     Pile completée du code PHP d'exécution de la balise
1507 1507
  **/
1508 1508
 function balise_SESSION_SET_dist($p) {
1509
-	$_nom = interprete_argument_balise(1, $p);
1510
-	$_val = interprete_argument_balise(2, $p);
1511
-	if (!$_nom or !$_val) {
1512
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET'));
1513
-		erreur_squelette($err_b_s_a, $p);
1514
-	} else {
1515
-		$p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))';
1516
-	}
1509
+    $_nom = interprete_argument_balise(1, $p);
1510
+    $_val = interprete_argument_balise(2, $p);
1511
+    if (!$_nom or !$_val) {
1512
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET'));
1513
+        erreur_squelette($err_b_s_a, $p);
1514
+    } else {
1515
+        $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))';
1516
+    }
1517 1517
 
1518
-	$p->interdire_scripts = false;
1518
+    $p->interdire_scripts = false;
1519 1519
 
1520
-	return $p;
1520
+    return $p;
1521 1521
 }
1522 1522
 
1523 1523
 
@@ -1548,25 +1548,25 @@  discard block
 block discarded – undo
1548 1548
  *     Pile completée du code PHP d'exécution de la balise
1549 1549
  **/
1550 1550
 function balise_EVAL_dist($p) {
1551
-	$php = interprete_argument_balise(1, $p);
1552
-	if ($php) {
1553
-		# optimisation sur les #EVAL{une expression sans #BALISE}
1554
-		# attention au commentaire "// x signes" qui precede
1555
-		if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms",
1556
-			$php, $r)) {
1557
-			$p->code = /* $r[1]. */
1558
-				'(' . $r[2] . ')';
1559
-		} else {
1560
-			$p->code = "eval('return '.$php.';')";
1561
-		}
1562
-	} else {
1563
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL'));
1564
-		erreur_squelette($msg, $p);
1565
-	}
1551
+    $php = interprete_argument_balise(1, $p);
1552
+    if ($php) {
1553
+        # optimisation sur les #EVAL{une expression sans #BALISE}
1554
+        # attention au commentaire "// x signes" qui precede
1555
+        if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms",
1556
+            $php, $r)) {
1557
+            $p->code = /* $r[1]. */
1558
+                '(' . $r[2] . ')';
1559
+        } else {
1560
+            $p->code = "eval('return '.$php.';')";
1561
+        }
1562
+    } else {
1563
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL'));
1564
+        erreur_squelette($msg, $p);
1565
+    }
1566 1566
 
1567
-	#$p->interdire_scripts = true;
1567
+    #$p->interdire_scripts = true;
1568 1568
 
1569
-	return $p;
1569
+    return $p;
1570 1570
 }
1571 1571
 
1572 1572
 
@@ -1596,18 +1596,18 @@  discard block
 block discarded – undo
1596 1596
  **/
1597 1597
 function balise_CHAMP_SQL_dist($p) {
1598 1598
 
1599
-	if ($p->param
1600
-		and isset($p->param[0][1][0])
1601
-		and $champ = ($p->param[0][1][0]->texte)
1602
-	) {
1603
-		$p->code = champ_sql($champ, $p);
1604
-	} else {
1605
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL'));
1606
-		erreur_squelette($err_b_s_a, $p);
1607
-	}
1599
+    if ($p->param
1600
+        and isset($p->param[0][1][0])
1601
+        and $champ = ($p->param[0][1][0]->texte)
1602
+    ) {
1603
+        $p->code = champ_sql($champ, $p);
1604
+    } else {
1605
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL'));
1606
+        erreur_squelette($err_b_s_a, $p);
1607
+    }
1608 1608
 
1609
-	#$p->interdire_scripts = true;
1610
-	return $p;
1609
+    #$p->interdire_scripts = true;
1610
+    return $p;
1611 1611
 }
1612 1612
 
1613 1613
 /**
@@ -1633,13 +1633,13 @@  discard block
 block discarded – undo
1633 1633
  *     Pile complétée par le code à générer
1634 1634
  **/
1635 1635
 function balise_VAL_dist($p) {
1636
-	$p->code = interprete_argument_balise(1, $p);
1637
-	if (!strlen($p->code)) {
1638
-		$p->code = "''";
1639
-	}
1640
-	$p->interdire_scripts = false;
1636
+    $p->code = interprete_argument_balise(1, $p);
1637
+    if (!strlen($p->code)) {
1638
+        $p->code = "''";
1639
+    }
1640
+    $p->interdire_scripts = false;
1641 1641
 
1642
-	return $p;
1642
+    return $p;
1643 1643
 }
1644 1644
 
1645 1645
 /**
@@ -1668,10 +1668,10 @@  discard block
 block discarded – undo
1668 1668
  *     Pile complétée par le code à générer
1669 1669
  **/
1670 1670
 function balise_REM_dist($p) {
1671
-	$p->code = "''";
1672
-	$p->interdire_scripts = false;
1671
+    $p->code = "''";
1672
+    $p->interdire_scripts = false;
1673 1673
 
1674
-	return $p;
1674
+    return $p;
1675 1675
 }
1676 1676
 
1677 1677
 /**
@@ -1681,10 +1681,10 @@  discard block
 block discarded – undo
1681 1681
  * @return mixed
1682 1682
  */
1683 1683
 function balise_NULL_dist($p) {
1684
-	$p->code = "null";
1685
-	$p->interdire_scripts = false;
1684
+    $p->code = "null";
1685
+    $p->interdire_scripts = false;
1686 1686
 
1687
-	return $p;
1687
+    return $p;
1688 1688
 }
1689 1689
 
1690 1690
 
@@ -1708,18 +1708,18 @@  discard block
 block discarded – undo
1708 1708
  **/
1709 1709
 function balise_HTTP_HEADER_dist($p) {
1710 1710
 
1711
-	$header = interprete_argument_balise(1, $p);
1712
-	if (!$header) {
1713
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER'));
1714
-		erreur_squelette($err_b_s_a, $p);
1715
-	} else {
1716
-		$p->code = "'<'.'?php header(' . _q("
1717
-			. $header
1718
-			. ") . '); ?'.'>'";
1719
-	}
1720
-	$p->interdire_scripts = false;
1711
+    $header = interprete_argument_balise(1, $p);
1712
+    if (!$header) {
1713
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER'));
1714
+        erreur_squelette($err_b_s_a, $p);
1715
+    } else {
1716
+        $p->code = "'<'.'?php header(' . _q("
1717
+            . $header
1718
+            . ") . '); ?'.'>'";
1719
+    }
1720
+    $p->interdire_scripts = false;
1721 1721
 
1722
-	return $p;
1722
+    return $p;
1723 1723
 }
1724 1724
 
1725 1725
 
@@ -1744,20 +1744,20 @@  discard block
 block discarded – undo
1744 1744
  *     Pile complétée par le code à générer
1745 1745
  **/
1746 1746
 function balise_FILTRE_dist($p) {
1747
-	if ($p->param) {
1748
-		$args = array();
1749
-		foreach ($p->param as $i => $ignore) {
1750
-			$args[] = interprete_argument_balise($i + 1, $p);
1751
-		}
1752
-		$p->code = "'<' . '"
1753
-			. '?php header("X-Spip-Filtre: \'.'
1754
-			. join('.\'|\'.', $args)
1755
-			. " . '\"); ?'.'>'";
1747
+    if ($p->param) {
1748
+        $args = array();
1749
+        foreach ($p->param as $i => $ignore) {
1750
+            $args[] = interprete_argument_balise($i + 1, $p);
1751
+        }
1752
+        $p->code = "'<' . '"
1753
+            . '?php header("X-Spip-Filtre: \'.'
1754
+            . join('.\'|\'.', $args)
1755
+            . " . '\"); ?'.'>'";
1756 1756
 
1757
-		$p->interdire_scripts = false;
1757
+        $p->interdire_scripts = false;
1758 1758
 
1759
-		return $p;
1760
-	}
1759
+        return $p;
1760
+    }
1761 1761
 }
1762 1762
 
1763 1763
 
@@ -1793,53 +1793,53 @@  discard block
 block discarded – undo
1793 1793
  **/
1794 1794
 function balise_CACHE_dist($p) {
1795 1795
 
1796
-	if ($p->param) {
1797
-		$duree = valeur_numerique($p->param[0][1][0]->texte);
1798
-
1799
-		// noter la duree du cache dans un entete proprietaire
1800
-
1801
-		$code = "'<'.'" . '?php header("X-Spip-Cache: '
1802
-			. $duree
1803
-			. '"); ?' . "'.'>'";
1804
-
1805
-		// Remplir le header Cache-Control
1806
-		// cas #CACHE{0}
1807
-		if ($duree == 0) {
1808
-			$code .= ".'<'.'"
1809
-				. '?php header("Cache-Control: no-cache, must-revalidate"); ?'
1810
-				. "'.'><'.'"
1811
-				. '?php header("Pragma: no-cache"); ?'
1812
-				. "'.'>'";
1813
-		}
1814
-
1815
-		// recuperer les parametres suivants
1816
-		$i = 1;
1817
-		while (isset($p->param[0][++$i])) {
1818
-			$pa = ($p->param[0][$i][0]->texte);
1819
-
1820
-			if ($pa == 'cache-client'
1821
-				and $duree > 0
1822
-			) {
1823
-				$code .= ".'<'.'" . '?php header("Cache-Control: max-age='
1824
-					. $duree
1825
-					. '"); ?' . "'.'>'";
1826
-				// il semble logique, si on cache-client, de ne pas invalider
1827
-				$pa = 'statique';
1828
-			}
1829
-
1830
-			if ($pa == 'statique'
1831
-				and $duree > 0
1832
-			) {
1833
-				$code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'";
1834
-			}
1835
-		}
1836
-	} else {
1837
-		$code = "''";
1838
-	}
1839
-	$p->code = $code;
1840
-	$p->interdire_scripts = false;
1841
-
1842
-	return $p;
1796
+    if ($p->param) {
1797
+        $duree = valeur_numerique($p->param[0][1][0]->texte);
1798
+
1799
+        // noter la duree du cache dans un entete proprietaire
1800
+
1801
+        $code = "'<'.'" . '?php header("X-Spip-Cache: '
1802
+            . $duree
1803
+            . '"); ?' . "'.'>'";
1804
+
1805
+        // Remplir le header Cache-Control
1806
+        // cas #CACHE{0}
1807
+        if ($duree == 0) {
1808
+            $code .= ".'<'.'"
1809
+                . '?php header("Cache-Control: no-cache, must-revalidate"); ?'
1810
+                . "'.'><'.'"
1811
+                . '?php header("Pragma: no-cache"); ?'
1812
+                . "'.'>'";
1813
+        }
1814
+
1815
+        // recuperer les parametres suivants
1816
+        $i = 1;
1817
+        while (isset($p->param[0][++$i])) {
1818
+            $pa = ($p->param[0][$i][0]->texte);
1819
+
1820
+            if ($pa == 'cache-client'
1821
+                and $duree > 0
1822
+            ) {
1823
+                $code .= ".'<'.'" . '?php header("Cache-Control: max-age='
1824
+                    . $duree
1825
+                    . '"); ?' . "'.'>'";
1826
+                // il semble logique, si on cache-client, de ne pas invalider
1827
+                $pa = 'statique';
1828
+            }
1829
+
1830
+            if ($pa == 'statique'
1831
+                and $duree > 0
1832
+            ) {
1833
+                $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'";
1834
+            }
1835
+        }
1836
+    } else {
1837
+        $code = "''";
1838
+    }
1839
+    $p->code = $code;
1840
+    $p->interdire_scripts = false;
1841
+
1842
+    return $p;
1843 1843
 }
1844 1844
 
1845 1845
 
@@ -1871,13 +1871,13 @@  discard block
 block discarded – undo
1871 1871
  *     Pile complétée par le code à générer
1872 1872
  */
1873 1873
 function balise_INSERT_HEAD_dist($p) {
1874
-	$p->code = "'<'.'"
1875
-		. '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?'
1876
-		. "'.'>'";
1877
-	$p->code .= ". pipeline('insert_head','<!-- insert_head -->')";
1878
-	$p->interdire_scripts = false;
1874
+    $p->code = "'<'.'"
1875
+        . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?'
1876
+        . "'.'>'";
1877
+    $p->code .= ". pipeline('insert_head','<!-- insert_head -->')";
1878
+    $p->interdire_scripts = false;
1879 1879
 
1880
-	return $p;
1880
+    return $p;
1881 1881
 }
1882 1882
 
1883 1883
 /**
@@ -1895,10 +1895,10 @@  discard block
 block discarded – undo
1895 1895
  *     Pile complétée par le code à générer
1896 1896
  */
1897 1897
 function balise_INSERT_HEAD_CSS_dist($p) {
1898
-	$p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')";
1899
-	$p->interdire_scripts = false;
1898
+    $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')";
1899
+    $p->interdire_scripts = false;
1900 1900
 
1901
-	return $p;
1901
+    return $p;
1902 1902
 }
1903 1903
 
1904 1904
 /**
@@ -1913,11 +1913,11 @@  discard block
 block discarded – undo
1913 1913
  *     Pile complétée par le code à générer
1914 1914
  **/
1915 1915
 function balise_INCLUDE_dist($p) {
1916
-	if (function_exists('balise_INCLURE')) {
1917
-		return balise_INCLURE($p);
1918
-	} else {
1919
-		return balise_INCLURE_dist($p);
1920
-	}
1916
+    if (function_exists('balise_INCLURE')) {
1917
+        return balise_INCLURE($p);
1918
+    } else {
1919
+        return balise_INCLURE_dist($p);
1920
+    }
1921 1921
 }
1922 1922
 
1923 1923
 /**
@@ -1951,68 +1951,68 @@  discard block
 block discarded – undo
1951 1951
  *     Pile complétée par le code à générer
1952 1952
  **/
1953 1953
 function balise_INCLURE_dist($p) {
1954
-	$id_boucle = $p->id_boucle;
1955
-	// la lang n'est pas passe de facon automatique par argumenter
1956
-	// mais le sera pas recuperer_fond, sauf si etoile=>true est passe
1957
-	// en option
1958
-
1959
-	$_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false);
1960
-
1961
-	// erreur de syntaxe = fond absent
1962
-	// (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
1963
-	if (!$_contexte) {
1964
-		$contexte = array();
1965
-	}
1966
-
1967
-	if (isset($_contexte['fond'])) {
1968
-
1969
-		$f = $_contexte['fond'];
1970
-		// toujours vrai :
1971
-		if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) {
1972
-			$f = $r[1];
1973
-			unset($_contexte['fond']);
1974
-		} else {
1975
-			spip_log("compilation de #INCLURE a revoir");
1976
-		}
1977
-
1978
-		// #INCLURE{doublons}
1979
-		if (isset($_contexte['doublons'])) {
1980
-			$_contexte['doublons'] = "'doublons' => \$doublons";
1981
-		}
1982
-
1983
-		// Critere d'inclusion {env} (et {self} pour compatibilite ascendante)
1984
-		$flag_env = false;
1985
-		if (isset($_contexte['env']) or isset($_contexte['self'])) {
1986
-			$flag_env = true;
1987
-			unset($_contexte['env']);
1988
-		}
1989
-
1990
-		$_options = array();
1991
-		if (isset($_contexte['ajax'])) {
1992
-			$_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
1993
-			unset($_contexte['ajax']);
1994
-		}
1995
-		if ($p->etoile) {
1996
-			$_options[] = "'etoile'=>true";
1997
-		}
1998
-		$_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")";
1999
-
2000
-		$_l = 'array(' . join(",\n\t", $_contexte) . ')';
2001
-		if ($flag_env) {
2002
-			$_l = "array_merge(\$Pile[0],$_l)";
2003
-		}
2004
-
2005
-		$p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect')");
2006
-
2007
-	} elseif (!isset($_contexte[1])) {
2008
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE'));
2009
-		erreur_squelette($msg, $p);
2010
-	} else {
2011
-		$p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
2012
-	}
2013
-
2014
-	$p->interdire_scripts = false; // la securite est assuree par recuperer_fond
2015
-	return $p;
1954
+    $id_boucle = $p->id_boucle;
1955
+    // la lang n'est pas passe de facon automatique par argumenter
1956
+    // mais le sera pas recuperer_fond, sauf si etoile=>true est passe
1957
+    // en option
1958
+
1959
+    $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false);
1960
+
1961
+    // erreur de syntaxe = fond absent
1962
+    // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
1963
+    if (!$_contexte) {
1964
+        $contexte = array();
1965
+    }
1966
+
1967
+    if (isset($_contexte['fond'])) {
1968
+
1969
+        $f = $_contexte['fond'];
1970
+        // toujours vrai :
1971
+        if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) {
1972
+            $f = $r[1];
1973
+            unset($_contexte['fond']);
1974
+        } else {
1975
+            spip_log("compilation de #INCLURE a revoir");
1976
+        }
1977
+
1978
+        // #INCLURE{doublons}
1979
+        if (isset($_contexte['doublons'])) {
1980
+            $_contexte['doublons'] = "'doublons' => \$doublons";
1981
+        }
1982
+
1983
+        // Critere d'inclusion {env} (et {self} pour compatibilite ascendante)
1984
+        $flag_env = false;
1985
+        if (isset($_contexte['env']) or isset($_contexte['self'])) {
1986
+            $flag_env = true;
1987
+            unset($_contexte['env']);
1988
+        }
1989
+
1990
+        $_options = array();
1991
+        if (isset($_contexte['ajax'])) {
1992
+            $_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
1993
+            unset($_contexte['ajax']);
1994
+        }
1995
+        if ($p->etoile) {
1996
+            $_options[] = "'etoile'=>true";
1997
+        }
1998
+        $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")";
1999
+
2000
+        $_l = 'array(' . join(",\n\t", $_contexte) . ')';
2001
+        if ($flag_env) {
2002
+            $_l = "array_merge(\$Pile[0],$_l)";
2003
+        }
2004
+
2005
+        $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect')");
2006
+
2007
+    } elseif (!isset($_contexte[1])) {
2008
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE'));
2009
+        erreur_squelette($msg, $p);
2010
+    } else {
2011
+        $p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
2012
+    }
2013
+
2014
+    $p->interdire_scripts = false; // la securite est assuree par recuperer_fond
2015
+    return $p;
2016 2016
 }
2017 2017
 
2018 2018
 
@@ -2040,69 +2040,69 @@  discard block
 block discarded – undo
2040 2040
  **/
2041 2041
 function balise_MODELE_dist($p) {
2042 2042
 
2043
-	$_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false);
2044
-
2045
-	// erreur de syntaxe = fond absent
2046
-	// (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
2047
-	if (!$_contexte) {
2048
-		$_contexte = array();
2049
-	}
2050
-
2051
-	if (!isset($_contexte[1])) {
2052
-		$msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE'));
2053
-		erreur_squelette($msg, $p);
2054
-	} else {
2055
-		$nom = $_contexte[1];
2056
-		unset($_contexte[1]);
2057
-
2058
-		if (preg_match("/^\s*'[^']*'/s", $nom)) {
2059
-			$nom = "'modeles/" . substr($nom, 1);
2060
-		} else {
2061
-			$nom = "'modeles/' . $nom";
2062
-		}
2063
-
2064
-		$flag_env = false;
2065
-		if (isset($_contexte['env'])) {
2066
-			$flag_env = true;
2067
-			unset($_contexte['env']);
2068
-		}
2069
-
2070
-		// Incoherence dans la syntaxe du contexte. A revoir.
2071
-		// Reserver la cle primaire de la boucle courante si elle existe
2072
-		if (isset($p->boucles[$p->id_boucle]->primary)) {
2073
-			$primary = $p->boucles[$p->id_boucle]->primary;
2074
-			if (!strpos($primary, ',')) {
2075
-				$id = champ_sql($primary, $p);
2076
-				$_contexte[] = "'$primary'=>" . $id;
2077
-				$_contexte[] = "'id'=>" . $id;
2078
-			}
2079
-		}
2080
-		$_contexte[] = "'recurs'=>(++\$recurs)";
2081
-		$connect = '';
2082
-		if (isset($p->boucles[$p->id_boucle])) {
2083
-			$connect = $p->boucles[$p->id_boucle]->sql_serveur;
2084
-		}
2085
-
2086
-		$_options = memoriser_contexte_compil($p);
2087
-		$_options = "'compil'=>array($_options), 'trim'=>true";
2088
-		if (isset($_contexte['ajax'])) {
2089
-			$_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2090
-			unset($_contexte['ajax']);
2091
-		}
2092
-
2093
-		$_l = 'array(' . join(",\n\t", $_contexte) . ')';
2094
-		if ($flag_env) {
2095
-			$_l = "array_merge(\$Pile[0],$_l)";
2096
-		}
2097
-
2098
-		$page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect));
2099
-
2100
-		$p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n";
2101
-
2102
-		$p->interdire_scripts = false; // securite assuree par le squelette
2103
-	}
2104
-
2105
-	return $p;
2043
+    $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false);
2044
+
2045
+    // erreur de syntaxe = fond absent
2046
+    // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP
2047
+    if (!$_contexte) {
2048
+        $_contexte = array();
2049
+    }
2050
+
2051
+    if (!isset($_contexte[1])) {
2052
+        $msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE'));
2053
+        erreur_squelette($msg, $p);
2054
+    } else {
2055
+        $nom = $_contexte[1];
2056
+        unset($_contexte[1]);
2057
+
2058
+        if (preg_match("/^\s*'[^']*'/s", $nom)) {
2059
+            $nom = "'modeles/" . substr($nom, 1);
2060
+        } else {
2061
+            $nom = "'modeles/' . $nom";
2062
+        }
2063
+
2064
+        $flag_env = false;
2065
+        if (isset($_contexte['env'])) {
2066
+            $flag_env = true;
2067
+            unset($_contexte['env']);
2068
+        }
2069
+
2070
+        // Incoherence dans la syntaxe du contexte. A revoir.
2071
+        // Reserver la cle primaire de la boucle courante si elle existe
2072
+        if (isset($p->boucles[$p->id_boucle]->primary)) {
2073
+            $primary = $p->boucles[$p->id_boucle]->primary;
2074
+            if (!strpos($primary, ',')) {
2075
+                $id = champ_sql($primary, $p);
2076
+                $_contexte[] = "'$primary'=>" . $id;
2077
+                $_contexte[] = "'id'=>" . $id;
2078
+            }
2079
+        }
2080
+        $_contexte[] = "'recurs'=>(++\$recurs)";
2081
+        $connect = '';
2082
+        if (isset($p->boucles[$p->id_boucle])) {
2083
+            $connect = $p->boucles[$p->id_boucle]->sql_serveur;
2084
+        }
2085
+
2086
+        $_options = memoriser_contexte_compil($p);
2087
+        $_options = "'compil'=>array($_options), 'trim'=>true";
2088
+        if (isset($_contexte['ajax'])) {
2089
+            $_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2090
+            unset($_contexte['ajax']);
2091
+        }
2092
+
2093
+        $_l = 'array(' . join(",\n\t", $_contexte) . ')';
2094
+        if ($flag_env) {
2095
+            $_l = "array_merge(\$Pile[0],$_l)";
2096
+        }
2097
+
2098
+        $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect));
2099
+
2100
+        $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n";
2101
+
2102
+        $p->interdire_scripts = false; // securite assuree par le squelette
2103
+    }
2104
+
2105
+    return $p;
2106 2106
 }
2107 2107
 
2108 2108
 
@@ -2126,21 +2126,21 @@  discard block
 block discarded – undo
2126 2126
  *     Pile complétée par le code à générer
2127 2127
  **/
2128 2128
 function balise_SET_dist($p) {
2129
-	$_nom = interprete_argument_balise(1, $p);
2130
-	$_val = interprete_argument_balise(2, $p);
2129
+    $_nom = interprete_argument_balise(1, $p);
2130
+    $_val = interprete_argument_balise(2, $p);
2131 2131
 
2132
-	if (!$_nom or !$_val) {
2133
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET'));
2134
-		erreur_squelette($err_b_s_a, $p);
2135
-	}
2136
-	// affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4
2137
-	// cf https://bugs.php.net/bug.php?id=65845
2138
-	else {
2139
-		$p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)";
2140
-	}
2132
+    if (!$_nom or !$_val) {
2133
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET'));
2134
+        erreur_squelette($err_b_s_a, $p);
2135
+    }
2136
+    // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4
2137
+    // cf https://bugs.php.net/bug.php?id=65845
2138
+    else {
2139
+        $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)";
2140
+    }
2141 2141
 
2142
-	$p->interdire_scripts = false; // la balise ne renvoie rien
2143
-	return $p;
2142
+    $p->interdire_scripts = false; // la balise ne renvoie rien
2143
+    return $p;
2144 2144
 }
2145 2145
 
2146 2146
 
@@ -2170,12 +2170,12 @@  discard block
 block discarded – undo
2170 2170
  *     Pile complétée par le code à générer
2171 2171
  **/
2172 2172
 function balise_GET_dist($p) {
2173
-	$p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance
2174
-	if (function_exists('balise_ENV')) {
2175
-		return balise_ENV($p, '$Pile["vars"]');
2176
-	} else {
2177
-		return balise_ENV_dist($p, '$Pile["vars"]');
2178
-	}
2173
+    $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance
2174
+    if (function_exists('balise_ENV')) {
2175
+        return balise_ENV($p, '$Pile["vars"]');
2176
+    } else {
2177
+        return balise_ENV_dist($p, '$Pile["vars"]');
2178
+    }
2179 2179
 }
2180 2180
 
2181 2181
 
@@ -2198,22 +2198,22 @@  discard block
 block discarded – undo
2198 2198
  *     Pile complétée par le code à générer
2199 2199
  **/
2200 2200
 function balise_DOUBLONS_dist($p) {
2201
-	if ($type = interprete_argument_balise(1, $p)) {
2202
-		if ($famille = interprete_argument_balise(2, $p)) {
2203
-			$type .= '.' . $famille;
2204
-		}
2205
-		$p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';
2206
-		if (!$p->etoile) {
2207
-			$p->code = 'array_filter(array_map("intval",explode(",",'
2208
-				. $p->code . ')))';
2209
-		}
2210
-	} else {
2211
-		$p->code = '$doublons';
2212
-	}
2201
+    if ($type = interprete_argument_balise(1, $p)) {
2202
+        if ($famille = interprete_argument_balise(2, $p)) {
2203
+            $type .= '.' . $famille;
2204
+        }
2205
+        $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';
2206
+        if (!$p->etoile) {
2207
+            $p->code = 'array_filter(array_map("intval",explode(",",'
2208
+                . $p->code . ')))';
2209
+        }
2210
+    } else {
2211
+        $p->code = '$doublons';
2212
+    }
2213 2213
 
2214
-	$p->interdire_scripts = false;
2214
+    $p->interdire_scripts = false;
2215 2215
 
2216
-	return $p;
2216
+    return $p;
2217 2217
 }
2218 2218
 
2219 2219
 
@@ -2236,18 +2236,18 @@  discard block
 block discarded – undo
2236 2236
  *     Pile complétée par le code à générer
2237 2237
  **/
2238 2238
 function balise_PIPELINE_dist($p) {
2239
-	$_pipe = interprete_argument_balise(1, $p);
2240
-	if (!$_pipe) {
2241
-		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE'));
2242
-		erreur_squelette($err_b_s_a, $p);
2243
-	} else {
2244
-		$_flux = interprete_argument_balise(2, $p);
2245
-		$_flux = $_flux ? $_flux : "''";
2246
-		$p->code = "pipeline( $_pipe , $_flux )";
2247
-		$p->interdire_scripts = false;
2248
-	}
2239
+    $_pipe = interprete_argument_balise(1, $p);
2240
+    if (!$_pipe) {
2241
+        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE'));
2242
+        erreur_squelette($err_b_s_a, $p);
2243
+    } else {
2244
+        $_flux = interprete_argument_balise(2, $p);
2245
+        $_flux = $_flux ? $_flux : "''";
2246
+        $p->code = "pipeline( $_pipe , $_flux )";
2247
+        $p->interdire_scripts = false;
2248
+    }
2249 2249
 
2250
-	return $p;
2250
+    return $p;
2251 2251
 }
2252 2252
 
2253 2253
 
@@ -2272,10 +2272,10 @@  discard block
 block discarded – undo
2272 2272
  *     Pile complétée par le code à générer
2273 2273
  **/
2274 2274
 function balise_EDIT_dist($p) {
2275
-	$p->code = "''";
2276
-	$p->interdire_scripts = false;
2275
+    $p->code = "''";
2276
+    $p->interdire_scripts = false;
2277 2277
 
2278
-	return $p;
2278
+    return $p;
2279 2279
 }
2280 2280
 
2281 2281
 
@@ -2298,11 +2298,11 @@  discard block
 block discarded – undo
2298 2298
  *     Pile complétée par le code à générer
2299 2299
  **/
2300 2300
 function balise_TOTAL_UNIQUE_dist($p) {
2301
-	$_famille = interprete_argument_balise(1, $p);
2302
-	$_famille = $_famille ? $_famille : "''";
2303
-	$p->code = "unique('', $_famille, true)";
2301
+    $_famille = interprete_argument_balise(1, $p);
2302
+    $_famille = $_famille ? $_famille : "''";
2303
+    $p->code = "unique('', $_famille, true)";
2304 2304
 
2305
-	return $p;
2305
+    return $p;
2306 2306
 }
2307 2307
 
2308 2308
 /**
@@ -2325,19 +2325,19 @@  discard block
 block discarded – undo
2325 2325
  *     Pile complétée par le code à générer
2326 2326
  **/
2327 2327
 function balise_ARRAY_dist($p) {
2328
-	$_code = array();
2329
-	$n = 1;
2330
-	do {
2331
-		$_key = interprete_argument_balise($n++, $p);
2332
-		$_val = interprete_argument_balise($n++, $p);
2333
-		if ($_key and $_val) {
2334
-			$_code[] = "$_key => $_val";
2335
-		}
2336
-	} while ($_key && $_val);
2337
-	$p->code = 'array(' . join(', ', $_code) . ')';
2338
-	$p->interdire_scripts = false;
2328
+    $_code = array();
2329
+    $n = 1;
2330
+    do {
2331
+        $_key = interprete_argument_balise($n++, $p);
2332
+        $_val = interprete_argument_balise($n++, $p);
2333
+        if ($_key and $_val) {
2334
+            $_code[] = "$_key => $_val";
2335
+        }
2336
+    } while ($_key && $_val);
2337
+    $p->code = 'array(' . join(', ', $_code) . ')';
2338
+    $p->interdire_scripts = false;
2339 2339
 
2340
-	return $p;
2340
+    return $p;
2341 2341
 }
2342 2342
 
2343 2343
 /**
@@ -2356,15 +2356,15 @@  discard block
 block discarded – undo
2356 2356
  *     Pile complétée par le code à générer
2357 2357
  */
2358 2358
 function balise_LISTE_dist($p) {
2359
-	$_code = array();
2360
-	$n = 1;
2361
-	while ($_val = interprete_argument_balise($n++, $p)) {
2362
-		$_code[] = $_val;
2363
-	}
2364
-	$p->code = 'array(' . join(', ', $_code) . ')';
2365
-	$p->interdire_scripts = false;
2359
+    $_code = array();
2360
+    $n = 1;
2361
+    while ($_val = interprete_argument_balise($n++, $p)) {
2362
+        $_code[] = $_val;
2363
+    }
2364
+    $p->code = 'array(' . join(', ', $_code) . ')';
2365
+    $p->interdire_scripts = false;
2366 2366
 
2367
-	return $p;
2367
+    return $p;
2368 2368
 }
2369 2369
 
2370 2370
 
@@ -2398,19 +2398,19 @@  discard block
 block discarded – undo
2398 2398
  *     Pile complétée par le code à générer
2399 2399
  **/
2400 2400
 function balise_AUTORISER_dist($p) {
2401
-	$_code = array();
2402
-	$p->descr['session'] = true; // faire un cache par session
2401
+    $_code = array();
2402
+    $p->descr['session'] = true; // faire un cache par session
2403 2403
 
2404
-	$n = 1;
2405
-	while ($_v = interprete_argument_balise($n++, $p)) {
2406
-		$_code[] = $_v;
2407
-	}
2404
+    $n = 1;
2405
+    while ($_v = interprete_argument_balise($n++, $p)) {
2406
+        $_code[] = $_v;
2407
+    }
2408 2408
 
2409
-	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',
2410
-			$_code) . ')?" ":"")';
2411
-	$p->interdire_scripts = false;
2409
+    $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',
2410
+            $_code) . ')?" ":"")';
2411
+    $p->interdire_scripts = false;
2412 2412
 
2413
-	return $p;
2413
+    return $p;
2414 2414
 }
2415 2415
 
2416 2416
 
@@ -2434,15 +2434,15 @@  discard block
 block discarded – undo
2434 2434
  *     Pile complétée par le code à générer
2435 2435
  **/
2436 2436
 function balise_PLUGIN_dist($p) {
2437
-	$plugin = interprete_argument_balise(1, $p);
2438
-	$plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""';
2439
-	$type_info = interprete_argument_balise(2, $p);
2440
-	$type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"';
2437
+    $plugin = interprete_argument_balise(1, $p);
2438
+    $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""';
2439
+    $type_info = interprete_argument_balise(2, $p);
2440
+    $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"';
2441 2441
 
2442
-	$f = chercher_filtre('info_plugin');
2443
-	$p->code = $f . '(' . $plugin . ', ' . $type_info . ')';
2442
+    $f = chercher_filtre('info_plugin');
2443
+    $p->code = $f . '(' . $plugin . ', ' . $type_info . ')';
2444 2444
 
2445
-	return $p;
2445
+    return $p;
2446 2446
 }
2447 2447
 
2448 2448
 /**
@@ -2463,9 +2463,9 @@  discard block
 block discarded – undo
2463 2463
  *     Pile complétée par le code à générer
2464 2464
  **/
2465 2465
 function balise_AIDER_dist($p) {
2466
-	$_motif = interprete_argument_balise(1, $p);
2467
-	$p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')";
2468
-	return $p;
2466
+    $_motif = interprete_argument_balise(1, $p);
2467
+    $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')";
2468
+    return $p;
2469 2469
 }
2470 2470
 
2471 2471
 /**
@@ -2491,16 +2491,16 @@  discard block
 block discarded – undo
2491 2491
  *     Pile complétée par le code à générer
2492 2492
  **/
2493 2493
 function balise_ACTION_FORMULAIRE($p) {
2494
-	if (!$_url = interprete_argument_balise(1, $p)) {
2495
-		$_url = "@\$Pile[0]['action']";
2496
-	}
2497
-	if (!$_form = interprete_argument_balise(2, $p)) {
2498
-		$_form = "@\$Pile[0]['form']";
2499
-	}
2500
-
2501
-	// envoyer le nom du formulaire que l'on traite
2502
-	// transmettre les eventuels args de la balise formulaire
2503
-	$p->code = "	'<span class=\"form-hidden\">' .
2494
+    if (!$_url = interprete_argument_balise(1, $p)) {
2495
+        $_url = "@\$Pile[0]['action']";
2496
+    }
2497
+    if (!$_form = interprete_argument_balise(2, $p)) {
2498
+        $_form = "@\$Pile[0]['form']";
2499
+    }
2500
+
2501
+    // envoyer le nom du formulaire que l'on traite
2502
+    // transmettre les eventuels args de la balise formulaire
2503
+    $p->code = "	'<span class=\"form-hidden\">' .
2504 2504
 	form_hidden($_url) .
2505 2505
 	'<input name=\'formulaire_action\' type=\'hidden\'
2506 2506
 		value=\'' . $_form . '\' />' .
@@ -2509,9 +2509,9 @@  discard block
 block discarded – undo
2509 2509
 	(!empty(\$Pile[0]['_hidden']) ? @\$Pile[0]['_hidden'] : '') .
2510 2510
 	'</span>'";
2511 2511
 
2512
-	$p->interdire_scripts = false;
2512
+    $p->interdire_scripts = false;
2513 2513
 
2514
-	return $p;
2514
+    return $p;
2515 2515
 }
2516 2516
 
2517 2517
 
@@ -2552,25 +2552,25 @@  discard block
 block discarded – undo
2552 2552
  */
2553 2553
 function balise_BOUTON_ACTION_dist($p) {
2554 2554
 
2555
-	$args = array();
2556
-	for ($k = 1; $k <= 6; $k++) {
2557
-		$_a = interprete_argument_balise($k, $p);
2558
-		if (!$_a) {
2559
-			$_a = "''";
2560
-		}
2561
-		$args[] = $_a;
2562
-	}
2563
-	// supprimer les args vides
2564
-	while (end($args) == "''" and count($args) > 2) {
2565
-		array_pop($args);
2566
-	}
2567
-	$args = implode(",", $args);
2555
+    $args = array();
2556
+    for ($k = 1; $k <= 6; $k++) {
2557
+        $_a = interprete_argument_balise($k, $p);
2558
+        if (!$_a) {
2559
+            $_a = "''";
2560
+        }
2561
+        $args[] = $_a;
2562
+    }
2563
+    // supprimer les args vides
2564
+    while (end($args) == "''" and count($args) > 2) {
2565
+        array_pop($args);
2566
+    }
2567
+    $args = implode(",", $args);
2568 2568
 
2569
-	$bouton_action = chercher_filtre("bouton_action");
2570
-	$p->code = "$bouton_action($args)";
2571
-	$p->interdire_scripts = false;
2569
+    $bouton_action = chercher_filtre("bouton_action");
2570
+    $p->code = "$bouton_action($args)";
2571
+    $p->interdire_scripts = false;
2572 2572
 
2573
-	return $p;
2573
+    return $p;
2574 2574
 }
2575 2575
 
2576 2576
 
@@ -2589,10 +2589,10 @@  discard block
 block discarded – undo
2589 2589
  *     Pile complétée par le code à générer
2590 2590
  */
2591 2591
 function balise_SLOGAN_SITE_SPIP_dist($p) {
2592
-	$p->code = "\$GLOBALS['meta']['slogan_site']";
2592
+    $p->code = "\$GLOBALS['meta']['slogan_site']";
2593 2593
 
2594
-	#$p->interdire_scripts = true;
2595
-	return $p;
2594
+    #$p->interdire_scripts = true;
2595
+    return $p;
2596 2596
 }
2597 2597
 
2598 2598
 
@@ -2616,10 +2616,10 @@  discard block
 block discarded – undo
2616 2616
  *     Pile complétée par le code à générer
2617 2617
  */
2618 2618
 function balise_HTML5_dist($p) {
2619
-	$p->code = html5_permis() ? "' '" : "''";
2620
-	$p->interdire_scripts = false;
2619
+    $p->code = html5_permis() ? "' '" : "''";
2620
+    $p->interdire_scripts = false;
2621 2621
 
2622
-	return $p;
2622
+    return $p;
2623 2623
 }
2624 2624
 
2625 2625
 
@@ -2645,61 +2645,61 @@  discard block
 block discarded – undo
2645 2645
  *     Pile complétée par le code à générer
2646 2646
  */
2647 2647
 function balise_TRI_dist($p, $liste = 'true') {
2648
-	$b = index_boucle_mere($p);
2649
-	// s'il n'y a pas de nom de boucle, on ne peut pas trier
2650
-	if ($b === '') {
2651
-		$msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
2652
-		erreur_squelette($msg, $p);
2653
-		$p->code = "''";
2648
+    $b = index_boucle_mere($p);
2649
+    // s'il n'y a pas de nom de boucle, on ne peut pas trier
2650
+    if ($b === '') {
2651
+        $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p)));
2652
+        erreur_squelette($msg, $p);
2653
+        $p->code = "''";
2654 2654
 
2655
-		return $p;
2656
-	}
2657
-	$boucle = $p->boucles[$b];
2655
+        return $p;
2656
+    }
2657
+    $boucle = $p->boucles[$b];
2658 2658
 
2659
-	// s'il n'y a pas de tri_champ, c'est qu'on se trouve
2660
-	// dans un boucle recursive ou qu'on a oublie le critere {tri}
2661
-	if (!isset($boucle->modificateur['tri_champ'])) {
2662
-		$msg = array('zbug_champ_hors_critere', array(
2663
-			'champ' => zbug_presenter_champ($p),
2664
-			'critere' => 'tri'
2665
-		));
2666
-		erreur_squelette($msg, $p);
2667
-		$p->code = "''";
2659
+    // s'il n'y a pas de tri_champ, c'est qu'on se trouve
2660
+    // dans un boucle recursive ou qu'on a oublie le critere {tri}
2661
+    if (!isset($boucle->modificateur['tri_champ'])) {
2662
+        $msg = array('zbug_champ_hors_critere', array(
2663
+            'champ' => zbug_presenter_champ($p),
2664
+            'critere' => 'tri'
2665
+        ));
2666
+        erreur_squelette($msg, $p);
2667
+        $p->code = "''";
2668 2668
 
2669
-		return $p;
2670
-	}
2669
+        return $p;
2670
+    }
2671 2671
 
2672
-	$_champ = interprete_argument_balise(1, $p);
2673
-	// si pas de champ, renvoyer le critere de tri utilise
2674
-	if (!$_champ) {
2675
-		$p->code = $boucle->modificateur['tri_champ'];
2672
+    $_champ = interprete_argument_balise(1, $p);
2673
+    // si pas de champ, renvoyer le critere de tri utilise
2674
+    if (!$_champ) {
2675
+        $p->code = $boucle->modificateur['tri_champ'];
2676 2676
 
2677
-		return $p;
2678
-	}
2679
-	// forcer la jointure si besoin, et si le champ est statique
2680
-	if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) {
2681
-		index_pile($b, $m[1], $p->boucles, '', null, true, false);
2682
-	}
2677
+        return $p;
2678
+    }
2679
+    // forcer la jointure si besoin, et si le champ est statique
2680
+    if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) {
2681
+        index_pile($b, $m[1], $p->boucles, '', null, true, false);
2682
+    }
2683 2683
 
2684
-	$_libelle = interprete_argument_balise(2, $p);
2685
-	$_libelle = $_libelle ? $_libelle : $_champ;
2684
+    $_libelle = interprete_argument_balise(2, $p);
2685
+    $_libelle = $_libelle ? $_libelle : $_champ;
2686 2686
 
2687
-	$_class = interprete_argument_balise(3, $p);
2688
-	// si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1
2689
-	// si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1
2690
-	$_issens = "in_array($_champ,array('>','<'))";
2691
-	$_sens = "(strpos('< >',$_champ)-1)";
2687
+    $_class = interprete_argument_balise(3, $p);
2688
+    // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1
2689
+    // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1
2690
+    $_issens = "in_array($_champ,array('>','<'))";
2691
+    $_sens = "(strpos('< >',$_champ)-1)";
2692 2692
 
2693
-	$_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];
2694
-	$_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";
2695
-	$_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')";
2696
-	$_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)";
2693
+    $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];
2694
+    $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";
2695
+    $_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')";
2696
+    $_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)";
2697 2697
 
2698
-	$p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";
2699
-	//$p->code = "''";
2700
-	$p->interdire_scripts = false;
2698
+    $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";
2699
+    //$p->code = "''";
2700
+    $p->interdire_scripts = false;
2701 2701
 
2702
-	return $p;
2702
+    return $p;
2703 2703
 }
2704 2704
 
2705 2705
 
@@ -2720,22 +2720,22 @@  discard block
 block discarded – undo
2720 2720
  *     Pile complétée par le code à générer
2721 2721
  */
2722 2722
 function balise_SAUTER_dist($p) {
2723
-	$id_boucle = $p->id_boucle;
2723
+    $id_boucle = $p->id_boucle;
2724 2724
 
2725
-	if (empty($p->boucles[$id_boucle])) {
2726
-		$msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER'));
2727
-		erreur_squelette($msg, $p);
2728
-	} else {
2729
-		$boucle = $p->boucles[$id_boucle];
2730
-		$_saut = interprete_argument_balise(1, $p);
2731
-		$_compteur = "\$Numrows['$id_boucle']['compteur_boucle']";
2732
-		$_total = "\$Numrows['$id_boucle']['total']";
2725
+    if (empty($p->boucles[$id_boucle])) {
2726
+        $msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER'));
2727
+        erreur_squelette($msg, $p);
2728
+    } else {
2729
+        $boucle = $p->boucles[$id_boucle];
2730
+        $_saut = interprete_argument_balise(1, $p);
2731
+        $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']";
2732
+        $_total = "\$Numrows['$id_boucle']['total']";
2733 2733
 
2734
-		$p->code = "vide($_compteur=\$iter->skip($_saut,$_total))";
2735
-	}
2736
-	$p->interdire_scripts = false;
2734
+        $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))";
2735
+    }
2736
+    $p->interdire_scripts = false;
2737 2737
 
2738
-	return $p;
2738
+    return $p;
2739 2739
 }
2740 2740
 
2741 2741
 
@@ -2757,22 +2757,22 @@  discard block
 block discarded – undo
2757 2757
  *     Pile complétée par le code à générer
2758 2758
  */
2759 2759
 function balise_PUBLIE_dist($p) {
2760
-	if (!$_type = interprete_argument_balise(1, $p)) {
2761
-		$_type = _q($p->type_requete);
2762
-		$_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p);
2763
-	} else {
2764
-		$_id = interprete_argument_balise(2, $p);
2765
-	}
2760
+    if (!$_type = interprete_argument_balise(1, $p)) {
2761
+        $_type = _q($p->type_requete);
2762
+        $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p);
2763
+    } else {
2764
+        $_id = interprete_argument_balise(2, $p);
2765
+    }
2766 2766
 
2767
-	$connect = '';
2768
-	if (isset($p->boucles[$p->id_boucle])) {
2769
-		$connect = $p->boucles[$p->id_boucle]->sql_serveur;
2770
-	}
2767
+    $connect = '';
2768
+    if (isset($p->boucles[$p->id_boucle])) {
2769
+        $connect = $p->boucles[$p->id_boucle]->sql_serveur;
2770
+    }
2771 2771
 
2772
-	$p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')";
2773
-	$p->interdire_scripts = false;
2772
+    $p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')";
2773
+    $p->interdire_scripts = false;
2774 2774
 
2775
-	return $p;
2775
+    return $p;
2776 2776
 }
2777 2777
 
2778 2778
 /**
@@ -2801,12 +2801,12 @@  discard block
 block discarded – undo
2801 2801
  *     Pile complétée par le code à générer
2802 2802
  */
2803 2803
 function balise_PRODUIRE_dist($p) {
2804
-	$balise_inclure = charger_fonction('INCLURE', 'balise');
2805
-	$p = $balise_inclure($p);
2804
+    $balise_inclure = charger_fonction('INCLURE', 'balise');
2805
+    $p = $balise_inclure($p);
2806 2806
 
2807
-	$p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code);
2807
+    $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code);
2808 2808
 
2809
-	return $p;
2809
+    return $p;
2810 2810
 }
2811 2811
 
2812 2812
 /**
@@ -2825,13 +2825,13 @@  discard block
 block discarded – undo
2825 2825
  *     Pile complétée par le code à générer
2826 2826
  */
2827 2827
 function balise_LARGEUR_ECRAN_dist($p) {
2828
-	$_class = interprete_argument_balise(1, $p);
2829
-	if (!$_class) {
2830
-		$_class = 'null';
2831
-	}
2832
-	$p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))";
2828
+    $_class = interprete_argument_balise(1, $p);
2829
+    if (!$_class) {
2830
+        $_class = 'null';
2831
+    }
2832
+    $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))";
2833 2833
 
2834
-	return $p;
2834
+    return $p;
2835 2835
 }
2836 2836
 
2837 2837
 
@@ -2847,14 +2847,14 @@  discard block
 block discarded – undo
2847 2847
  *     Pile complétée par le code à générer
2848 2848
  **/
2849 2849
 function balise_CONST_dist($p) {
2850
-	$_const = interprete_argument_balise(1, $p);
2851
-	if (!strlen($_const)) {
2852
-		$p->code = "''";
2853
-	}
2854
-	else {
2855
-		$p->code = "(defined($_const)?constant($_const):'')";
2856
-	}
2857
-	$p->interdire_scripts = false;
2858
-
2859
-	return $p;
2850
+    $_const = interprete_argument_balise(1, $p);
2851
+    if (!strlen($_const)) {
2852
+        $p->code = "''";
2853
+    }
2854
+    else {
2855
+        $p->code = "(defined($_const)?constant($_const):'')";
2856
+    }
2857
+    $p->interdire_scripts = false;
2858
+
2859
+    return $p;
2860 2860
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
  */
363 363
 function balise_DOSSIER_SQUELETTE_dist($p) {
364 364
 	$code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));
365
-	$p->code = "_DIR_RACINE . '$code'" .
365
+	$p->code = "_DIR_RACINE . '$code'".
366 366
 		$p->interdire_scripts = false;
367 367
 
368 368
 	return $p;
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
  */
382 382
 function balise_SQUELETTE_dist($p) {
383 383
 	$code = addslashes($p->descr['sourcefile']);
384
-	$p->code = "'$code'" .
384
+	$p->code = "'$code'".
385 385
 		$p->interdire_scripts = false;
386 386
 
387 387
 	return $p;
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
  **/
434 434
 function balise_NOM_SITE_dist($p) {
435 435
 	if (!$p->etoile) {
436
-		$p->code = "supprimer_numero(calculer_url(" .
437
-			champ_sql('url_site', $p) . "," .
438
-			champ_sql('nom_site', $p) .
436
+		$p->code = "supprimer_numero(calculer_url(".
437
+			champ_sql('url_site', $p).",".
438
+			champ_sql('nom_site', $p).
439 439
 			", 'titre', \$connect, false))";
440 440
 	} else {
441 441
 		$p->code = champ_sql('nom_site', $p);
@@ -586,8 +586,8 @@  discard block
 block discarded – undo
586 586
  *     Pile complétée par le code à générer
587 587
  **/
588 588
 function balise_POPULARITE_ABSOLUE_dist($p) {
589
-	$p->code = 'ceil(' .
590
-		champ_sql('popularite', $p) .
589
+	$p->code = 'ceil('.
590
+		champ_sql('popularite', $p).
591 591
 		')';
592 592
 	$p->interdire_scripts = false;
593 593
 
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
  **/
666 666
 function balise_VALEUR_dist($p) {
667 667
 	$b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;
668
-	$p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;
668
+	$p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); ;
669 669
 	if (($v = interprete_argument_balise(1, $p)) !== null) {
670
-		$p->code = 'table_valeur(' . $p->code . ', ' . $v . ')';
670
+		$p->code = 'table_valeur('.$p->code.', '.$v.')';
671 671
 	}
672 672
 	$p->interdire_scripts = true;
673 673
 
@@ -808,16 +808,16 @@  discard block
 block discarded – undo
808 808
 	$trouver_table = charger_fonction('trouver_table', 'base');
809 809
 	if ($desc = $trouver_table(table_objet_sql($type_objet))) {
810 810
 		if (isset($desc['field']['descriptif'])) {
811
-			$_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ',';
811
+			$_ligne .= "'descriptif' => ".champ_sql('descriptif', $p).',';
812 812
 		}
813 813
 		if (isset($desc['field']['texte'])) {
814
-			$_ligne .= "'texte' => " . champ_sql('texte', $p) . ',';
814
+			$_ligne .= "'texte' => ".champ_sql('texte', $p).',';
815 815
 		}
816 816
 		if (isset($desc['field']['chapo'])) {
817
-			$_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ',';
817
+			$_ligne .= "'chapo' => ".champ_sql('chapo', $p).',';
818 818
 		}
819 819
 		if (isset($desc['introduction_longueur'])) {
820
-			$_introduction_longueur = "'" . $desc['introduction_longueur'] . "'";
820
+			$_introduction_longueur = "'".$desc['introduction_longueur']."'";
821 821
 		}
822 822
 	}
823 823
 	$_ligne .= ')';
@@ -913,10 +913,10 @@  discard block
 block discarded – undo
913 913
 		$c = memoriser_contexte_compil($p);
914 914
 
915 915
 		$p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",
916
-			"array('objet'=>'" . $objet .
917
-			"','id_objet' => " . champ_sql($id_table_objet, $p) .
918
-			",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .
919
-			($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) .
916
+			"array('objet'=>'".$objet.
917
+			"','id_objet' => ".champ_sql($id_table_objet, $p).
918
+			",'$id_table_objet' => ".champ_sql($id_table_objet, $p).
919
+			($objet == 'article' ? "" : ",'id_article' => ".champ_sql('id_article', $p)).
920 920
 			")",
921 921
 			"'trim'=>true, 'compil'=>array($c)",
922 922
 			_q($connect));
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 					$m = trim($m);
985 985
 					if ($m != "''") {
986 986
 						if (!preg_match(",\W,", $m)) {
987
-							$m = $boucle->id_table . ".$m";
987
+							$m = $boucle->id_table.".$m";
988 988
 						}
989 989
 						
990 990
 						$m .= " AS titre_rang";
@@ -1008,8 +1008,8 @@  discard block
 block discarded – undo
1008 1008
 			$_primary = champ_sql($id_table_objet, $p, '', false);
1009 1009
 			$_env = '$Pile[0]';
1010 1010
 
1011
-			if (!$_titre) {$_titre = "''";}
1012
-			if (!$_primary) {$_primary = "''";}
1011
+			if (!$_titre) {$_titre = "''"; }
1012
+			if (!$_primary) {$_primary = "''"; }
1013 1013
 			$_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)";
1014 1014
 
1015 1015
 		}
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 	$f_pagination = chercher_filtre('pagination');
1143 1143
 	$type = $p->boucles[$b]->modificateur['debut_nom'];
1144 1144
 	$modif = ($type[0] !== "'") ? "'debut'.$type"
1145
-		: ("'debut" . substr($type, 1));
1145
+		: ("'debut".substr($type, 1));
1146 1146
 
1147 1147
 	$p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,
1148 1148
 		((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN'));
1277 1277
 		erreur_squelette($msg, $p);
1278 1278
 	} else {
1279
-		$p->code = 'find_in_path(' . $arg . ')';
1279
+		$p->code = 'find_in_path('.$arg.')';
1280 1280
 	}
1281 1281
 
1282 1282
 	$p->interdire_scripts = false;
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE'));
1312 1312
 		erreur_squelette($msg, $p);
1313 1313
 	} else {
1314
-		$p->code = 'chemin_image(' . $arg . ')';
1314
+		$p->code = 'chemin_image('.$arg.')';
1315 1315
 	}
1316 1316
 
1317 1317
 	$p->interdire_scripts = false;
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 		// cas de #ENV sans argument : on retourne le serialize() du tableau
1366 1366
 		// une belle fonction [(#ENV|affiche_env)] serait pratique
1367 1367
 		if ($src) {
1368
-			$p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")';
1368
+			$p->code = '(is_array($a = ('.$src.')) ? serialize($a) : "")';
1369 1369
 		} else {
1370 1370
 			$p->code = '@serialize($Pile[0])';
1371 1371
 		}
@@ -1418,8 +1418,8 @@  discard block
 block discarded – undo
1418 1418
 	$_sinon = interprete_argument_balise(2, $p);
1419 1419
 	$_unserialize = sinon(interprete_argument_balise(3, $p), "false");
1420 1420
 
1421
-	$p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' .
1422
-		($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";
1421
+	$p->code = '(include_spip(\'inc/config\')?lire_config('.$arg.','.
1422
+		($_sinon && $_sinon != "''" ? $_sinon : 'null').','.$_unserialize."):'')";
1423 1423
 
1424 1424
 	return $p;
1425 1425
 }
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET'));
1513 1513
 		erreur_squelette($err_b_s_a, $p);
1514 1514
 	} else {
1515
-		$p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))';
1515
+		$p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))';
1516 1516
 	}
1517 1517
 
1518 1518
 	$p->interdire_scripts = false;
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 		if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms",
1556 1556
 			$php, $r)) {
1557 1557
 			$p->code = /* $r[1]. */
1558
-				'(' . $r[2] . ')';
1558
+				'('.$r[2].')';
1559 1559
 		} else {
1560 1560
 			$p->code = "eval('return '.$php.';')";
1561 1561
 		}
@@ -1798,9 +1798,9 @@  discard block
 block discarded – undo
1798 1798
 
1799 1799
 		// noter la duree du cache dans un entete proprietaire
1800 1800
 
1801
-		$code = "'<'.'" . '?php header("X-Spip-Cache: '
1801
+		$code = "'<'.'".'?php header("X-Spip-Cache: '
1802 1802
 			. $duree
1803
-			. '"); ?' . "'.'>'";
1803
+			. '"); ?'."'.'>'";
1804 1804
 
1805 1805
 		// Remplir le header Cache-Control
1806 1806
 		// cas #CACHE{0}
@@ -1820,9 +1820,9 @@  discard block
 block discarded – undo
1820 1820
 			if ($pa == 'cache-client'
1821 1821
 				and $duree > 0
1822 1822
 			) {
1823
-				$code .= ".'<'.'" . '?php header("Cache-Control: max-age='
1823
+				$code .= ".'<'.'".'?php header("Cache-Control: max-age='
1824 1824
 					. $duree
1825
-					. '"); ?' . "'.'>'";
1825
+					. '"); ?'."'.'>'";
1826 1826
 				// il semble logique, si on cache-client, de ne pas invalider
1827 1827
 				$pa = 'statique';
1828 1828
 			}
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 			if ($pa == 'statique'
1831 1831
 				and $duree > 0
1832 1832
 			) {
1833
-				$code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'";
1833
+				$code .= ".'<'.'".'?php header("X-Spip-Statique: oui"); ?'."'.'>'";
1834 1834
 			}
1835 1835
 		}
1836 1836
 	} else {
@@ -1995,9 +1995,9 @@  discard block
 block discarded – undo
1995 1995
 		if ($p->etoile) {
1996 1996
 			$_options[] = "'etoile'=>true";
1997 1997
 		}
1998
-		$_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")";
1998
+		$_options[] = "'compil'=>array(".memoriser_contexte_compil($p).")";
1999 1999
 
2000
-		$_l = 'array(' . join(",\n\t", $_contexte) . ')';
2000
+		$_l = 'array('.join(",\n\t", $_contexte).')';
2001 2001
 		if ($flag_env) {
2002 2002
 			$_l = "array_merge(\$Pile[0],$_l)";
2003 2003
 		}
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
 		$msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE'));
2009 2009
 		erreur_squelette($msg, $p);
2010 2010
 	} else {
2011
-		$p->code = 'charge_scripts(' . $_contexte[1] . ',false)';
2011
+		$p->code = 'charge_scripts('.$_contexte[1].',false)';
2012 2012
 	}
2013 2013
 
2014 2014
 	$p->interdire_scripts = false; // la securite est assuree par recuperer_fond
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
 		unset($_contexte[1]);
2057 2057
 
2058 2058
 		if (preg_match("/^\s*'[^']*'/s", $nom)) {
2059
-			$nom = "'modeles/" . substr($nom, 1);
2059
+			$nom = "'modeles/".substr($nom, 1);
2060 2060
 		} else {
2061 2061
 			$nom = "'modeles/' . $nom";
2062 2062
 		}
@@ -2073,8 +2073,8 @@  discard block
 block discarded – undo
2073 2073
 			$primary = $p->boucles[$p->id_boucle]->primary;
2074 2074
 			if (!strpos($primary, ',')) {
2075 2075
 				$id = champ_sql($primary, $p);
2076
-				$_contexte[] = "'$primary'=>" . $id;
2077
-				$_contexte[] = "'id'=>" . $id;
2076
+				$_contexte[] = "'$primary'=>".$id;
2077
+				$_contexte[] = "'id'=>".$id;
2078 2078
 			}
2079 2079
 		}
2080 2080
 		$_contexte[] = "'recurs'=>(++\$recurs)";
@@ -2086,11 +2086,11 @@  discard block
 block discarded – undo
2086 2086
 		$_options = memoriser_contexte_compil($p);
2087 2087
 		$_options = "'compil'=>array($_options), 'trim'=>true";
2088 2088
 		if (isset($_contexte['ajax'])) {
2089
-			$_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2089
+			$_options .= ", ".preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']);
2090 2090
 			unset($_contexte['ajax']);
2091 2091
 		}
2092 2092
 
2093
-		$_l = 'array(' . join(",\n\t", $_contexte) . ')';
2093
+		$_l = 'array('.join(",\n\t", $_contexte).')';
2094 2094
 		if ($flag_env) {
2095 2095
 			$_l = "array_merge(\$Pile[0],$_l)";
2096 2096
 		}
@@ -2200,12 +2200,12 @@  discard block
 block discarded – undo
2200 2200
 function balise_DOUBLONS_dist($p) {
2201 2201
 	if ($type = interprete_argument_balise(1, $p)) {
2202 2202
 		if ($famille = interprete_argument_balise(2, $p)) {
2203
-			$type .= '.' . $famille;
2203
+			$type .= '.'.$famille;
2204 2204
 		}
2205
-		$p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';
2205
+		$p->code = '(isset($doublons['.$type.']) ? $doublons['.$type.'] : "")';
2206 2206
 		if (!$p->etoile) {
2207 2207
 			$p->code = 'array_filter(array_map("intval",explode(",",'
2208
-				. $p->code . ')))';
2208
+				. $p->code.')))';
2209 2209
 		}
2210 2210
 	} else {
2211 2211
 		$p->code = '$doublons';
@@ -2334,7 +2334,7 @@  discard block
 block discarded – undo
2334 2334
 			$_code[] = "$_key => $_val";
2335 2335
 		}
2336 2336
 	} while ($_key && $_val);
2337
-	$p->code = 'array(' . join(', ', $_code) . ')';
2337
+	$p->code = 'array('.join(', ', $_code).')';
2338 2338
 	$p->interdire_scripts = false;
2339 2339
 
2340 2340
 	return $p;
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
 	while ($_val = interprete_argument_balise($n++, $p)) {
2362 2362
 		$_code[] = $_val;
2363 2363
 	}
2364
-	$p->code = 'array(' . join(', ', $_code) . ')';
2364
+	$p->code = 'array('.join(', ', $_code).')';
2365 2365
 	$p->interdire_scripts = false;
2366 2366
 
2367 2367
 	return $p;
@@ -2406,8 +2406,8 @@  discard block
 block discarded – undo
2406 2406
 		$_code[] = $_v;
2407 2407
 	}
2408 2408
 
2409
-	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',
2410
-			$_code) . ')?" ":"")';
2409
+	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('.join(', ',
2410
+			$_code).')?" ":"")';
2411 2411
 	$p->interdire_scripts = false;
2412 2412
 
2413 2413
 	return $p;
@@ -2440,7 +2440,7 @@  discard block
 block discarded – undo
2440 2440
 	$type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"';
2441 2441
 
2442 2442
 	$f = chercher_filtre('info_plugin');
2443
-	$p->code = $f . '(' . $plugin . ', ' . $type_info . ')';
2443
+	$p->code = $f.'('.$plugin.', '.$type_info.')';
2444 2444
 
2445 2445
 	return $p;
2446 2446
 }
@@ -2690,12 +2690,12 @@  discard block
 block discarded – undo
2690 2690
 	$_issens = "in_array($_champ,array('>','<'))";
2691 2691
 	$_sens = "(strpos('< >',$_champ)-1)";
2692 2692
 
2693
-	$_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];
2693
+	$_variable = "((\$s=$_issens)?'sens':'tri').".$boucle->modificateur['tri_nom'];
2694 2694
 	$_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";
2695
-	$_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')";
2696
-	$_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)";
2695
+	$_url = "parametre_url($_url,'var_memotri',strncmp(".$boucle->modificateur['tri_nom'].",'session',7)==0?$_variable:'')";
2696
+	$_on = "\$s?(".$boucle->modificateur['tri_sens']."==$_sens".'):('.$boucle->modificateur['tri_champ']."==$_champ)";
2697 2697
 
2698
-	$p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";
2698
+	$p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class ? ",$_class" : "").")";
2699 2699
 	//$p->code = "''";
2700 2700
 	$p->interdire_scripts = false;
2701 2701
 
@@ -2769,7 +2769,7 @@  discard block
 block discarded – undo
2769 2769
 		$connect = $p->boucles[$p->id_boucle]->sql_serveur;
2770 2770
 	}
2771 2771
 
2772
-	$p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')";
2772
+	$p->code = "(objet_test_si_publie(".$_type.",intval(".$_id."),"._q($connect).")?' ':'')";
2773 2773
 	$p->interdire_scripts = false;
2774 2774
 
2775 2775
 	return $p;
Please login to merge, or discard this patch.
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/debusquer.php 4 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -362,9 +362,11 @@  discard block
 block discarded – undo
362 362
 			if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) {
363 363
 				$y = substr_count($v[0], "\n");
364 364
 			} else {
365
-				if ($v[1][0] == '#') // balise dynamique
365
+				if ($v[1][0] == '#') {
366
+				    // balise dynamique
366 367
 				{
367 368
 					$incl = $GLOBALS['debug_objets']['resultat'][$v[2]];
369
+				}
368 370
 				} else // inclusion
369 371
 				{
370 372
 					$incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])];
@@ -397,12 +399,14 @@  discard block
 block discarded – undo
397 399
 	preg_match('/include\(.(.*).php3?.\);/', $script, $reg);
398 400
 	// si le script X.php n'est pas ecrire/public.php
399 401
 	// on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux)
400
-	if ($reg[1] == 'ecrire/public') // si c'est bien ecrire/public on cherche le param 'fond'
402
+	if ($reg[1] == 'ecrire/public') {
403
+	    // si c'est bien ecrire/public on cherche le param 'fond'
401 404
 	{
402 405
 		if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) // a defaut on cherche le param 'page'
403 406
 		{
404 407
 			if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) {
405 408
 				$reg[1] = "inconnu";
409
+	}
406 410
 			}
407 411
 		}
408 412
 	}
Please login to merge, or discard this patch.
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -432,6 +432,10 @@  discard block
 block discarded – undo
432 432
 }
433 433
 
434 434
 // https://code.spip.net/@reference_boucle_debug
435
+/**
436
+ * @param string $nom
437
+ * @param string $self
438
+ */
435 439
 function reference_boucle_debug($n, $nom, $self) {
436 440
 	list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom);
437 441
 
@@ -820,6 +824,9 @@  discard block
 block discarded – undo
820 824
 }
821 825
 
822 826
 // https://code.spip.net/@debusquer_entete
827
+/**
828
+ * @param string $corps
829
+ */
823 830
 function debusquer_entete($titre, $corps) {
824 831
 
825 832
 	include_spip('balise/formulaire_admin');
Please login to merge, or discard this patch.
Indentation   +681 added lines, -681 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
 include_spip('public/decompiler');
@@ -66,135 +66,135 @@  discard block
 block discarded – undo
66 66
  *     - string si $message à false.
67 67
  **/
68 68
 function public_debusquer_dist($message = '', $lieu = '', $opt = array()) {
69
-	static $tableau_des_erreurs = array();
70
-
71
-	// Pour des tests unitaires, pouvoir récupérer les erreurs générées
72
-	if (isset($opt['erreurs'])) {
73
-		if ($opt['erreurs'] == 'get') {
74
-			return $tableau_des_erreurs;
75
-		}
76
-		if ($opt['erreurs'] == 'reset') {
77
-			$tableau_des_erreurs = array();
78
-
79
-			return true;
80
-		}
81
-	}
82
-
83
-	// Erreur ou appel final ?
84
-	if ($message) {
85
-		$message = debusquer_compose_message($message);
86
-		$tableau_des_erreurs[] = array($message, $lieu);
87
-		set_request('var_mode', 'debug');
88
-		$GLOBALS['bouton_admin_debug'] = true;
89
-		// Permettre a la compil de continuer
90
-		if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) {
91
-			$lieu->code = "''";
92
-		}
93
-		// forcer l'appel au debusqueur en cas de boucles infernales
94
-		$urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and count($tableau_des_erreurs) > _DEBUG_MAX_SQUELETTE_ERREURS);
95
-		if (!$urgence) {
96
-			return;
97
-		}
98
-	}
99
-	if (empty($GLOBALS['debug_objets']['principal'])) {
100
-		// espace public ?
101
-		if (isset($GLOBALS['fond'])) {
102
-			$GLOBALS['debug_objets']['principal'] = $GLOBALS['fond'];
103
-		}
104
-	}
105
-
106
-	include_spip('inc/autoriser');
107
-	if (!autoriser('debug')) {
108
-		return;
109
-	}
110
-	include_spip('inc/headers');
111
-	include_spip('inc/filtres');
112
-
113
-	// en cas de squelette inclus,  virer le code de l'incluant:
114
-	// - il contient souvent une Div restreignant la largeur a 3 fois rien
115
-	// - ca fait 2 headers !
116
-	// sauf si l'on se trouve deja dans un flux compresse (plugin compresseur
117
-	// actif par exemple)
118
-	if (ob_get_length()
119
-		and
120
-		!in_array('ob_gzhandler', ob_get_status())
121
-	) {
122
-		ob_end_clean();
123
-	}
124
-
125
-	lang_select($GLOBALS['visiteur_session']['lang']);
126
-	$fonc = _request('var_mode_objet');
127
-	$mode = _request('var_mode_affiche');
128
-	$self = str_replace("\\'", '&#39;', self());
129
-	$self = parametre_url($self, 'var_mode', 'debug');
130
-
131
-	$res = debusquer_bandeau($tableau_des_erreurs)
132
-		. '<br />'
133
-		. debusquer_squelette($fonc, $mode, $self);
134
-
135
-	if (!_DIR_RESTREINT or headers_sent()) {
136
-		return $res;
137
-	}
138
-	if ($tableau_des_erreurs) {
139
-		http_status(503);
140
-	}
141
-
142
-	http_no_cache();
143
-	if (isset($_GET['var_profile'])) {
144
-		$titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', '');
145
-		$titre = parametre_url($titre, 'var_mode', '');
146
-	} else {
147
-		if (!$fonc) {
148
-			$fonc = $GLOBALS['debug_objets']['principal'];
149
-		}
150
-		$titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? " " . $GLOBALS['debug_objets']['sourcefile'][$fonc] : ""));
151
-	}
152
-	if ($message === false) {
153
-		lang_select();
154
-
155
-		return debusquer_entete($titre, $res);
156
-	} else {
157
-		echo debusquer_entete($titre, $res);
158
-	}
159
-	exit;
69
+    static $tableau_des_erreurs = array();
70
+
71
+    // Pour des tests unitaires, pouvoir récupérer les erreurs générées
72
+    if (isset($opt['erreurs'])) {
73
+        if ($opt['erreurs'] == 'get') {
74
+            return $tableau_des_erreurs;
75
+        }
76
+        if ($opt['erreurs'] == 'reset') {
77
+            $tableau_des_erreurs = array();
78
+
79
+            return true;
80
+        }
81
+    }
82
+
83
+    // Erreur ou appel final ?
84
+    if ($message) {
85
+        $message = debusquer_compose_message($message);
86
+        $tableau_des_erreurs[] = array($message, $lieu);
87
+        set_request('var_mode', 'debug');
88
+        $GLOBALS['bouton_admin_debug'] = true;
89
+        // Permettre a la compil de continuer
90
+        if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) {
91
+            $lieu->code = "''";
92
+        }
93
+        // forcer l'appel au debusqueur en cas de boucles infernales
94
+        $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and count($tableau_des_erreurs) > _DEBUG_MAX_SQUELETTE_ERREURS);
95
+        if (!$urgence) {
96
+            return;
97
+        }
98
+    }
99
+    if (empty($GLOBALS['debug_objets']['principal'])) {
100
+        // espace public ?
101
+        if (isset($GLOBALS['fond'])) {
102
+            $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond'];
103
+        }
104
+    }
105
+
106
+    include_spip('inc/autoriser');
107
+    if (!autoriser('debug')) {
108
+        return;
109
+    }
110
+    include_spip('inc/headers');
111
+    include_spip('inc/filtres');
112
+
113
+    // en cas de squelette inclus,  virer le code de l'incluant:
114
+    // - il contient souvent une Div restreignant la largeur a 3 fois rien
115
+    // - ca fait 2 headers !
116
+    // sauf si l'on se trouve deja dans un flux compresse (plugin compresseur
117
+    // actif par exemple)
118
+    if (ob_get_length()
119
+        and
120
+        !in_array('ob_gzhandler', ob_get_status())
121
+    ) {
122
+        ob_end_clean();
123
+    }
124
+
125
+    lang_select($GLOBALS['visiteur_session']['lang']);
126
+    $fonc = _request('var_mode_objet');
127
+    $mode = _request('var_mode_affiche');
128
+    $self = str_replace("\\'", '&#39;', self());
129
+    $self = parametre_url($self, 'var_mode', 'debug');
130
+
131
+    $res = debusquer_bandeau($tableau_des_erreurs)
132
+        . '<br />'
133
+        . debusquer_squelette($fonc, $mode, $self);
134
+
135
+    if (!_DIR_RESTREINT or headers_sent()) {
136
+        return $res;
137
+    }
138
+    if ($tableau_des_erreurs) {
139
+        http_status(503);
140
+    }
141
+
142
+    http_no_cache();
143
+    if (isset($_GET['var_profile'])) {
144
+        $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', '');
145
+        $titre = parametre_url($titre, 'var_mode', '');
146
+    } else {
147
+        if (!$fonc) {
148
+            $fonc = $GLOBALS['debug_objets']['principal'];
149
+        }
150
+        $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? " " . $GLOBALS['debug_objets']['sourcefile'][$fonc] : ""));
151
+    }
152
+    if ($message === false) {
153
+        lang_select();
154
+
155
+        return debusquer_entete($titre, $res);
156
+    } else {
157
+        echo debusquer_entete($titre, $res);
158
+    }
159
+    exit;
160 160
 }
161 161
 
162 162
 function debusquer_compose_message($msg) {
163
-	if (is_array($msg)) {
164
-		// si c'est un texte, c'est une traduction a faire, mais
165
-		// sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments)
166
-		if (!is_numeric($msg[0]) and count($msg) == 2) {
167
-			// message avec argument: instancier
168
-			$msg = _T($msg[0], $msg[1], 'spip-debug-arg');
169
-		} else {
170
-			// message SQL: interpreter
171
-			$msg = debusquer_requete($msg);
172
-		}
173
-	}
174
-	// FIXME: le fond n'est pas la si on n'est pas dans un squelette
175
-	// cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur
176
-	$fond = isset($GLOBALS['fond']) ? $GLOBALS['fond'] : "";
177
-	// une erreur critique sort $message en array
178
-	$debug = is_array($msg) ? $msg[1] : $msg;
179
-	spip_log("Debug: " . $debug . " (" . $fond . ")");
180
-
181
-	return $msg;
163
+    if (is_array($msg)) {
164
+        // si c'est un texte, c'est une traduction a faire, mais
165
+        // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments)
166
+        if (!is_numeric($msg[0]) and count($msg) == 2) {
167
+            // message avec argument: instancier
168
+            $msg = _T($msg[0], $msg[1], 'spip-debug-arg');
169
+        } else {
170
+            // message SQL: interpreter
171
+            $msg = debusquer_requete($msg);
172
+        }
173
+    }
174
+    // FIXME: le fond n'est pas la si on n'est pas dans un squelette
175
+    // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur
176
+    $fond = isset($GLOBALS['fond']) ? $GLOBALS['fond'] : "";
177
+    // une erreur critique sort $message en array
178
+    $debug = is_array($msg) ? $msg[1] : $msg;
179
+    spip_log("Debug: " . $debug . " (" . $fond . ")");
180
+
181
+    return $msg;
182 182
 }
183 183
 
184 184
 function debusquer_bandeau($erreurs) {
185 185
 
186
-	if (!empty($erreurs)) {
187
-		$n = array(count($erreurs) . ' ' . _T('zbug_erreur_squelette'));
186
+    if (!empty($erreurs)) {
187
+        $n = array(count($erreurs) . ' ' . _T('zbug_erreur_squelette'));
188 188
 
189
-		return debusquer_navigation($erreurs, $n);
190
-	} elseif (!empty($GLOBALS['tableau_des_temps'])) {
191
-		include_spip('public/tracer');
192
-		list($temps, $nav) = chrono_requete($GLOBALS['tableau_des_temps']);
189
+        return debusquer_navigation($erreurs, $n);
190
+    } elseif (!empty($GLOBALS['tableau_des_temps'])) {
191
+        include_spip('public/tracer');
192
+        list($temps, $nav) = chrono_requete($GLOBALS['tableau_des_temps']);
193 193
 
194
-		return debusquer_navigation($temps, $nav, 'debug-profile');
195
-	} else {
196
-		return '';
197
-	}
194
+        return debusquer_navigation($temps, $nav, 'debug-profile');
195
+    } else {
196
+        return '';
197
+    }
198 198
 }
199 199
 
200 200
 /**
@@ -204,42 +204,42 @@  discard block
 block discarded – undo
204 204
  * @return string Code HTML
205 205
  **/
206 206
 function debusquer_contexte($env) {
207
-	if (is_string($env) and is_array($env_tab = @unserialize($env))) {
208
-		$env = $env_tab;
209
-	}
210
-
211
-	if (!$env) {
212
-		return '';
213
-	}
214
-	$res = "";
215
-	foreach ($env as $nom => $valeur) {
216
-		if (is_array($valeur)) {
217
-			$valeur_simple = array();
218
-			foreach ($valeur as $v) {
219
-				if (is_array($v)) {
220
-					$valeur_simple[] = 'array:' . count($v);
221
-				} elseif (is_object($v)) {
222
-					$valeur_simple[] = get_class($v);
223
-				} elseif (is_string($v)) {
224
-					$valeur_simple[] = "'" . $v . "'";
225
-				} else {
226
-					$valeur_simple[] = $v;
227
-				}
228
-			}
229
-			$n = count($valeur);
230
-			$valeur = (($n > 3) ? 'array:' . $n . ' ' : '');
231
-			$valeur .= '[' . join(', ', $valeur_simple) . ']';
232
-		} elseif (is_object($valeur)) {
233
-			$valeur = get_class($valeur);
234
-		} elseif (is_string($valeur)) {
235
-			$valeur = "'" . $valeur . "'";
236
-		}
237
-		$res .= "\n<tr><td><strong>" . nl2br(entites_html($nom))
238
-			. "</strong></td><td>:&nbsp;" . nl2br(entites_html($valeur))
239
-			. "</td></tr>\n";
240
-	}
241
-
242
-	return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n";
207
+    if (is_string($env) and is_array($env_tab = @unserialize($env))) {
208
+        $env = $env_tab;
209
+    }
210
+
211
+    if (!$env) {
212
+        return '';
213
+    }
214
+    $res = "";
215
+    foreach ($env as $nom => $valeur) {
216
+        if (is_array($valeur)) {
217
+            $valeur_simple = array();
218
+            foreach ($valeur as $v) {
219
+                if (is_array($v)) {
220
+                    $valeur_simple[] = 'array:' . count($v);
221
+                } elseif (is_object($v)) {
222
+                    $valeur_simple[] = get_class($v);
223
+                } elseif (is_string($v)) {
224
+                    $valeur_simple[] = "'" . $v . "'";
225
+                } else {
226
+                    $valeur_simple[] = $v;
227
+                }
228
+            }
229
+            $n = count($valeur);
230
+            $valeur = (($n > 3) ? 'array:' . $n . ' ' : '');
231
+            $valeur .= '[' . join(', ', $valeur_simple) . ']';
232
+        } elseif (is_object($valeur)) {
233
+            $valeur = get_class($valeur);
234
+        } elseif (is_string($valeur)) {
235
+            $valeur = "'" . $valeur . "'";
236
+        }
237
+        $res .= "\n<tr><td><strong>" . nl2br(entites_html($nom))
238
+            . "</strong></td><td>:&nbsp;" . nl2br(entites_html($valeur))
239
+            . "</td></tr>\n";
240
+    }
241
+
242
+    return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n";
243 243
 }
244 244
 
245 245
 // Affichage du tableau des erreurs ou des temps de calcul
@@ -247,67 +247,67 @@  discard block
 block discarded – undo
247 247
 
248 248
 function debusquer_navigation($tableau, $caption = array(), $id = 'debug-nav') {
249 249
 
250
-	if (_request('exec') == 'valider_xml') {
251
-		return '';
252
-	}
253
-	$GLOBALS['bouton_admin_debug'] = true;
254
-	$res = '';
255
-	$href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug'));
256
-	foreach ($tableau as $i => $err) {
257
-		$boucle = $ligne = $skel = '';
258
-		list($msg, $lieu) = $err;
259
-		if (is_object($lieu)) {
260
-			$ligne = $lieu->ligne;
261
-			$boucle = $lieu->id_boucle ? $lieu->id_boucle : '';
262
-			if (isset($lieu->descr['nom'])) {
263
-				$nom_code = $lieu->descr['nom'];
264
-				$skel = $lieu->descr['sourcefile'];
265
-				$h2 = parametre_url($href, 'var_mode_objet', $nom_code);
266
-				$h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne;
267
-				$skel = "<a href='$h3'><b>$skel</b></a>";
268
-				if ($boucle) {
269
-					$h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle');
270
-					$boucle = "<a href='$h3'><b>$boucle</b></a>";
271
-				}
272
-			}
273
-		}
274
-
275
-		$j = ($i + 1);
276
-		$res .= "<tr id='req$j'><td style='text-align: right'>"
277
-			. $j
278
-			. "&nbsp;</td><td style='text-align: left'>"
279
-			. (is_array($msg) ? implode('', $msg) : $msg)
280
-			. "</td><td style='text-align: left'>"
281
-			. ($skel ? $skel : "&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;")
282
-			. "</td><td class='spip-debug-arg' style='text-align: left'>"
283
-			. ($boucle ? $boucle : "&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;")
284
-			. "</td><td style='text-align: right'>"
285
-			. $ligne
286
-			. "</td></tr>\n";
287
-
288
-	}
289
-
290
-	return "\n<table id='$id'>"
291
-	. "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">"
292
-	. $caption[0]
250
+    if (_request('exec') == 'valider_xml') {
251
+        return '';
252
+    }
253
+    $GLOBALS['bouton_admin_debug'] = true;
254
+    $res = '';
255
+    $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug'));
256
+    foreach ($tableau as $i => $err) {
257
+        $boucle = $ligne = $skel = '';
258
+        list($msg, $lieu) = $err;
259
+        if (is_object($lieu)) {
260
+            $ligne = $lieu->ligne;
261
+            $boucle = $lieu->id_boucle ? $lieu->id_boucle : '';
262
+            if (isset($lieu->descr['nom'])) {
263
+                $nom_code = $lieu->descr['nom'];
264
+                $skel = $lieu->descr['sourcefile'];
265
+                $h2 = parametre_url($href, 'var_mode_objet', $nom_code);
266
+                $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne;
267
+                $skel = "<a href='$h3'><b>$skel</b></a>";
268
+                if ($boucle) {
269
+                    $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle');
270
+                    $boucle = "<a href='$h3'><b>$boucle</b></a>";
271
+                }
272
+            }
273
+        }
274
+
275
+        $j = ($i + 1);
276
+        $res .= "<tr id='req$j'><td style='text-align: right'>"
277
+            . $j
278
+            . "&nbsp;</td><td style='text-align: left'>"
279
+            . (is_array($msg) ? implode('', $msg) : $msg)
280
+            . "</td><td style='text-align: left'>"
281
+            . ($skel ? $skel : "&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;")
282
+            . "</td><td class='spip-debug-arg' style='text-align: left'>"
283
+            . ($boucle ? $boucle : "&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;")
284
+            . "</td><td style='text-align: right'>"
285
+            . $ligne
286
+            . "</td></tr>\n";
287
+
288
+    }
289
+
290
+    return "\n<table id='$id'>"
291
+    . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">"
292
+    . $caption[0]
293 293
 ## aide locale courte a ecrire, avec lien vers une grosse page de documentation
294 294
 #		aider('erreur_compilation'),
295
-	. "</caption>"
296
-	//  fausse caption du chrono (mais vraie nav)
297
-	. (!empty($caption[1]) ? $caption[1] : '')
298
-	. "<tr><th>"
299
-	. _T('numero')
300
-	. "</th><th>"
301
-	. _T('public:message')
302
-	. "</th><th>"
303
-	. _T('squelette')
304
-	. "</th><th>"
305
-	. _T('zbug_boucle')
306
-	. "</th><th>"
307
-	. _T('ligne')
308
-	. "</th></tr>"
309
-	. $res
310
-	. "</table>";
295
+    . "</caption>"
296
+    //  fausse caption du chrono (mais vraie nav)
297
+    . (!empty($caption[1]) ? $caption[1] : '')
298
+    . "<tr><th>"
299
+    . _T('numero')
300
+    . "</th><th>"
301
+    . _T('public:message')
302
+    . "</th><th>"
303
+    . _T('squelette')
304
+    . "</th><th>"
305
+    . _T('zbug_boucle')
306
+    . "</th><th>"
307
+    . _T('ligne')
308
+    . "</th></tr>"
309
+    . $res
310
+    . "</table>";
311 311
 }
312 312
 
313 313
 
@@ -327,125 +327,125 @@  discard block
 block discarded – undo
327 327
  *    ou un tableau si l'erreur est critique
328 328
  **/
329 329
 function debusquer_requete($message) {
330
-	list($errno, $msg, $query) = $message;
331
-
332
-	// FIXME: ces écritures mélangent divers syntaxe des moteurs SQL
333
-	// il serait plus prudent certainement d'avoir une fonction d'analyse par moteur
334
-	if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) {
335
-		$errno = $regs[2];
336
-	} elseif (is_numeric($errno) and ($errno == 1030 or $errno <= 1026)
337
-		and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs)
338
-	) {
339
-		$errno = $regs[1];
340
-	}
341
-
342
-	// Erreur systeme
343
-	if (is_numeric($errno) and $errno > 0 and $errno < 200) {
344
-		$retour = "<tt><br /><br /><blink>"
345
-			. _T('info_erreur_systeme', array('errsys' => $errno))
346
-			. "</blink><br />\n<b>"
347
-			. _T('info_erreur_systeme2',
348
-				array('script' => generer_url_ecrire('base_repair')))
349
-			. '</b><br />';
350
-		spip_log("Erreur systeme $errno");
351
-
352
-		return array($retour, '');
353
-	}
354
-
355
-	// Requete erronee
356
-	$err = "<b>" . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n"
357
-		. spip_htmlspecialchars($msg)
358
-		. "\n<br /><span style='color: red'><b>"
359
-		. spip_htmlspecialchars($query)
360
-		. "</b></span></tt><br />";
361
-
362
-	//. aider('erreur_mysql');
363
-
364
-	return $err;
330
+    list($errno, $msg, $query) = $message;
331
+
332
+    // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL
333
+    // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur
334
+    if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) {
335
+        $errno = $regs[2];
336
+    } elseif (is_numeric($errno) and ($errno == 1030 or $errno <= 1026)
337
+        and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs)
338
+    ) {
339
+        $errno = $regs[1];
340
+    }
341
+
342
+    // Erreur systeme
343
+    if (is_numeric($errno) and $errno > 0 and $errno < 200) {
344
+        $retour = "<tt><br /><br /><blink>"
345
+            . _T('info_erreur_systeme', array('errsys' => $errno))
346
+            . "</blink><br />\n<b>"
347
+            . _T('info_erreur_systeme2',
348
+                array('script' => generer_url_ecrire('base_repair')))
349
+            . '</b><br />';
350
+        spip_log("Erreur systeme $errno");
351
+
352
+        return array($retour, '');
353
+    }
354
+
355
+    // Requete erronee
356
+    $err = "<b>" . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n"
357
+        . spip_htmlspecialchars($msg)
358
+        . "\n<br /><span style='color: red'><b>"
359
+        . spip_htmlspecialchars($query)
360
+        . "</b></span></tt><br />";
361
+
362
+    //. aider('erreur_mysql');
363
+
364
+    return $err;
365 365
 }
366 366
 
367 367
 
368 368
 // https://code.spip.net/@trouve_boucle_debug
369 369
 function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = "") {
370 370
 
371
-	$id = $nom . $boucle;
372
-	if (is_array($GLOBALS['debug_objets']['sequence'][$id])) {
373
-		foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) {
374
-
375
-			if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) {
376
-				$y = substr_count($v[0], "\n");
377
-			} else {
378
-				if ($v[1][0] == '#') // balise dynamique
379
-				{
380
-					$incl = $GLOBALS['debug_objets']['resultat'][$v[2]];
381
-				} else // inclusion
382
-				{
383
-					$incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])];
384
-				}
385
-				$y = substr_count($incl, "\n")
386
-					+ substr_count($r[1], "\n")
387
-					+ substr_count($r[3], "\n");
388
-			}
389
-			if ($n <= ($y + $debut)) {
390
-				if ($v[1][0] == '?') {
391
-					return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1));
392
-				} elseif ($v[1][0] == '!') {
393
-					if ($incl = trouve_squelette_inclus($v[1])) {
394
-						return trouve_boucle_debug($n, $incl, $debut);
395
-					}
396
-				}
397
-
398
-				return array($nom, $boucle, $v[2] - 1 + $n - $debut);
399
-			}
400
-			$debut += $y;
401
-		}
402
-	}
403
-
404
-	return array($nom, $boucle, $n - $debut);
371
+    $id = $nom . $boucle;
372
+    if (is_array($GLOBALS['debug_objets']['sequence'][$id])) {
373
+        foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) {
374
+
375
+            if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) {
376
+                $y = substr_count($v[0], "\n");
377
+            } else {
378
+                if ($v[1][0] == '#') // balise dynamique
379
+                {
380
+                    $incl = $GLOBALS['debug_objets']['resultat'][$v[2]];
381
+                } else // inclusion
382
+                {
383
+                    $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])];
384
+                }
385
+                $y = substr_count($incl, "\n")
386
+                    + substr_count($r[1], "\n")
387
+                    + substr_count($r[3], "\n");
388
+            }
389
+            if ($n <= ($y + $debut)) {
390
+                if ($v[1][0] == '?') {
391
+                    return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1));
392
+                } elseif ($v[1][0] == '!') {
393
+                    if ($incl = trouve_squelette_inclus($v[1])) {
394
+                        return trouve_boucle_debug($n, $incl, $debut);
395
+                    }
396
+                }
397
+
398
+                return array($nom, $boucle, $v[2] - 1 + $n - $debut);
399
+            }
400
+            $debut += $y;
401
+        }
402
+    }
403
+
404
+    return array($nom, $boucle, $n - $debut);
405 405
 }
406 406
 
407 407
 // https://code.spip.net/@trouve_squelette_inclus
408 408
 function trouve_squelette_inclus($script) {
409 409
 
410
-	preg_match('/include\(.(.*).php3?.\);/', $script, $reg);
411
-	// si le script X.php n'est pas ecrire/public.php
412
-	// on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux)
413
-	if ($reg[1] == 'ecrire/public') // si c'est bien ecrire/public on cherche le param 'fond'
414
-	{
415
-		if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) // a defaut on cherche le param 'page'
416
-		{
417
-			if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) {
418
-				$reg[1] = "inconnu";
419
-			}
420
-		}
421
-	}
422
-	$incl = ',' . $reg[1] . '[.]\w$,';
423
-
424
-	foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) {
425
-		if (preg_match($incl, $v)) {
426
-			return $k;
427
-		}
428
-	}
429
-
430
-	return "";
410
+    preg_match('/include\(.(.*).php3?.\);/', $script, $reg);
411
+    // si le script X.php n'est pas ecrire/public.php
412
+    // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux)
413
+    if ($reg[1] == 'ecrire/public') // si c'est bien ecrire/public on cherche le param 'fond'
414
+    {
415
+        if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) // a defaut on cherche le param 'page'
416
+        {
417
+            if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) {
418
+                $reg[1] = "inconnu";
419
+            }
420
+        }
421
+    }
422
+    $incl = ',' . $reg[1] . '[.]\w$,';
423
+
424
+    foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) {
425
+        if (preg_match($incl, $v)) {
426
+            return $k;
427
+        }
428
+    }
429
+
430
+    return "";
431 431
 }
432 432
 
433 433
 // https://code.spip.net/@reference_boucle_debug
434 434
 function reference_boucle_debug($n, $nom, $self) {
435
-	list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom);
436
-
437
-	if (!$boucle) {
438
-		return !$ligne ? "" :
439
-			(" (" .
440
-				(($nom != $skel) ? _T('squelette_inclus_ligne') :
441
-					_T('squelette_ligne')) .
442
-				" <a href='$self&amp;var_mode_objet=$skel&amp;var_mode_affiche=squelette&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)");
443
-	} else {
444
-		$self .= "&amp;var_mode_objet=$skel$boucle&amp;var_mode_affiche=boucle";
445
-
446
-		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" :
447
-			" (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
448
-	}
435
+    list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom);
436
+
437
+    if (!$boucle) {
438
+        return !$ligne ? "" :
439
+            (" (" .
440
+                (($nom != $skel) ? _T('squelette_inclus_ligne') :
441
+                    _T('squelette_ligne')) .
442
+                " <a href='$self&amp;var_mode_objet=$skel&amp;var_mode_affiche=squelette&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)");
443
+    } else {
444
+        $self .= "&amp;var_mode_objet=$skel$boucle&amp;var_mode_affiche=boucle";
445
+
446
+        return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" :
447
+            " (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
448
+    }
449 449
 }
450 450
 
451 451
 // affiche un texte avec numero de ligne et ancre.
@@ -453,395 +453,395 @@  discard block
 block discarded – undo
453 453
 // https://code.spip.net/@ancre_texte
454 454
 function ancre_texte($texte, $fautifs = array(), $nocpt = false) {
455 455
 
456
-	$var_mode_ligne = _request('var_mode_ligne');
457
-	if ($var_mode_ligne) {
458
-		$fautifs[] = array($var_mode_ligne);
459
-	}
460
-	$res = '';
461
-
462
-	$s = highlight_string($texte, true);
463
-	if (substr($s, 0, 6) == '<code>') {
464
-		$s = substr($s, 6);
465
-		$res = '<code>';
466
-	}
467
-
468
-	$s = preg_replace(',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,',
469
-		'<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>',
470
-		$s);
471
-
472
-
473
-	$tableau = explode("<br />", $s);
474
-
475
-	$format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n";
476
-
477
-	$format10 = str_replace('white', 'lightgrey', $format);
478
-	$formaterr = "color: red;";
479
-	$i = 1;
480
-	$flignes = array();
481
-	$loc = array(0, 0);
482
-	foreach ($fautifs as $lc) {
483
-		if (is_array($lc)) {
484
-			$l = array_shift($lc);
485
-			$flignes[$l] = $lc;
486
-		} else {
487
-			$flignes[$lc] = $loc;
488
-		}
489
-	}
490
-
491
-	$ancre = md5($texte);
492
-	foreach ($tableau as $ligne) {
493
-		if (isset($flignes[$i])) {
494
-			$ligne = str_replace('&nbsp;', ' ', $ligne);
495
-			$indexmesg = $flignes[$i][1];
496
-			$err = textebrut($flignes[$i][2]);
497
-			// tentative de pointer sur la colonne fautive;
498
-			// marche pas car highlight_string rajoute des entites. A revoir.
499
-			// $m = $flignes[$i][0];
500
-			// $ligne = substr($ligne, 0, $m-1) .
501
-			// sprintf($formaterr, substr($ligne,$m));
502
-			$bg = $formaterr;
503
-		} else {
504
-			$indexmesg = $ancre;
505
-			$err = $bg = '';
506
-		}
507
-		$res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne);
508
-		$i++;
509
-	}
510
-
511
-	return "<div id='T$ancre'>"
512
-	. '<div onclick="'
513
-	. "jQuery(this).parent().find('a').toggle();"
514
-	. '" title="'
515
-	. _T('masquer_colonne')
516
-	. '" style="cursor: pointer;">'
517
-	. ($nocpt ? '' : _T('info_numero_abbreviation'))
518
-	. "</div>
456
+    $var_mode_ligne = _request('var_mode_ligne');
457
+    if ($var_mode_ligne) {
458
+        $fautifs[] = array($var_mode_ligne);
459
+    }
460
+    $res = '';
461
+
462
+    $s = highlight_string($texte, true);
463
+    if (substr($s, 0, 6) == '<code>') {
464
+        $s = substr($s, 6);
465
+        $res = '<code>';
466
+    }
467
+
468
+    $s = preg_replace(',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,',
469
+        '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>',
470
+        $s);
471
+
472
+
473
+    $tableau = explode("<br />", $s);
474
+
475
+    $format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n";
476
+
477
+    $format10 = str_replace('white', 'lightgrey', $format);
478
+    $formaterr = "color: red;";
479
+    $i = 1;
480
+    $flignes = array();
481
+    $loc = array(0, 0);
482
+    foreach ($fautifs as $lc) {
483
+        if (is_array($lc)) {
484
+            $l = array_shift($lc);
485
+            $flignes[$l] = $lc;
486
+        } else {
487
+            $flignes[$lc] = $loc;
488
+        }
489
+    }
490
+
491
+    $ancre = md5($texte);
492
+    foreach ($tableau as $ligne) {
493
+        if (isset($flignes[$i])) {
494
+            $ligne = str_replace('&nbsp;', ' ', $ligne);
495
+            $indexmesg = $flignes[$i][1];
496
+            $err = textebrut($flignes[$i][2]);
497
+            // tentative de pointer sur la colonne fautive;
498
+            // marche pas car highlight_string rajoute des entites. A revoir.
499
+            // $m = $flignes[$i][0];
500
+            // $ligne = substr($ligne, 0, $m-1) .
501
+            // sprintf($formaterr, substr($ligne,$m));
502
+            $bg = $formaterr;
503
+        } else {
504
+            $indexmesg = $ancre;
505
+            $err = $bg = '';
506
+        }
507
+        $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne);
508
+        $i++;
509
+    }
510
+
511
+    return "<div id='T$ancre'>"
512
+    . '<div onclick="'
513
+    . "jQuery(this).parent().find('a').toggle();"
514
+    . '" title="'
515
+    . _T('masquer_colonne')
516
+    . '" style="cursor: pointer;">'
517
+    . ($nocpt ? '' : _T('info_numero_abbreviation'))
518
+    . "</div>
519 519
 	" . $res . "</div>\n";
520 520
 }
521 521
 
522 522
 // l'environnement graphique du debuggueur 
523 523
 
524 524
 function debusquer_squelette($fonc, $mode, $self) {
525
-	$texte = '';
526
-
527
-	if ($mode !== 'validation') {
528
-		if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) {
529
-			$res = "<div id='spip-boucles'>\n"
530
-				. debusquer_navigation_squelettes($self)
531
-				. "</div>";
532
-		} else {
533
-			$res = '';
534
-		}
535
-		if ($fonc) {
536
-			$id = " id='$fonc'";
537
-			if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) {
538
-				list($legend, $texte, $res2) = debusquer_source($fonc, $mode);
539
-				$texte .= $res2;
540
-			} elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) {
541
-				$legend = _T('zbug_' . $mode);
542
-				$texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout'];
543
-				$texte = ancre_texte($texte, array('', ''));
544
-			}
545
-		} else {
546
-			if (strlen(trim($res))) {
547
-				return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>";
548
-			} else {
549
-				// cas de l'appel sur erreur: montre la page
550
-				return isset($GLOBALS['debug_objets']['resultat']['tout'])
551
-					? $GLOBALS['debug_objets']['resultat']['tout']
552
-					: '';
553
-			}
554
-		}
555
-	} else {
556
-		$valider = charger_fonction('valider', 'xml');
557
-		$val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']);
558
-		// Si erreur, signaler leur nombre dans le formulaire admin
559
-		$GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : '';
560
-		list($texte, $err) = emboite_texte($val, $fonc, $self);
561
-		if ($err === false) {
562
-			$err = _T('impossible');
563
-		} elseif ($err === true) {
564
-			$err = _T('correcte');
565
-		} else {
566
-			$err = ": $err";
567
-		}
568
-		$legend = _T('validation') . ' ' . $err;
569
-		$res = $id = '';
570
-	}
571
-
572
-	return !trim($texte) ? '' : (
573
-		"<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res"
574
-		. "<div id='debug_boucle'><fieldset$id><legend>"
575
-		. "<a href='" . $self . "#f_" . substr($fonc, 0, 37) . "'> &#8593; "
576
-		. ($legend ? $legend : $mode)
577
-		. "</a></legend>"
578
-		. $texte
579
-		. "</fieldset></div>"
580
-		. "</div>");
525
+    $texte = '';
526
+
527
+    if ($mode !== 'validation') {
528
+        if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) {
529
+            $res = "<div id='spip-boucles'>\n"
530
+                . debusquer_navigation_squelettes($self)
531
+                . "</div>";
532
+        } else {
533
+            $res = '';
534
+        }
535
+        if ($fonc) {
536
+            $id = " id='$fonc'";
537
+            if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) {
538
+                list($legend, $texte, $res2) = debusquer_source($fonc, $mode);
539
+                $texte .= $res2;
540
+            } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) {
541
+                $legend = _T('zbug_' . $mode);
542
+                $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout'];
543
+                $texte = ancre_texte($texte, array('', ''));
544
+            }
545
+        } else {
546
+            if (strlen(trim($res))) {
547
+                return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>";
548
+            } else {
549
+                // cas de l'appel sur erreur: montre la page
550
+                return isset($GLOBALS['debug_objets']['resultat']['tout'])
551
+                    ? $GLOBALS['debug_objets']['resultat']['tout']
552
+                    : '';
553
+            }
554
+        }
555
+    } else {
556
+        $valider = charger_fonction('valider', 'xml');
557
+        $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']);
558
+        // Si erreur, signaler leur nombre dans le formulaire admin
559
+        $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : '';
560
+        list($texte, $err) = emboite_texte($val, $fonc, $self);
561
+        if ($err === false) {
562
+            $err = _T('impossible');
563
+        } elseif ($err === true) {
564
+            $err = _T('correcte');
565
+        } else {
566
+            $err = ": $err";
567
+        }
568
+        $legend = _T('validation') . ' ' . $err;
569
+        $res = $id = '';
570
+    }
571
+
572
+    return !trim($texte) ? '' : (
573
+        "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res"
574
+        . "<div id='debug_boucle'><fieldset$id><legend>"
575
+        . "<a href='" . $self . "#f_" . substr($fonc, 0, 37) . "'> &#8593; "
576
+        . ($legend ? $legend : $mode)
577
+        . "</a></legend>"
578
+        . $texte
579
+        . "</fieldset></div>"
580
+        . "</div>");
581 581
 }
582 582
 
583 583
 
584 584
 // https://code.spip.net/@emboite_texte
585 585
 function emboite_texte($res, $fonc = '', $self = '') {
586
-	$errs = $res->err;
587
-	$texte = $res->entete . ($errs ? '' : $res->page);
588
-
589
-	if (!$texte and !$errs) {
590
-		return array(ancre_texte('', array('', '')), false);
591
-	}
592
-	if (!$errs) {
593
-		return array(ancre_texte($texte, array('', '')), true);
594
-	}
595
-
596
-	if (!isset($GLOBALS['debug_objets'])) {
597
-
598
-		$colors = array('#e0e0f0', '#f8f8ff');
599
-		$encore = count_occ($errs);
600
-		$encore2 = array();
601
-		$fautifs = array();
602
-
603
-		$err = '<tr><th>'
604
-			. _T('numero')
605
-			. "</th><th>"
606
-			. _T('occurence')
607
-			. "</th><th>"
608
-			. _T('ligne')
609
-			. "</th><th>"
610
-			. _T('colonne')
611
-			. "</th><th>"
612
-			. _T('erreur')
613
-			. "</th></tr>";
614
-
615
-		$i = 0;
616
-		$style = "style='text-align: right; padding-right: 5px'";
617
-		foreach ($errs as $r) {
618
-			$i++;
619
-			list($msg, $ligne, $col) = $r;
620
-			#spip_log("$r = list($msg, $ligne, $col");
621
-			if (isset($encore2[$msg])) {
622
-				$ref = ++$encore2[$msg];
623
-			} else {
624
-				$encore2[$msg] = $ref = 1;
625
-			}
626
-			$err .= "<tr  style='background-color: "
627
-				. $colors[$i % 2]
628
-				. "'><td $style><a href='#debut_err'>"
629
-				. $i
630
-				. "</a></td><td $style>"
631
-				. "$ref/$encore[$msg]</td>"
632
-				. "<td $style><a href='#L"
633
-				. $ligne
634
-				. "' id='T$i'>"
635
-				. $ligne
636
-				. "</a></td><td $style>"
637
-				. $col
638
-				. "</td><td>$msg</td></tr>\n";
639
-			$fautifs[] = array($ligne, $col, $i, $msg);
640
-		}
641
-		$err = "<h2 style='text-align: center'>"
642
-			. $i
643
-			. "<a href='#fin_err'>"
644
-			. " " . _T('erreur_texte')
645
-			. "</a></h2><table id='debut_err' style='width: 100%'>"
646
-			. $err
647
-			. " </table><a id='fin_err'></a>";
648
-
649
-		return array(ancre_texte($texte, $fautifs), $err);
650
-	} else {
651
-		list($msg, $fermant, $ouvrant) = $errs[0];
652
-		$rf = reference_boucle_debug($fermant, $fonc, $self);
653
-		$ro = reference_boucle_debug($ouvrant, $fonc, $self);
654
-		$err = $msg .
655
-			"<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" .
656
-			"<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro";
657
-
658
-		return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err);
659
-	}
586
+    $errs = $res->err;
587
+    $texte = $res->entete . ($errs ? '' : $res->page);
588
+
589
+    if (!$texte and !$errs) {
590
+        return array(ancre_texte('', array('', '')), false);
591
+    }
592
+    if (!$errs) {
593
+        return array(ancre_texte($texte, array('', '')), true);
594
+    }
595
+
596
+    if (!isset($GLOBALS['debug_objets'])) {
597
+
598
+        $colors = array('#e0e0f0', '#f8f8ff');
599
+        $encore = count_occ($errs);
600
+        $encore2 = array();
601
+        $fautifs = array();
602
+
603
+        $err = '<tr><th>'
604
+            . _T('numero')
605
+            . "</th><th>"
606
+            . _T('occurence')
607
+            . "</th><th>"
608
+            . _T('ligne')
609
+            . "</th><th>"
610
+            . _T('colonne')
611
+            . "</th><th>"
612
+            . _T('erreur')
613
+            . "</th></tr>";
614
+
615
+        $i = 0;
616
+        $style = "style='text-align: right; padding-right: 5px'";
617
+        foreach ($errs as $r) {
618
+            $i++;
619
+            list($msg, $ligne, $col) = $r;
620
+            #spip_log("$r = list($msg, $ligne, $col");
621
+            if (isset($encore2[$msg])) {
622
+                $ref = ++$encore2[$msg];
623
+            } else {
624
+                $encore2[$msg] = $ref = 1;
625
+            }
626
+            $err .= "<tr  style='background-color: "
627
+                . $colors[$i % 2]
628
+                . "'><td $style><a href='#debut_err'>"
629
+                . $i
630
+                . "</a></td><td $style>"
631
+                . "$ref/$encore[$msg]</td>"
632
+                . "<td $style><a href='#L"
633
+                . $ligne
634
+                . "' id='T$i'>"
635
+                . $ligne
636
+                . "</a></td><td $style>"
637
+                . $col
638
+                . "</td><td>$msg</td></tr>\n";
639
+            $fautifs[] = array($ligne, $col, $i, $msg);
640
+        }
641
+        $err = "<h2 style='text-align: center'>"
642
+            . $i
643
+            . "<a href='#fin_err'>"
644
+            . " " . _T('erreur_texte')
645
+            . "</a></h2><table id='debut_err' style='width: 100%'>"
646
+            . $err
647
+            . " </table><a id='fin_err'></a>";
648
+
649
+        return array(ancre_texte($texte, $fautifs), $err);
650
+    } else {
651
+        list($msg, $fermant, $ouvrant) = $errs[0];
652
+        $rf = reference_boucle_debug($fermant, $fonc, $self);
653
+        $ro = reference_boucle_debug($ouvrant, $fonc, $self);
654
+        $err = $msg .
655
+            "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" .
656
+            "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro";
657
+
658
+        return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err);
659
+    }
660 660
 }
661 661
 
662 662
 // https://code.spip.net/@count_occ
663 663
 function count_occ($regs) {
664
-	$encore = array();
665
-	foreach ($regs as $r) {
666
-		if (isset($encore[$r[0]])) {
667
-			$encore[$r[0]]++;
668
-		} else {
669
-			$encore[$r[0]] = 1;
670
-		}
671
-	}
672
-
673
-	return $encore;
664
+    $encore = array();
665
+    foreach ($regs as $r) {
666
+        if (isset($encore[$r[0]])) {
667
+            $encore[$r[0]]++;
668
+        } else {
669
+            $encore[$r[0]] = 1;
670
+        }
671
+    }
672
+
673
+    return $encore;
674 674
 }
675 675
 
676 676
 function debusquer_navigation_squelettes($self) {
677 677
 
678
-	$res = '';
679
-	$boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : '';
680
-	$contexte = $GLOBALS['debug_objets']['contexte'];
681
-	$t_skel = _T('squelette');
682
-	foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) {
683
-		$self2 = parametre_url($self, 'var_mode_objet', $nom);
684
-		$nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile);
685
-		$temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T('zbug_profile',
686
-			array('time' => $GLOBALS['debug_objets']['profile'][$sourcefile]));
687
-
688
-		$res .= "<fieldset id='f_" . $nom . "'><legend>"
689
-			. $t_skel
690
-			. ' '
691
-			. $sourcefile
692
-			. "&nbsp;:\n<a href='$self2&amp;var_mode_affiche=squelette#f_$nom'>"
693
-			. $t_skel
694
-			. "</a>\n<a href='$self2&amp;var_mode_affiche=resultat#f_$nom'>"
695
-			. _T('zbug_resultat')
696
-			. "</a>\n<a href='$self2&amp;var_mode_affiche=code#f_$nom'>"
697
-			. _T('zbug_code')
698
-			. "</a>\n<a href='"
699
-			. str_replace('var_mode=debug', 'var_profile=1&amp;var_mode=recalcul', $self)
700
-			. "'>"
701
-			. _T('zbug_calcul')
702
-			. "</a></legend>"
703
-			. (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />"))
704
-			. debusquer_contexte($contexte[$sourcefile])
705
-		. (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n"))
706
-		. "</fieldset>\n";
707
-	}
708
-
709
-	return $res;
678
+    $res = '';
679
+    $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : '';
680
+    $contexte = $GLOBALS['debug_objets']['contexte'];
681
+    $t_skel = _T('squelette');
682
+    foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) {
683
+        $self2 = parametre_url($self, 'var_mode_objet', $nom);
684
+        $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile);
685
+        $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T('zbug_profile',
686
+            array('time' => $GLOBALS['debug_objets']['profile'][$sourcefile]));
687
+
688
+        $res .= "<fieldset id='f_" . $nom . "'><legend>"
689
+            . $t_skel
690
+            . ' '
691
+            . $sourcefile
692
+            . "&nbsp;:\n<a href='$self2&amp;var_mode_affiche=squelette#f_$nom'>"
693
+            . $t_skel
694
+            . "</a>\n<a href='$self2&amp;var_mode_affiche=resultat#f_$nom'>"
695
+            . _T('zbug_resultat')
696
+            . "</a>\n<a href='$self2&amp;var_mode_affiche=code#f_$nom'>"
697
+            . _T('zbug_code')
698
+            . "</a>\n<a href='"
699
+            . str_replace('var_mode=debug', 'var_profile=1&amp;var_mode=recalcul', $self)
700
+            . "'>"
701
+            . _T('zbug_calcul')
702
+            . "</a></legend>"
703
+            . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />"))
704
+            . debusquer_contexte($contexte[$sourcefile])
705
+        . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n"))
706
+        . "</fieldset>\n";
707
+    }
708
+
709
+    return $res;
710 710
 }
711 711
 
712 712
 function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) {
713
-	$i = 0;
714
-	$res = '';
715
-	$var_mode_objet = _request('var_mode_objet');
716
-	$gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : '';
717
-
718
-	foreach ($boucles as $objet => $boucle) {
719
-		if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) {
720
-			$i++;
721
-			$nom = $boucle->id_boucle;
722
-			$req = $boucle->type_requete;
723
-			$crit = public_decompiler($boucle, $gram, 0, 'criteres');
724
-			$self2 = $self . "&amp;var_mode_objet=" . $objet;
725
-
726
-			$res .= "\n<tr style='background-color: " .
727
-				($i % 2 ? '#e0e0f0' : '#f8f8ff') .
728
-				"'><td  align='right'>$i</td><td>\n" .
729
-				"<a  class='debug_link_boucle' href='" .
730
-				$self2 .
731
-				"&amp;var_mode_affiche=boucle#f_$nom_skel'>" .
732
-				_T('zbug_boucle') .
733
-				"</a></td><td>\n<a class='debug_link_boucle' href='" .
734
-				$self2 .
735
-				"&amp;var_mode_affiche=resultat#f_$nom_skel'>" .
736
-				_T('zbug_resultat') .
737
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
738
-				$self2 .
739
-				"&amp;var_mode_affiche=code#f_$nom_skel'>" .
740
-				_T('zbug_code') .
741
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
742
-				str_replace('var_mode=', 'var_profile=', $self2) .
743
-				"'>" .
744
-				_T('zbug_calcul') .
745
-				"</a></td><td>\n" .
746
-				(($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) .
747
-				"</td><td>\n" .
748
-				$req .
749
-				"</td><td>\n" .
750
-				spip_htmlspecialchars($crit) .
751
-				"</td></tr>";
752
-		}
753
-	}
754
-
755
-	return $res;
713
+    $i = 0;
714
+    $res = '';
715
+    $var_mode_objet = _request('var_mode_objet');
716
+    $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : '';
717
+
718
+    foreach ($boucles as $objet => $boucle) {
719
+        if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) {
720
+            $i++;
721
+            $nom = $boucle->id_boucle;
722
+            $req = $boucle->type_requete;
723
+            $crit = public_decompiler($boucle, $gram, 0, 'criteres');
724
+            $self2 = $self . "&amp;var_mode_objet=" . $objet;
725
+
726
+            $res .= "\n<tr style='background-color: " .
727
+                ($i % 2 ? '#e0e0f0' : '#f8f8ff') .
728
+                "'><td  align='right'>$i</td><td>\n" .
729
+                "<a  class='debug_link_boucle' href='" .
730
+                $self2 .
731
+                "&amp;var_mode_affiche=boucle#f_$nom_skel'>" .
732
+                _T('zbug_boucle') .
733
+                "</a></td><td>\n<a class='debug_link_boucle' href='" .
734
+                $self2 .
735
+                "&amp;var_mode_affiche=resultat#f_$nom_skel'>" .
736
+                _T('zbug_resultat') .
737
+                "</a></td><td>\n<a class='debug_link_resultat' href='" .
738
+                $self2 .
739
+                "&amp;var_mode_affiche=code#f_$nom_skel'>" .
740
+                _T('zbug_code') .
741
+                "</a></td><td>\n<a class='debug_link_resultat' href='" .
742
+                str_replace('var_mode=', 'var_profile=', $self2) .
743
+                "'>" .
744
+                _T('zbug_calcul') .
745
+                "</a></td><td>\n" .
746
+                (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) .
747
+                "</td><td>\n" .
748
+                $req .
749
+                "</td><td>\n" .
750
+                spip_htmlspecialchars($crit) .
751
+                "</td></tr>";
752
+        }
753
+    }
754
+
755
+    return $res;
756 756
 }
757 757
 
758 758
 function debusquer_source($objet, $affiche) {
759
-	$quoi = $GLOBALS['debug_objets'][$affiche][$objet];
760
-	if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) {
761
-		$nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle;
762
-	} else {
763
-		$nom = $GLOBALS['debug_objets']['sourcefile'][$objet];
764
-	}
765
-	$res2 = "";
766
-
767
-	if ($affiche == 'resultat') {
768
-		$legend = $nom;
769
-		$req = $GLOBALS['debug_objets']['requete'][$objet];
770
-		if (function_exists('_mysql_traite_query')) {
771
-			$c = strtolower(_request('connect'));
772
-			$c = $GLOBALS['connexions'][$c ? $c : 0]['prefixe'];
773
-			$req = _mysql_traite_query($req, '', $c);
774
-		}
775
-		//  permettre le copier/coller facile
776
-		// $res = ancre_texte($req, array(), true);
777
-		$res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n";
778
-		//  formatage et affichage des resultats bruts de la requete
779
-		$ress_req = spip_query($req);
780
-		$brut_sql = '';
781
-		$num = 1;
782
-		//  eviter l'affichage de milliers de lignes
783
-		//  personnalisation possible dans mes_options
784
-		$max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50;
785
-		while ($retours_sql = sql_fetch($ress_req)) {
786
-			if ($num <= $max_aff) {
787
-				$brut_sql .= "<h3>" . ($num == 1 ? $num . " sur " . sql_count($ress_req) : $num) . "</h3>";
788
-				$brut_sql .= "<p>";
789
-				foreach ($retours_sql as $key => $val) {
790
-					$brut_sql .= "<strong>" . $key . "</strong> => " . spip_htmlspecialchars(couper($val, 150)) . "<br />\n";
791
-				}
792
-				$brut_sql .= "</p>";
793
-			}
794
-			$num++;
795
-		}
796
-		$res2 = interdire_scripts($brut_sql);
797
-		foreach ($quoi as $view) {
798
-			//  ne pas afficher les $contexte_inclus
799
-			$view = preg_replace(",<\?php.+\?[>],Uims", "", $view);
800
-			if ($view) {
801
-				$res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . "</fieldset>";
802
-			}
803
-		}
804
-
805
-	} elseif ($affiche == 'code') {
806
-		$legend = $nom;
807
-		$res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">");
808
-	} elseif ($affiche == 'boucle') {
809
-		$legend = _T('zbug_boucle') . ' ' . $nom;
810
-		// Le compilateur prefixe le nom des boucles par l'extension du fichier source.
811
-		$gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : '';
812
-		$res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle'));
813
-	} elseif ($affiche == 'squelette') {
814
-		$legend = $GLOBALS['debug_objets']['sourcefile'][$objet];
815
-		$res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]);
816
-	}
817
-
818
-	return array($legend, $res, $res2);
759
+    $quoi = $GLOBALS['debug_objets'][$affiche][$objet];
760
+    if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) {
761
+        $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle;
762
+    } else {
763
+        $nom = $GLOBALS['debug_objets']['sourcefile'][$objet];
764
+    }
765
+    $res2 = "";
766
+
767
+    if ($affiche == 'resultat') {
768
+        $legend = $nom;
769
+        $req = $GLOBALS['debug_objets']['requete'][$objet];
770
+        if (function_exists('_mysql_traite_query')) {
771
+            $c = strtolower(_request('connect'));
772
+            $c = $GLOBALS['connexions'][$c ? $c : 0]['prefixe'];
773
+            $req = _mysql_traite_query($req, '', $c);
774
+        }
775
+        //  permettre le copier/coller facile
776
+        // $res = ancre_texte($req, array(), true);
777
+        $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n";
778
+        //  formatage et affichage des resultats bruts de la requete
779
+        $ress_req = spip_query($req);
780
+        $brut_sql = '';
781
+        $num = 1;
782
+        //  eviter l'affichage de milliers de lignes
783
+        //  personnalisation possible dans mes_options
784
+        $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50;
785
+        while ($retours_sql = sql_fetch($ress_req)) {
786
+            if ($num <= $max_aff) {
787
+                $brut_sql .= "<h3>" . ($num == 1 ? $num . " sur " . sql_count($ress_req) : $num) . "</h3>";
788
+                $brut_sql .= "<p>";
789
+                foreach ($retours_sql as $key => $val) {
790
+                    $brut_sql .= "<strong>" . $key . "</strong> => " . spip_htmlspecialchars(couper($val, 150)) . "<br />\n";
791
+                }
792
+                $brut_sql .= "</p>";
793
+            }
794
+            $num++;
795
+        }
796
+        $res2 = interdire_scripts($brut_sql);
797
+        foreach ($quoi as $view) {
798
+            //  ne pas afficher les $contexte_inclus
799
+            $view = preg_replace(",<\?php.+\?[>],Uims", "", $view);
800
+            if ($view) {
801
+                $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . "</fieldset>";
802
+            }
803
+        }
804
+
805
+    } elseif ($affiche == 'code') {
806
+        $legend = $nom;
807
+        $res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">");
808
+    } elseif ($affiche == 'boucle') {
809
+        $legend = _T('zbug_boucle') . ' ' . $nom;
810
+        // Le compilateur prefixe le nom des boucles par l'extension du fichier source.
811
+        $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : '';
812
+        $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle'));
813
+    } elseif ($affiche == 'squelette') {
814
+        $legend = $GLOBALS['debug_objets']['sourcefile'][$objet];
815
+        $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]);
816
+    }
817
+
818
+    return array($legend, $res, $res2);
819 819
 }
820 820
 
821 821
 // https://code.spip.net/@debusquer_entete
822 822
 function debusquer_entete($titre, $corps) {
823 823
 
824
-	include_spip('balise/formulaire_admin');
825
-	include_spip('public/assembler'); // pour inclure_balise_dynamique
826
-	include_spip('inc/texte'); // pour corriger_typo
827
-
828
-	return _DOCTYPE_ECRIRE .
829
-	html_lang_attributes() .
830
-	"<head>\n<title>" .
831
-	('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' .
832
-		_T('admin_debug') . ' ' . $titre . ' (' .
833
-		supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) .
834
-	")</title>\n" .
835
-	"<meta http-equiv='Content-Type' content='text/html" .
836
-	(($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') .
837
-	"' />\n" .
838
-	http_script('', 'jquery.js')
839
-	. "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css'))
840
-	. "' type='text/css' />" .
841
-	"</head>\n" .
842
-	"<body style='margin:0 10px;'>\n" .
843
-	"<div id='spip-debug-header'>" .
844
-	$corps .
845
-	inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) .
846
-	'</div></body></html>';
824
+    include_spip('balise/formulaire_admin');
825
+    include_spip('public/assembler'); // pour inclure_balise_dynamique
826
+    include_spip('inc/texte'); // pour corriger_typo
827
+
828
+    return _DOCTYPE_ECRIRE .
829
+    html_lang_attributes() .
830
+    "<head>\n<title>" .
831
+    ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' .
832
+        _T('admin_debug') . ' ' . $titre . ' (' .
833
+        supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) .
834
+    ")</title>\n" .
835
+    "<meta http-equiv='Content-Type' content='text/html" .
836
+    (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') .
837
+    "' />\n" .
838
+    http_script('', 'jquery.js')
839
+    . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css'))
840
+    . "' type='text/css' />" .
841
+    "</head>\n" .
842
+    "<body style='margin:0 10px;'>\n" .
843
+    "<div id='spip-debug-header'>" .
844
+    $corps .
845
+    inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) .
846
+    '</div></body></html>';
847 847
 }
Please login to merge, or discard this patch.
Spacing   +86 added lines, -89 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		if (!$fonc) {
148 148
 			$fonc = $GLOBALS['debug_objets']['principal'];
149 149
 		}
150
-		$titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? " " . $GLOBALS['debug_objets']['sourcefile'][$fonc] : ""));
150
+		$titre = !$mode ? $fonc : ($mode.(isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? " ".$GLOBALS['debug_objets']['sourcefile'][$fonc] : ""));
151 151
 	}
152 152
 	if ($message === false) {
153 153
 		lang_select();
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	$fond = isset($GLOBALS['fond']) ? $GLOBALS['fond'] : "";
177 177
 	// une erreur critique sort $message en array
178 178
 	$debug = is_array($msg) ? $msg[1] : $msg;
179
-	spip_log("Debug: " . $debug . " (" . $fond . ")");
179
+	spip_log("Debug: ".$debug." (".$fond.")");
180 180
 
181 181
 	return $msg;
182 182
 }
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 function debusquer_bandeau($erreurs) {
185 185
 
186 186
 	if (!empty($erreurs)) {
187
-		$n = array(count($erreurs) . ' ' . _T('zbug_erreur_squelette'));
187
+		$n = array(count($erreurs).' '._T('zbug_erreur_squelette'));
188 188
 
189 189
 		return debusquer_navigation($erreurs, $n);
190 190
 	} elseif (!empty($GLOBALS['tableau_des_temps'])) {
@@ -217,25 +217,25 @@  discard block
 block discarded – undo
217 217
 			$valeur_simple = array();
218 218
 			foreach ($valeur as $v) {
219 219
 				if (is_array($v)) {
220
-					$valeur_simple[] = 'array:' . count($v);
220
+					$valeur_simple[] = 'array:'.count($v);
221 221
 				} elseif (is_object($v)) {
222 222
 					$valeur_simple[] = get_class($v);
223 223
 				} elseif (is_string($v)) {
224
-					$valeur_simple[] = "'" . $v . "'";
224
+					$valeur_simple[] = "'".$v."'";
225 225
 				} else {
226 226
 					$valeur_simple[] = $v;
227 227
 				}
228 228
 			}
229 229
 			$n = count($valeur);
230
-			$valeur = (($n > 3) ? 'array:' . $n . ' ' : '');
231
-			$valeur .= '[' . join(', ', $valeur_simple) . ']';
230
+			$valeur = (($n > 3) ? 'array:'.$n.' ' : '');
231
+			$valeur .= '['.join(', ', $valeur_simple).']';
232 232
 		} elseif (is_object($valeur)) {
233 233
 			$valeur = get_class($valeur);
234 234
 		} elseif (is_string($valeur)) {
235
-			$valeur = "'" . $valeur . "'";
235
+			$valeur = "'".$valeur."'";
236 236
 		}
237
-		$res .= "\n<tr><td><strong>" . nl2br(entites_html($nom))
238
-			. "</strong></td><td>:&nbsp;" . nl2br(entites_html($valeur))
237
+		$res .= "\n<tr><td><strong>".nl2br(entites_html($nom))
238
+			. "</strong></td><td>:&nbsp;".nl2br(entites_html($valeur))
239 239
 			. "</td></tr>\n";
240 240
 	}
241 241
 
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 				$nom_code = $lieu->descr['nom'];
264 264
 				$skel = $lieu->descr['sourcefile'];
265 265
 				$h2 = parametre_url($href, 'var_mode_objet', $nom_code);
266
-				$h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne;
266
+				$h3 = parametre_url($h2, 'var_mode_affiche', 'squelette').'#L'.$ligne;
267 267
 				$skel = "<a href='$h3'><b>$skel</b></a>";
268 268
 				if ($boucle) {
269
-					$h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle');
269
+					$h3 = parametre_url($h2.$boucle, 'var_mode_affiche', 'boucle');
270 270
 					$boucle = "<a href='$h3'><b>$boucle</b></a>";
271 271
 				}
272 272
 			}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 	}
354 354
 
355 355
 	// Requete erronee
356
-	$err = "<b>" . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n"
356
+	$err = "<b>"._T('avis_erreur_mysql')." $errno</b><br /><tt>\n"
357 357
 		. spip_htmlspecialchars($msg)
358 358
 		. "\n<br /><span style='color: red'><b>"
359 359
 		. spip_htmlspecialchars($query)
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 // https://code.spip.net/@trouve_boucle_debug
369 369
 function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = "") {
370 370
 
371
-	$id = $nom . $boucle;
371
+	$id = $nom.$boucle;
372 372
 	if (is_array($GLOBALS['debug_objets']['sequence'][$id])) {
373 373
 		foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) {
374 374
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 			}
420 420
 		}
421 421
 	}
422
-	$incl = ',' . $reg[1] . '[.]\w$,';
422
+	$incl = ','.$reg[1].'[.]\w$,';
423 423
 
424 424
 	foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) {
425 425
 		if (preg_match($incl, $v)) {
@@ -435,16 +435,13 @@  discard block
 block discarded – undo
435 435
 	list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom);
436 436
 
437 437
 	if (!$boucle) {
438
-		return !$ligne ? "" :
439
-			(" (" .
440
-				(($nom != $skel) ? _T('squelette_inclus_ligne') :
441
-					_T('squelette_ligne')) .
438
+		return !$ligne ? "" : (" (".
439
+				(($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')).
442 440
 				" <a href='$self&amp;var_mode_objet=$skel&amp;var_mode_affiche=squelette&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)");
443 441
 	} else {
444 442
 		$self .= "&amp;var_mode_objet=$skel$boucle&amp;var_mode_affiche=boucle";
445 443
 
446
-		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" :
447
-			" (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
444
+		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : " (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
448 445
 	}
449 446
 }
450 447
 
@@ -466,13 +463,13 @@  discard block
 block discarded – undo
466 463
 	}
467 464
 
468 465
 	$s = preg_replace(',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,',
469
-		'<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>',
466
+		'<\1>\2</\1><br />'."\n".'<\1>\3</\1>',
470 467
 		$s);
471 468
 
472 469
 
473 470
 	$tableau = explode("<br />", $s);
474 471
 
475
-	$format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n";
472
+	$format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: ".($nocpt ? 'hidden' : 'visible').";%s' href='#T%s' title=\"%s\">%0".strval(@strlen(count($tableau)))."d</a></span> %s<br />\n";
476 473
 
477 474
 	$format10 = str_replace('white', 'lightgrey', $format);
478 475
 	$formaterr = "color: red;";
@@ -516,7 +513,7 @@  discard block
 block discarded – undo
516 513
 	. '" style="cursor: pointer;">'
517 514
 	. ($nocpt ? '' : _T('info_numero_abbreviation'))
518 515
 	. "</div>
519
-	" . $res . "</div>\n";
516
+	" . $res."</div>\n";
520 517
 }
521 518
 
522 519
 // l'environnement graphique du debuggueur 
@@ -537,14 +534,14 @@  discard block
 block discarded – undo
537 534
 			if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) {
538 535
 				list($legend, $texte, $res2) = debusquer_source($fonc, $mode);
539 536
 				$texte .= $res2;
540
-			} elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) {
541
-				$legend = _T('zbug_' . $mode);
542
-				$texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout'];
537
+			} elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc.'tout'])) {
538
+				$legend = _T('zbug_'.$mode);
539
+				$texte = $GLOBALS['debug_objets'][$mode][$fonc.'tout'];
543 540
 				$texte = ancre_texte($texte, array('', ''));
544 541
 			}
545 542
 		} else {
546 543
 			if (strlen(trim($res))) {
547
-				return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>";
544
+				return "<img src='".chemin_image('debug-xx.svg')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>";
548 545
 			} else {
549 546
 				// cas de l'appel sur erreur: montre la page
550 547
 				return isset($GLOBALS['debug_objets']['resultat']['tout'])
@@ -554,7 +551,7 @@  discard block
 block discarded – undo
554 551
 		}
555 552
 	} else {
556 553
 		$valider = charger_fonction('valider', 'xml');
557
-		$val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']);
554
+		$val = $valider($GLOBALS['debug_objets']['validation'][$fonc.'tout']);
558 555
 		// Si erreur, signaler leur nombre dans le formulaire admin
559 556
 		$GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : '';
560 557
 		list($texte, $err) = emboite_texte($val, $fonc, $self);
@@ -565,14 +562,14 @@  discard block
 block discarded – undo
565 562
 		} else {
566 563
 			$err = ": $err";
567 564
 		}
568
-		$legend = _T('validation') . ' ' . $err;
565
+		$legend = _T('validation').' '.$err;
569 566
 		$res = $id = '';
570 567
 	}
571 568
 
572 569
 	return !trim($texte) ? '' : (
573
-		"<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res"
570
+		"<img src='".chemin_image('debug-xx.svg')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res"
574 571
 		. "<div id='debug_boucle'><fieldset$id><legend>"
575
-		. "<a href='" . $self . "#f_" . substr($fonc, 0, 37) . "'> &#8593; "
572
+		. "<a href='".$self."#f_".substr($fonc, 0, 37)."'> &#8593; "
576 573
 		. ($legend ? $legend : $mode)
577 574
 		. "</a></legend>"
578 575
 		. $texte
@@ -584,7 +581,7 @@  discard block
 block discarded – undo
584 581
 // https://code.spip.net/@emboite_texte
585 582
 function emboite_texte($res, $fonc = '', $self = '') {
586 583
 	$errs = $res->err;
587
-	$texte = $res->entete . ($errs ? '' : $res->page);
584
+	$texte = $res->entete.($errs ? '' : $res->page);
588 585
 
589 586
 	if (!$texte and !$errs) {
590 587
 		return array(ancre_texte('', array('', '')), false);
@@ -641,7 +638,7 @@  discard block
 block discarded – undo
641 638
 		$err = "<h2 style='text-align: center'>"
642 639
 			. $i
643 640
 			. "<a href='#fin_err'>"
644
-			. " " . _T('erreur_texte')
641
+			. " "._T('erreur_texte')
645 642
 			. "</a></h2><table id='debut_err' style='width: 100%'>"
646 643
 			. $err
647 644
 			. " </table><a id='fin_err'></a>";
@@ -651,9 +648,9 @@  discard block
 block discarded – undo
651 648
 		list($msg, $fermant, $ouvrant) = $errs[0];
652 649
 		$rf = reference_boucle_debug($fermant, $fonc, $self);
653 650
 		$ro = reference_boucle_debug($ouvrant, $fonc, $self);
654
-		$err = $msg .
655
-			"<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" .
656
-			"<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro";
651
+		$err = $msg.
652
+			"<a href='#L".$fermant."'>$fermant</a>$rf<br />".
653
+			"<a href='#L".$ouvrant."'>$ouvrant</a>$ro";
657 654
 
658 655
 		return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err);
659 656
 	}
@@ -685,7 +682,7 @@  discard block
 block discarded – undo
685 682
 		$temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T('zbug_profile',
686 683
 			array('time' => $GLOBALS['debug_objets']['profile'][$sourcefile]));
687 684
 
688
-		$res .= "<fieldset id='f_" . $nom . "'><legend>"
685
+		$res .= "<fieldset id='f_".$nom."'><legend>"
689 686
 			. $t_skel
690 687
 			. ' '
691 688
 			. $sourcefile
@@ -700,7 +697,7 @@  discard block
 block discarded – undo
700 697
 			. "'>"
701 698
 			. _T('zbug_calcul')
702 699
 			. "</a></legend>"
703
-			. (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />"))
700
+			. (!$temps ? '' : ("\n<span style='display:block;float:".$GLOBALS['spip_lang_right']."'>$temps</span><br />"))
704 701
 			. debusquer_contexte($contexte[$sourcefile])
705 702
 		. (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n"))
706 703
 		. "</fieldset>\n";
@@ -721,33 +718,33 @@  discard block
 block discarded – undo
721 718
 			$nom = $boucle->id_boucle;
722 719
 			$req = $boucle->type_requete;
723 720
 			$crit = public_decompiler($boucle, $gram, 0, 'criteres');
724
-			$self2 = $self . "&amp;var_mode_objet=" . $objet;
725
-
726
-			$res .= "\n<tr style='background-color: " .
727
-				($i % 2 ? '#e0e0f0' : '#f8f8ff') .
728
-				"'><td  align='right'>$i</td><td>\n" .
729
-				"<a  class='debug_link_boucle' href='" .
730
-				$self2 .
731
-				"&amp;var_mode_affiche=boucle#f_$nom_skel'>" .
732
-				_T('zbug_boucle') .
733
-				"</a></td><td>\n<a class='debug_link_boucle' href='" .
734
-				$self2 .
735
-				"&amp;var_mode_affiche=resultat#f_$nom_skel'>" .
736
-				_T('zbug_resultat') .
737
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
738
-				$self2 .
739
-				"&amp;var_mode_affiche=code#f_$nom_skel'>" .
740
-				_T('zbug_code') .
741
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
742
-				str_replace('var_mode=', 'var_profile=', $self2) .
743
-				"'>" .
744
-				_T('zbug_calcul') .
745
-				"</a></td><td>\n" .
746
-				(($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) .
747
-				"</td><td>\n" .
748
-				$req .
749
-				"</td><td>\n" .
750
-				spip_htmlspecialchars($crit) .
721
+			$self2 = $self."&amp;var_mode_objet=".$objet;
722
+
723
+			$res .= "\n<tr style='background-color: ".
724
+				($i % 2 ? '#e0e0f0' : '#f8f8ff').
725
+				"'><td  align='right'>$i</td><td>\n".
726
+				"<a  class='debug_link_boucle' href='".
727
+				$self2.
728
+				"&amp;var_mode_affiche=boucle#f_$nom_skel'>".
729
+				_T('zbug_boucle').
730
+				"</a></td><td>\n<a class='debug_link_boucle' href='".
731
+				$self2.
732
+				"&amp;var_mode_affiche=resultat#f_$nom_skel'>".
733
+				_T('zbug_resultat').
734
+				"</a></td><td>\n<a class='debug_link_resultat' href='".
735
+				$self2.
736
+				"&amp;var_mode_affiche=code#f_$nom_skel'>".
737
+				_T('zbug_code').
738
+				"</a></td><td>\n<a class='debug_link_resultat' href='".
739
+				str_replace('var_mode=', 'var_profile=', $self2).
740
+				"'>".
741
+				_T('zbug_calcul').
742
+				"</a></td><td>\n".
743
+				(($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom).
744
+				"</td><td>\n".
745
+				$req.
746
+				"</td><td>\n".
747
+				spip_htmlspecialchars($crit).
751 748
 				"</td></tr>";
752 749
 		}
753 750
 	}
@@ -774,7 +771,7 @@  discard block
 block discarded – undo
774 771
 		}
775 772
 		//  permettre le copier/coller facile
776 773
 		// $res = ancre_texte($req, array(), true);
777
-		$res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n";
774
+		$res = "<div id='T".md5($req)."'>\n<pre>\n".$req."</pre>\n</div>\n";
778 775
 		//  formatage et affichage des resultats bruts de la requete
779 776
 		$ress_req = spip_query($req);
780 777
 		$brut_sql = '';
@@ -784,10 +781,10 @@  discard block
 block discarded – undo
784 781
 		$max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50;
785 782
 		while ($retours_sql = sql_fetch($ress_req)) {
786 783
 			if ($num <= $max_aff) {
787
-				$brut_sql .= "<h3>" . ($num == 1 ? $num . " sur " . sql_count($ress_req) : $num) . "</h3>";
784
+				$brut_sql .= "<h3>".($num == 1 ? $num." sur ".sql_count($ress_req) : $num)."</h3>";
788 785
 				$brut_sql .= "<p>";
789 786
 				foreach ($retours_sql as $key => $val) {
790
-					$brut_sql .= "<strong>" . $key . "</strong> => " . spip_htmlspecialchars(couper($val, 150)) . "<br />\n";
787
+					$brut_sql .= "<strong>".$key."</strong> => ".spip_htmlspecialchars(couper($val, 150))."<br />\n";
791 788
 				}
792 789
 				$brut_sql .= "</p>";
793 790
 			}
@@ -798,15 +795,15 @@  discard block
 block discarded – undo
798 795
 			//  ne pas afficher les $contexte_inclus
799 796
 			$view = preg_replace(",<\?php.+\?[>],Uims", "", $view);
800 797
 			if ($view) {
801
-				$res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . "</fieldset>";
798
+				$res2 .= "\n<br /><fieldset>".interdire_scripts($view)."</fieldset>";
802 799
 			}
803 800
 		}
804 801
 
805 802
 	} elseif ($affiche == 'code') {
806 803
 		$legend = $nom;
807
-		$res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">");
804
+		$res = ancre_texte("<"."?php\n".$quoi."\n?".">");
808 805
 	} elseif ($affiche == 'boucle') {
809
-		$legend = _T('zbug_boucle') . ' ' . $nom;
806
+		$legend = _T('zbug_boucle').' '.$nom;
810 807
 		// Le compilateur prefixe le nom des boucles par l'extension du fichier source.
811 808
 		$gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : '';
812 809
 		$res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle'));
@@ -825,23 +822,23 @@  discard block
 block discarded – undo
825 822
 	include_spip('public/assembler'); // pour inclure_balise_dynamique
826 823
 	include_spip('inc/texte'); // pour corriger_typo
827 824
 
828
-	return _DOCTYPE_ECRIRE .
829
-	html_lang_attributes() .
830
-	"<head>\n<title>" .
831
-	('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' .
832
-		_T('admin_debug') . ' ' . $titre . ' (' .
833
-		supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) .
834
-	")</title>\n" .
835
-	"<meta http-equiv='Content-Type' content='text/html" .
836
-	(($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') .
837
-	"' />\n" .
825
+	return _DOCTYPE_ECRIRE.
826
+	html_lang_attributes().
827
+	"<head>\n<title>".
828
+	('SPIP '.$GLOBALS['spip_version_affichee'].' '.
829
+		_T('admin_debug').' '.$titre.' ('.
830
+		supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))).
831
+	")</title>\n".
832
+	"<meta http-equiv='Content-Type' content='text/html".
833
+	(($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '').
834
+	"' />\n".
838 835
 	http_script('', 'jquery.js')
839
-	. "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css'))
840
-	. "' type='text/css' />" .
841
-	"</head>\n" .
842
-	"<body style='margin:0 10px;'>\n" .
843
-	"<div id='spip-debug-header'>" .
844
-	$corps .
845
-	inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) .
836
+	. "<link rel='stylesheet' href='".url_absolue(find_in_path('spip_admin.css'))
837
+	. "' type='text/css' />".
838
+	"</head>\n".
839
+	"<body style='margin:0 10px;'>\n".
840
+	"<div id='spip-debug-header'>".
841
+	$corps.
842
+	inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false).
846 843
 	'</div></body></html>';
847 844
 }
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
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.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -11,126 +11,126 @@
 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($preaff, $avant, $nom, $type, $crit, $corps, $apres, $altern, $postaff, $prof) {
18
-	$preaff = $preaff ? "<BB$nom>$preaff" : "";
19
-	$avant = $avant ? "<B$nom>$avant" : "";
20
-	$apres = $apres ? "$apres</B$nom>" : "";
21
-	$altern = $altern ? "$altern<//B$nom>" : "";
22
-	$postaff = $postaff ? "$postaff</BB$nom>" : "";
23
-	if (!$corps) {
24
-		$corps = " />";
25
-	} else {
26
-		$corps = ">$corps</BOUCLE$nom>";
27
-	}
28
-
29
-	return "$preaff$avant<BOUCLE$nom($type)$crit$corps$apres$altern$postaff";
18
+    $preaff = $preaff ? "<BB$nom>$preaff" : "";
19
+    $avant = $avant ? "<B$nom>$avant" : "";
20
+    $apres = $apres ? "$apres</B$nom>" : "";
21
+    $altern = $altern ? "$altern<//B$nom>" : "";
22
+    $postaff = $postaff ? "$postaff</BB$nom>" : "";
23
+    if (!$corps) {
24
+        $corps = " />";
25
+    } else {
26
+        $corps = ">$corps</BOUCLE$nom>";
27
+    }
28
+
29
+    return "$preaff$avant<BOUCLE$nom($type)$crit$corps$apres$altern$postaff";
30 30
 }
31 31
 
32 32
 function format_inclure_html($file, $args, $prof) {
33
-	if (strpos($file, '#') === false) {
34
-		$t = $file ? ("(" . $file . ")") : "";
35
-	} else {
36
-		$t = "{fond=" . $file . '}';
37
-	}
38
-	$args = !$args ? '' : ("{" . join(", ", $args) . "}");
39
-
40
-	return ("<INCLURE" . $t . $args . ">");
33
+    if (strpos($file, '#') === false) {
34
+        $t = $file ? ("(" . $file . ")") : "";
35
+    } else {
36
+        $t = "{fond=" . $file . '}';
37
+    }
38
+    $args = !$args ? '' : ("{" . join(", ", $args) . "}");
39
+
40
+    return ("<INCLURE" . $t . $args . ">");
41 41
 }
42 42
 
43 43
 function format_polyglotte_html($args, $prof) {
44
-	$contenu = array();
45
-	foreach ($args as $l => $t) {
46
-		$contenu[] = ($l ? "[$l]" : '') . $t;
47
-	}
44
+    $contenu = array();
45
+    foreach ($args as $l => $t) {
46
+        $contenu[] = ($l ? "[$l]" : '') . $t;
47
+    }
48 48
 
49
-	return ("<multi>" . join(" ", $contenu) . "</multi>");
49
+    return ("<multi>" . join(" ", $contenu) . "</multi>");
50 50
 }
51 51
 
52 52
 function format_idiome_html($nom, $module, $args, $filtres, $prof) {
53
-	foreach ($args as $k => $v) {
54
-		$args[$k] = "$k=$v";
55
-	}
56
-	$args = (!$args ? '' : ('{' . join(',', $args) . '}'));
53
+    foreach ($args as $k => $v) {
54
+        $args[$k] = "$k=$v";
55
+    }
56
+    $args = (!$args ? '' : ('{' . join(',', $args) . '}'));
57 57
 
58
-	return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>");
58
+    return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>");
59 59
 }
60 60
 
61 61
 function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) {
62
-	$nom = "#"
63
-		. ($boucle ? ($boucle . ":") : "")
64
-		. $nom
65
-		. $etoile
66
-		. $args
67
-		. $filtres;
62
+    $nom = "#"
63
+        . ($boucle ? ($boucle . ":") : "")
64
+        . $nom
65
+        . $etoile
66
+        . $args
67
+        . $filtres;
68 68
 
69
-	// Determiner si c'est un champ etendu, 
69
+    // Determiner si c'est un champ etendu, 
70 70
 
71
-	$s = ($avant or $apres or $filtres
72
-		or (strpos($args, '(#') !== false));
71
+    $s = ($avant or $apres or $filtres
72
+        or (strpos($args, '(#') !== false));
73 73
 
74
-	return ($s ? "[$avant($nom)$apres]" : $nom);
74
+    return ($s ? "[$avant($nom)$apres]" : $nom);
75 75
 }
76 76
 
77 77
 function format_critere_html($critere) {
78
-	foreach ($critere as $k => $crit) {
79
-		$crit_s = '';
80
-		foreach ($crit as $operande) {
81
-			list($type, $valeur) = $operande;
82
-			if ($type == 'champ' and $valeur[0] == '[') {
83
-				$valeur = substr($valeur, 1, -1);
84
-				if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) {
85
-					$valeur = substr($valeur, 1, -1);
86
-				}
87
-			}
88
-			$crit_s .= $valeur;
89
-		}
90
-		$critere[$k] = $crit_s;
91
-	}
92
-
93
-	return (!$critere ? "" : ("{" . join(",", $critere) . "}"));
78
+    foreach ($critere as $k => $crit) {
79
+        $crit_s = '';
80
+        foreach ($crit as $operande) {
81
+            list($type, $valeur) = $operande;
82
+            if ($type == 'champ' and $valeur[0] == '[') {
83
+                $valeur = substr($valeur, 1, -1);
84
+                if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) {
85
+                    $valeur = substr($valeur, 1, -1);
86
+                }
87
+            }
88
+            $crit_s .= $valeur;
89
+        }
90
+        $critere[$k] = $crit_s;
91
+    }
92
+
93
+    return (!$critere ? "" : ("{" . join(",", $critere) . "}"));
94 94
 }
95 95
 
96 96
 function format_liste_html($fonc, $args, $prof) {
97
-	return ((($fonc !== '') ? "|$fonc" : $fonc)
98
-		. (!$args ? "" : ("{" . join(",", $args) . "}")));
97
+    return ((($fonc !== '') ? "|$fonc" : $fonc)
98
+        . (!$args ? "" : ("{" . join(",", $args) . "}")));
99 99
 }
100 100
 
101 101
 // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes
102 102
 function format_suite_html($args) {
103
-	for ($i = 0; $i < count($args) - 1; $i++) {
104
-		list($texte, $type) = $args[$i];
105
-		list($texte2, $type2) = $args[$i + 1];
106
-		if (!$texte or !$texte2) {
107
-			continue;
108
-		}
109
-		$c1 = substr($texte, -1);
110
-		if ($type2 !== 'texte') {
111
-			// si un texte se termine par ( et est suivi d'un champ
112
-			// ou assimiles, forcer la notation pleine
113
-			if ($c1 == '(' and substr($texte2, 0, 1) == '#') {
114
-				$args[$i + 1][0] = '[(' . $texte2 . ')]';
115
-			}
116
-		} else {
117
-			if ($type == 'texte') {
118
-				continue;
119
-			}
120
-			// si un champ ou assimiles est suivi d'un texte
121
-			// et si celui-ci commence par un caractere de champ
122
-			// forcer la notation pleine
123
-			if (($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|')
124
-				or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2))
125
-			) {
126
-				$args[$i][0] = '[(' . $texte . ')]';
127
-			}
128
-		}
129
-	}
130
-
131
-	return join("", array_map(function($arg) { return reset($arg); }, $args));
103
+    for ($i = 0; $i < count($args) - 1; $i++) {
104
+        list($texte, $type) = $args[$i];
105
+        list($texte2, $type2) = $args[$i + 1];
106
+        if (!$texte or !$texte2) {
107
+            continue;
108
+        }
109
+        $c1 = substr($texte, -1);
110
+        if ($type2 !== 'texte') {
111
+            // si un texte se termine par ( et est suivi d'un champ
112
+            // ou assimiles, forcer la notation pleine
113
+            if ($c1 == '(' and substr($texte2, 0, 1) == '#') {
114
+                $args[$i + 1][0] = '[(' . $texte2 . ')]';
115
+            }
116
+        } else {
117
+            if ($type == 'texte') {
118
+                continue;
119
+            }
120
+            // si un champ ou assimiles est suivi d'un texte
121
+            // et si celui-ci commence par un caractere de champ
122
+            // forcer la notation pleine
123
+            if (($c1 == '}' and substr(ltrim($texte2), 0, 1) == '|')
124
+                or (preg_match('/[\w\d_*]/', $c1) and preg_match('/^[\w\d_*{|]/', $texte2))
125
+            ) {
126
+                $args[$i][0] = '[(' . $texte . ')]';
127
+            }
128
+        }
129
+    }
130
+
131
+    return join("", array_map(function($arg) { return reset($arg); }, $args));
132 132
 }
133 133
 
134 134
 function format_texte_html($texte) {
135
-	return $texte;
135
+    return $texte;
136 136
 }
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.