Completed
Push — master ( cc9c6b...2841c8 )
by cam
01:28
created
ecrire/xml/valider.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 							. $pere
62 62
 							. '</b>'
63 63
 							. (!$bons_peres ? ''
64
-								: ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
64
+								: ('<p style="font-size: 80%"> '._T('zxml_mais_de').' <b>'.$bons_peres.'</b></p>')));
65 65
 					} elseif ($this->dtc->regles[$pere][0] == '/') {
66 66
 						$frat = substr($depth, 2);
67 67
 						if (!isset($this->fratrie[$frat])) {
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		if (!isset($a[$name])) {
99 99
 			$bons = join(', ', array_keys($a));
100 100
 			if ($bons) {
101
-				$bons = " title=' " .
102
-					_T('zxml_connus_attributs') .
103
-					'&nbsp;: ' .
104
-					$bons .
101
+				$bons = " title=' ".
102
+					_T('zxml_connus_attributs').
103
+					'&nbsp;: '.
104
+					$bons.
105 105
 					"'";
106 106
 			}
107 107
 			$bons .= " style='font-weight: bold'";
108 108
 			coordonnees_erreur($this, " <b>$name</b> "
109
-				. _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
109
+				. _T('zxml_inconnu_attribut').' '._T('zxml_de')
110 110
 				. " <a$bons>$bal</a> ("
111 111
 				. _T('zxml_survoler')
112 112
 				. ')');
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 			if (!preg_match('/^\w+$/', $type)) {
116 116
 				$this->valider_motif($phraseur, $name, $val, $bal, $type);
117 117
 			} else {
118
-				if (method_exists($this, $f = 'validerAttribut_' . $type)) {
118
+				if (method_exists($this, $f = 'validerAttribut_'.$type)) {
119 119
 					$this->$f($phraseur, $name, $val, $bal);
120 120
 				}
121 121
 			}
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 				. " <b>$bal</b> "
165 165
 				. _T('zxml_non_conforme')
166 166
 				. '</p><p>'
167
-				. '<b>' . $motif . '</b>');
167
+				. '<b>'.$motif.'</b>');
168 168
 		}
169 169
 	}
170 170
 
171 171
 	public function valider_idref($nom, $ligne, $col) {
172 172
 		if (!isset($this->ids[$nom])) {
173
-			$this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
173
+			$this->err[] = [" <p><b>$nom</b> "._T('zxml_inconnu_id'), $ligne, $col];
174 174
 		}
175 175
 	}
176 176
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		// controler que les balises devant etre vides le sont
218 218
 		if ($vide) {
219 219
 			if ($n <> ($k + $c)) {
220
-				coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
220
+				coordonnees_erreur($this, " <p><b>$name</b> "._T('zxml_nonvide_balise'));
221 221
 			}
222 222
 			// pour les regles PCDATA ou iteration de disjonction, tout est fait
223 223
 		} elseif ($regle and ($regle != '*')) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$d = $this->ouvrant[$d];
253 253
 			preg_match('/^\s*(\S+)/', $d, $m);
254 254
 			if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
255
-				coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
255
+				coordonnees_erreur($this, ' <p><b>'.$m[1].'</b> '
256 256
 					. _T('zxml_nonvide_balise')); // message a affiner
257 257
 			}
258 258
 		}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	public function phraserTout($phraseur, $data) {
297 297
 		xml_parsestring($this, $data);
298 298
 
299
-		if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
299
+		if (!$this->dtc or preg_match(',^'._MESSAGE_DOCTYPE.',', $data)) {
300 300
 			$this->err[] = ['DOCTYPE ?', 0, 0];
301 301
 		} else {
302 302
 			$this->valider_passe2();
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 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
 /**
@@ -23,322 +23,322 @@  discard block
 block discarded – undo
23 23
  **/
24 24
 class ValidateurXML
25 25
 {
26
-	public function validerElement($phraseur, $name, $attrs) {
27
-		if (!($p = isset($this->dtc->elements[$name]))) {
28
-			if ($p = strpos($name, ':')) {
29
-				$name = substr($name, $p + 1);
30
-				$p = isset($this->dtc->elements[$name]);
31
-			}
32
-			if (!$p) {
33
-				coordonnees_erreur($this, " <b>$name</b>&nbsp;: "
34
-					. _T('zxml_inconnu_balise'));
35
-
36
-				return;
37
-			}
38
-		}
39
-		// controler les filles illegitimes, ca suffit
40
-		$depth = $this->depth;
41
-		$ouvrant = $this->ouvrant;
42
-		#spip_log("trouve $name apres " . $ouvrant[$depth]);
43
-		if (isset($ouvrant[$depth])) {
44
-			if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
45
-				$pere = $r[1];
46
-				#spip_log("pere $pere");
47
-				if (isset($this->dtc->elements[$pere])) {
48
-					$fils = $this->dtc->elements[$pere];
49
-					#spip_log("rejeton $name fils " . @join(',',$fils));
50
-					if (!($p = @in_array($name, $fils))) {
51
-						if ($p = strpos($name, ':')) {
52
-							$p = substr($name, $p + 1);
53
-							$p = @in_array($p, $fils);
54
-						}
55
-					}
56
-					if (!$p) {
57
-						$bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]);
58
-						coordonnees_erreur($this, " <b>$name</b> "
59
-							. _T('zxml_non_fils')
60
-							. ' <b>'
61
-							. $pere
62
-							. '</b>'
63
-							. (!$bons_peres ? ''
64
-								: ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
65
-					} elseif ($this->dtc->regles[$pere][0] == '/') {
66
-						$frat = substr($depth, 2);
67
-						if (!isset($this->fratrie[$frat])) {
68
-							$this->fratrie[$frat] = '';
69
-						}
70
-						$this->fratrie[$frat] .= "$name ";
71
-					}
72
-				}
73
-			}
74
-		}
75
-		// Init de la suite des balises a memoriser si regle difficile
76
-		if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') {
77
-			$this->fratrie[$depth] = '';
78
-		}
79
-		if (isset($this->dtc->attributs[$name])) {
80
-			foreach ($this->dtc->attributs[$name] as $n => $v) {
81
-				if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) {
82
-					coordonnees_erreur($this, " <b>$n</b>"
83
-						. '&nbsp;:&nbsp;'
84
-						. _T('zxml_obligatoire_attribut')
85
-						. " <b>$name</b>");
86
-				}
87
-			}
88
-		}
89
-	}
90
-
91
-	public function validerAttribut($phraseur, $name, $val, $bal) {
92
-		// Si la balise est inconnue, eviter d'insister
93
-		if (!isset($this->dtc->attributs[$bal])) {
94
-			return;
95
-		}
96
-
97
-		$a = $this->dtc->attributs[$bal];
98
-		if (!isset($a[$name])) {
99
-			$bons = join(', ', array_keys($a));
100
-			if ($bons) {
101
-				$bons = " title=' " .
102
-					_T('zxml_connus_attributs') .
103
-					'&nbsp;: ' .
104
-					$bons .
105
-					"'";
106
-			}
107
-			$bons .= " style='font-weight: bold'";
108
-			coordonnees_erreur($this, " <b>$name</b> "
109
-				. _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
110
-				. " <a$bons>$bal</a> ("
111
-				. _T('zxml_survoler')
112
-				. ')');
113
-		} else {
114
-			$type = $a[$name][0];
115
-			if (!preg_match('/^\w+$/', $type)) {
116
-				$this->valider_motif($phraseur, $name, $val, $bal, $type);
117
-			} else {
118
-				if (method_exists($this, $f = 'validerAttribut_' . $type)) {
119
-					$this->$f($phraseur, $name, $val, $bal);
120
-				}
121
-			}
122
-			#		else spip_log("$type type d'attribut inconnu");
123
-		}
124
-	}
125
-
126
-	public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) {
127
-		$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN);
128
-	}
129
-
130
-	public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) {
131
-		$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS);
132
-	}
133
-
134
-	public function validerAttribut_ID($phraseur, $name, $val, $bal) {
135
-		if (isset($this->ids[$val])) {
136
-			[$l, $c] = $this->ids[$val];
137
-			coordonnees_erreur($this, " <p><b>$val</b> "
138
-				. _T('zxml_valeur_attribut')
139
-				. " <b>$name</b> "
140
-				. _T('zxml_de')
141
-				. " <b>$bal</b> "
142
-				. _T('zxml_vu')
143
-				. " (L$l,C$c)");
144
-		} else {
145
-			$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID);
146
-			$this->ids[$val] = [xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
147
-		}
148
-	}
149
-
150
-	public function validerAttribut_IDREF($phraseur, $name, $val, $bal) {
151
-		$this->idrefs[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
152
-	}
153
-
154
-	public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) {
155
-		$this->idrefss[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
156
-	}
157
-
158
-	public function valider_motif($phraseur, $name, $val, $bal, $motif) {
159
-		if (!preg_match($motif, $val)) {
160
-			coordonnees_erreur($this, "<b>$val</b> "
161
-				. _T('zxml_valeur_attribut')
162
-				. " <b>$name</b> "
163
-				. _T('zxml_de')
164
-				. " <b>$bal</b> "
165
-				. _T('zxml_non_conforme')
166
-				. '</p><p>'
167
-				. '<b>' . $motif . '</b>');
168
-		}
169
-	}
170
-
171
-	public function valider_idref($nom, $ligne, $col) {
172
-		if (!isset($this->ids[$nom])) {
173
-			$this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
174
-		}
175
-	}
176
-
177
-	public function valider_passe2() {
178
-		if (!$this->err) {
179
-			foreach ($this->idrefs as $idref) {
180
-				[$nom, $ligne, $col] = $idref;
181
-				$this->valider_idref($nom, $ligne, $col);
182
-			}
183
-			foreach ($this->idrefss as $idref) {
184
-				[$noms, $ligne, $col] = $idref;
185
-				foreach (preg_split('/\s+/', $noms) as $nom) {
186
-					$this->valider_idref($nom, $ligne, $col);
187
-				}
188
-			}
189
-		}
190
-	}
191
-
192
-	public function debutElement($phraseur, $name, $attrs) {
193
-		if ($this->dtc->elements) {
194
-			$this->validerElement($phraseur, $name, $attrs);
195
-		}
196
-
197
-		if ($f = $this->process['debut']) {
198
-			$f($this, $name, $attrs);
199
-		}
200
-		$depth = $this->depth;
201
-		$this->debuts[$depth] = strlen($this->res);
202
-		foreach ($attrs as $k => $v) {
203
-			$this->validerAttribut($phraseur, $k, $v, $name);
204
-		}
205
-	}
206
-
207
-	public function finElement($phraseur, $name) {
208
-		$depth = $this->depth;
209
-		$contenu = $this->contenu;
210
-
211
-		$n = strlen($this->res);
212
-		$c = strlen(trim($contenu[$depth]));
213
-		$k = $this->debuts[$depth];
214
-
215
-		$regle = $this->dtc->regles[$name] ?? false;
216
-		$vide = ($regle == 'EMPTY');
217
-		// controler que les balises devant etre vides le sont
218
-		if ($vide) {
219
-			if ($n <> ($k + $c)) {
220
-				coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
221
-			}
222
-			// pour les regles PCDATA ou iteration de disjonction, tout est fait
223
-		} elseif ($regle and ($regle != '*')) {
224
-			if ($regle == '+') {
225
-				// iteration de disjonction non vide: 1 balise au -
226
-				if ($n == $k) {
227
-					coordonnees_erreur($this, "<p>\n<b>$name</b> "
228
-						. _T('zxml_vide_balise'));
229
-				}
230
-			} else {
231
-				$f = $this->fratrie[substr($depth, 2)] ?? null;
232
-				if (is_null($f) or !preg_match($regle, $f)) {
233
-					coordonnees_erreur(
234
-						$this,
235
-						" <p>\n<b>$name</b> "
236
-						. _T('zxml_succession_fils_incorrecte')
237
-						. '&nbsp;: <b>'
238
-						. $f
239
-						. '</b>'
240
-					);
241
-				}
242
-			}
243
-		}
244
-		if ($f = $this->process['fin']) {
245
-			$f($this, $name, $vide);
246
-		}
247
-	}
248
-
249
-	public function textElement($phraseur, $data) {
250
-		if (trim($data)) {
251
-			$d = $this->depth;
252
-			$d = $this->ouvrant[$d];
253
-			preg_match('/^\s*(\S+)/', $d, $m);
254
-			if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
255
-				coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
256
-					. _T('zxml_nonvide_balise')); // message a affiner
257
-			}
258
-		}
259
-		if ($f = $this->process['text']) {
260
-			$f($this, $data);
261
-		}
262
-	}
263
-
264
-	public function piElement($phraseur, $target, $data) {
265
-		if ($f = $this->process['pi']) {
266
-			$f($this, $target, $data);
267
-		}
268
-	}
269
-
270
-	// Denonciation des entitees XML inconnues
271
-	// Pour contourner le bug de conception de SAX qui ne signale pas si elles
272
-	// sont dans un attribut, les  entites les plus frequentes ont ete
273
-	// transcodees au prealable  (sauf & < > " que SAX traite correctement).
274
-	// On ne les verra donc pas passer a cette etape, contrairement a ce que
275
-	// le source de la page laisse legitimement supposer.
276
-
277
-	public function defaultElement($phraseur, $data) {
278
-		if (
279
-			!preg_match('/^<!--/', $data)
280
-			and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))
281
-		) {
282
-			foreach ($r as $m) {
283
-				[$t, $e] = $m;
284
-				if (!isset($this->dtc->entites[$e])) {
285
-					coordonnees_erreur($this, " <b>$e</b> "
286
-						. _T('zxml_inconnu_entite')
287
-						. ' ');
288
-				}
289
-			}
290
-		}
291
-		if (isset($this->process['default']) and ($f = $this->process['default'])) {
292
-			$f($this, $data);
293
-		}
294
-	}
295
-
296
-	public function phraserTout($phraseur, $data) {
297
-		xml_parsestring($this, $data);
298
-
299
-		if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
300
-			$this->err[] = ['DOCTYPE ?', 0, 0];
301
-		} else {
302
-			$this->valider_passe2();
303
-		}
304
-	}
305
-
306
-	/**
307
-	 * Constructeur
308
-	 *
309
-	 * @param array $process ?
310
-	 **/
311
-	public function __construct($process = []) {
312
-		if (is_array($process)) {
313
-			$this->process = $process;
314
-		}
315
-	}
316
-
317
-	public $ids = [];
318
-	public $idrefs = [];
319
-	public $idrefss = [];
320
-	public $debuts = [];
321
-	public $fratrie = [];
322
-
323
-	public $dtc = null;
324
-	public $sax = null;
325
-	public $depth = '';
326
-	public $entete = '';
327
-	public $page = '';
328
-	public $res = '';
329
-	public array $err = [];
330
-	public array $contenu = [];
331
-	public array $versions = [];
332
-
333
-	public array $ouvrant = [];
334
-	public array $reperes = [];
335
-	public array $process = [
336
-		'debut' => 'xml_debutElement',
337
-		'fin' => 'xml_finElement',
338
-		'text' => 'xml_textElement',
339
-		'pi' => 'xml_piElement',
340
-		'default' => 'xml_defaultElement'
341
-	];
26
+    public function validerElement($phraseur, $name, $attrs) {
27
+        if (!($p = isset($this->dtc->elements[$name]))) {
28
+            if ($p = strpos($name, ':')) {
29
+                $name = substr($name, $p + 1);
30
+                $p = isset($this->dtc->elements[$name]);
31
+            }
32
+            if (!$p) {
33
+                coordonnees_erreur($this, " <b>$name</b>&nbsp;: "
34
+                    . _T('zxml_inconnu_balise'));
35
+
36
+                return;
37
+            }
38
+        }
39
+        // controler les filles illegitimes, ca suffit
40
+        $depth = $this->depth;
41
+        $ouvrant = $this->ouvrant;
42
+        #spip_log("trouve $name apres " . $ouvrant[$depth]);
43
+        if (isset($ouvrant[$depth])) {
44
+            if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
45
+                $pere = $r[1];
46
+                #spip_log("pere $pere");
47
+                if (isset($this->dtc->elements[$pere])) {
48
+                    $fils = $this->dtc->elements[$pere];
49
+                    #spip_log("rejeton $name fils " . @join(',',$fils));
50
+                    if (!($p = @in_array($name, $fils))) {
51
+                        if ($p = strpos($name, ':')) {
52
+                            $p = substr($name, $p + 1);
53
+                            $p = @in_array($p, $fils);
54
+                        }
55
+                    }
56
+                    if (!$p) {
57
+                        $bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]);
58
+                        coordonnees_erreur($this, " <b>$name</b> "
59
+                            . _T('zxml_non_fils')
60
+                            . ' <b>'
61
+                            . $pere
62
+                            . '</b>'
63
+                            . (!$bons_peres ? ''
64
+                                : ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
65
+                    } elseif ($this->dtc->regles[$pere][0] == '/') {
66
+                        $frat = substr($depth, 2);
67
+                        if (!isset($this->fratrie[$frat])) {
68
+                            $this->fratrie[$frat] = '';
69
+                        }
70
+                        $this->fratrie[$frat] .= "$name ";
71
+                    }
72
+                }
73
+            }
74
+        }
75
+        // Init de la suite des balises a memoriser si regle difficile
76
+        if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') {
77
+            $this->fratrie[$depth] = '';
78
+        }
79
+        if (isset($this->dtc->attributs[$name])) {
80
+            foreach ($this->dtc->attributs[$name] as $n => $v) {
81
+                if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) {
82
+                    coordonnees_erreur($this, " <b>$n</b>"
83
+                        . '&nbsp;:&nbsp;'
84
+                        . _T('zxml_obligatoire_attribut')
85
+                        . " <b>$name</b>");
86
+                }
87
+            }
88
+        }
89
+    }
90
+
91
+    public function validerAttribut($phraseur, $name, $val, $bal) {
92
+        // Si la balise est inconnue, eviter d'insister
93
+        if (!isset($this->dtc->attributs[$bal])) {
94
+            return;
95
+        }
96
+
97
+        $a = $this->dtc->attributs[$bal];
98
+        if (!isset($a[$name])) {
99
+            $bons = join(', ', array_keys($a));
100
+            if ($bons) {
101
+                $bons = " title=' " .
102
+                    _T('zxml_connus_attributs') .
103
+                    '&nbsp;: ' .
104
+                    $bons .
105
+                    "'";
106
+            }
107
+            $bons .= " style='font-weight: bold'";
108
+            coordonnees_erreur($this, " <b>$name</b> "
109
+                . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
110
+                . " <a$bons>$bal</a> ("
111
+                . _T('zxml_survoler')
112
+                . ')');
113
+        } else {
114
+            $type = $a[$name][0];
115
+            if (!preg_match('/^\w+$/', $type)) {
116
+                $this->valider_motif($phraseur, $name, $val, $bal, $type);
117
+            } else {
118
+                if (method_exists($this, $f = 'validerAttribut_' . $type)) {
119
+                    $this->$f($phraseur, $name, $val, $bal);
120
+                }
121
+            }
122
+            #		else spip_log("$type type d'attribut inconnu");
123
+        }
124
+    }
125
+
126
+    public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) {
127
+        $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN);
128
+    }
129
+
130
+    public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) {
131
+        $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS);
132
+    }
133
+
134
+    public function validerAttribut_ID($phraseur, $name, $val, $bal) {
135
+        if (isset($this->ids[$val])) {
136
+            [$l, $c] = $this->ids[$val];
137
+            coordonnees_erreur($this, " <p><b>$val</b> "
138
+                . _T('zxml_valeur_attribut')
139
+                . " <b>$name</b> "
140
+                . _T('zxml_de')
141
+                . " <b>$bal</b> "
142
+                . _T('zxml_vu')
143
+                . " (L$l,C$c)");
144
+        } else {
145
+            $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID);
146
+            $this->ids[$val] = [xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
147
+        }
148
+    }
149
+
150
+    public function validerAttribut_IDREF($phraseur, $name, $val, $bal) {
151
+        $this->idrefs[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
152
+    }
153
+
154
+    public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) {
155
+        $this->idrefss[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
156
+    }
157
+
158
+    public function valider_motif($phraseur, $name, $val, $bal, $motif) {
159
+        if (!preg_match($motif, $val)) {
160
+            coordonnees_erreur($this, "<b>$val</b> "
161
+                . _T('zxml_valeur_attribut')
162
+                . " <b>$name</b> "
163
+                . _T('zxml_de')
164
+                . " <b>$bal</b> "
165
+                . _T('zxml_non_conforme')
166
+                . '</p><p>'
167
+                . '<b>' . $motif . '</b>');
168
+        }
169
+    }
170
+
171
+    public function valider_idref($nom, $ligne, $col) {
172
+        if (!isset($this->ids[$nom])) {
173
+            $this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
174
+        }
175
+    }
176
+
177
+    public function valider_passe2() {
178
+        if (!$this->err) {
179
+            foreach ($this->idrefs as $idref) {
180
+                [$nom, $ligne, $col] = $idref;
181
+                $this->valider_idref($nom, $ligne, $col);
182
+            }
183
+            foreach ($this->idrefss as $idref) {
184
+                [$noms, $ligne, $col] = $idref;
185
+                foreach (preg_split('/\s+/', $noms) as $nom) {
186
+                    $this->valider_idref($nom, $ligne, $col);
187
+                }
188
+            }
189
+        }
190
+    }
191
+
192
+    public function debutElement($phraseur, $name, $attrs) {
193
+        if ($this->dtc->elements) {
194
+            $this->validerElement($phraseur, $name, $attrs);
195
+        }
196
+
197
+        if ($f = $this->process['debut']) {
198
+            $f($this, $name, $attrs);
199
+        }
200
+        $depth = $this->depth;
201
+        $this->debuts[$depth] = strlen($this->res);
202
+        foreach ($attrs as $k => $v) {
203
+            $this->validerAttribut($phraseur, $k, $v, $name);
204
+        }
205
+    }
206
+
207
+    public function finElement($phraseur, $name) {
208
+        $depth = $this->depth;
209
+        $contenu = $this->contenu;
210
+
211
+        $n = strlen($this->res);
212
+        $c = strlen(trim($contenu[$depth]));
213
+        $k = $this->debuts[$depth];
214
+
215
+        $regle = $this->dtc->regles[$name] ?? false;
216
+        $vide = ($regle == 'EMPTY');
217
+        // controler que les balises devant etre vides le sont
218
+        if ($vide) {
219
+            if ($n <> ($k + $c)) {
220
+                coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
221
+            }
222
+            // pour les regles PCDATA ou iteration de disjonction, tout est fait
223
+        } elseif ($regle and ($regle != '*')) {
224
+            if ($regle == '+') {
225
+                // iteration de disjonction non vide: 1 balise au -
226
+                if ($n == $k) {
227
+                    coordonnees_erreur($this, "<p>\n<b>$name</b> "
228
+                        . _T('zxml_vide_balise'));
229
+                }
230
+            } else {
231
+                $f = $this->fratrie[substr($depth, 2)] ?? null;
232
+                if (is_null($f) or !preg_match($regle, $f)) {
233
+                    coordonnees_erreur(
234
+                        $this,
235
+                        " <p>\n<b>$name</b> "
236
+                        . _T('zxml_succession_fils_incorrecte')
237
+                        . '&nbsp;: <b>'
238
+                        . $f
239
+                        . '</b>'
240
+                    );
241
+                }
242
+            }
243
+        }
244
+        if ($f = $this->process['fin']) {
245
+            $f($this, $name, $vide);
246
+        }
247
+    }
248
+
249
+    public function textElement($phraseur, $data) {
250
+        if (trim($data)) {
251
+            $d = $this->depth;
252
+            $d = $this->ouvrant[$d];
253
+            preg_match('/^\s*(\S+)/', $d, $m);
254
+            if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
255
+                coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
256
+                    . _T('zxml_nonvide_balise')); // message a affiner
257
+            }
258
+        }
259
+        if ($f = $this->process['text']) {
260
+            $f($this, $data);
261
+        }
262
+    }
263
+
264
+    public function piElement($phraseur, $target, $data) {
265
+        if ($f = $this->process['pi']) {
266
+            $f($this, $target, $data);
267
+        }
268
+    }
269
+
270
+    // Denonciation des entitees XML inconnues
271
+    // Pour contourner le bug de conception de SAX qui ne signale pas si elles
272
+    // sont dans un attribut, les  entites les plus frequentes ont ete
273
+    // transcodees au prealable  (sauf & < > " que SAX traite correctement).
274
+    // On ne les verra donc pas passer a cette etape, contrairement a ce que
275
+    // le source de la page laisse legitimement supposer.
276
+
277
+    public function defaultElement($phraseur, $data) {
278
+        if (
279
+            !preg_match('/^<!--/', $data)
280
+            and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))
281
+        ) {
282
+            foreach ($r as $m) {
283
+                [$t, $e] = $m;
284
+                if (!isset($this->dtc->entites[$e])) {
285
+                    coordonnees_erreur($this, " <b>$e</b> "
286
+                        . _T('zxml_inconnu_entite')
287
+                        . ' ');
288
+                }
289
+            }
290
+        }
291
+        if (isset($this->process['default']) and ($f = $this->process['default'])) {
292
+            $f($this, $data);
293
+        }
294
+    }
295
+
296
+    public function phraserTout($phraseur, $data) {
297
+        xml_parsestring($this, $data);
298
+
299
+        if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
300
+            $this->err[] = ['DOCTYPE ?', 0, 0];
301
+        } else {
302
+            $this->valider_passe2();
303
+        }
304
+    }
305
+
306
+    /**
307
+     * Constructeur
308
+     *
309
+     * @param array $process ?
310
+     **/
311
+    public function __construct($process = []) {
312
+        if (is_array($process)) {
313
+            $this->process = $process;
314
+        }
315
+    }
316
+
317
+    public $ids = [];
318
+    public $idrefs = [];
319
+    public $idrefss = [];
320
+    public $debuts = [];
321
+    public $fratrie = [];
322
+
323
+    public $dtc = null;
324
+    public $sax = null;
325
+    public $depth = '';
326
+    public $entete = '';
327
+    public $page = '';
328
+    public $res = '';
329
+    public array $err = [];
330
+    public array $contenu = [];
331
+    public array $versions = [];
332
+
333
+    public array $ouvrant = [];
334
+    public array $reperes = [];
335
+    public array $process = [
336
+        'debut' => 'xml_debutElement',
337
+        'fin' => 'xml_finElement',
338
+        'text' => 'xml_textElement',
339
+        'pi' => 'xml_piElement',
340
+        'default' => 'xml_defaultElement'
341
+    ];
342 342
 }
343 343
 
344 344
 
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
  *
349 349
  **/
350 350
 function xml_valider_dist($page, $apply = false, $process = false, $doctype = '', $charset = null) {
351
-	$f = new ValidateurXML($process);
352
-	$sax = charger_fonction('sax', 'xml');
351
+    $f = new ValidateurXML($process);
352
+    $sax = charger_fonction('sax', 'xml');
353 353
 
354
-	return $sax($page, $apply, $f, $doctype, $charset);
354
+    return $sax($page, $apply, $f, $doctype, $charset);
355 355
 }
Please login to merge, or discard this patch.
ecrire/install/etape_ldap4.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 	if ($fail) {
40 40
 		echo info_etape(_T('info_chemin_acces_annuaire')),
41 41
 		info_progression_etape(3, 'etape_ldap', 'install/', true),
42
-			"<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'),
43
-			' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>';
42
+			"<div class='error'><p><b>"._T('avis_operation_echec').'</b></p><p>'._T('avis_chemin_invalide_1'),
43
+			' (<tt>'.spip_htmlspecialchars($base_ldap).'</tt>) '._T('avis_chemin_invalide_2').'</p></div>';
44 44
 	} else {
45 45
 		info_etape(_T('info_reglage_ldap'));
46 46
 		echo info_progression_etape(4, 'etape_ldap', 'install/');
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 
54 54
 		$res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap'])
55 55
 			. "<input type='hidden' name='etape' value='ldap5' />"
56
-			. "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />"
56
+			. "<input type='hidden' name='base_ldap' value='".spip_htmlentities($base_ldap)."' />"
57 57
 			. fieldset(
58 58
 				_T('info_statut_utilisateurs_1'),
59 59
 				[
60 60
 					'statut_ldap' => [
61
-						'label' => _T('info_statut_utilisateurs_2') . '<br />',
61
+						'label' => _T('info_statut_utilisateurs_2').'<br />',
62 62
 						'valeur' => $statut_ldap,
63 63
 						'alternatives' => $statuts
64 64
 					]
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
 function liste_statuts_ldap() {
77 77
 	$recom = [
78
-		'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'),
79
-		'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'),
80
-		'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />')
78
+		'info_administrateurs' => ('<b>'._T('info_administrateur_1').'</b> '._T('info_administrateur_2').'<br />'),
79
+		'info_redacteurs' => ('<b>'._T('info_redacteur_1').'</b> '._T('info_redacteur_2').'<br />'),
80
+		'info_visiteurs' => ('<b>'._T('info_visiteur_1').'</b> '._T('info_visiteur_2').'<br />')
81 81
 	];
82 82
 
83 83
 	$res = [];
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 function install_ldap_correspondances() {
94 94
 	$champs = [];
95 95
 	foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) {
96
-		$nom = 'ldap_' . $champ;
96
+		$nom = 'ldap_'.$champ;
97 97
 		$val = is_array($v) ? join(',', $v) : strval($v);
98 98
 		$champs[$nom] = [
99
-			'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />',
99
+			'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]).'<br />',
100 100
 			'valeur' => $val
101 101
 		];
102 102
 	}
103 103
 
104 104
 	return !$champs ?
105
-		'' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />');
105
+		'' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2').'<br /><br />');
106 106
 }
Please login to merge, or discard this patch.
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -10,97 +10,97 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('auth/ldap');
17 17
 
18 18
 function install_etape_ldap4_dist() {
19
-	$adresse_ldap = _request('adresse_ldap');
20
-	$login_ldap = _request('login_ldap');
21
-	$pass_ldap = _request('pass_ldap');
22
-	$port_ldap = _request('port_ldap');
23
-	$base_ldap = _request('base_ldap');
24
-	$base_ldap_text = _request('base_ldap_text');
25
-	if (!$base_ldap) {
26
-		$base_ldap = $base_ldap_text;
27
-	}
28
-
29
-	$minipage = new Spip\Afficher\Minipage\Installation();
30
-	echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']);
31
-
32
-	$ldap_link = ldap_connect($adresse_ldap, $port_ldap);
33
-	@ldap_bind($ldap_link, $login_ldap, $pass_ldap);
34
-
35
-	// Essayer de verifier le chemin fourni
36
-	$r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', '');
37
-	$fail = (ldap_errno($ldap_link) == 32);
38
-
39
-	if ($fail) {
40
-		echo info_etape(_T('info_chemin_acces_annuaire')),
41
-		info_progression_etape(3, 'etape_ldap', 'install/', true),
42
-			"<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'),
43
-			' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>';
44
-	} else {
45
-		info_etape(_T('info_reglage_ldap'));
46
-		echo info_progression_etape(4, 'etape_ldap', 'install/');
47
-
48
-		$statuts = liste_statuts_ldap();
49
-		$statut_ldap = defined('_INSTALL_STATUT_LDAP')
50
-			? _INSTALL_STATUT_LDAP
51
-			: $GLOBALS['liste_des_statuts']['info_redacteurs'];
52
-
53
-
54
-		$res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap'])
55
-			. "<input type='hidden' name='etape' value='ldap5' />"
56
-			. "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />"
57
-			. fieldset(
58
-				_T('info_statut_utilisateurs_1'),
59
-				[
60
-					'statut_ldap' => [
61
-						'label' => _T('info_statut_utilisateurs_2') . '<br />',
62
-						'valeur' => $statut_ldap,
63
-						'alternatives' => $statuts
64
-					]
65
-				]
66
-			)
67
-			. install_ldap_correspondances()
68
-			. bouton_suivant();
69
-
70
-		echo generer_form_ecrire('install', $res);
71
-	}
72
-
73
-	echo $minipage->installFinPage();
19
+    $adresse_ldap = _request('adresse_ldap');
20
+    $login_ldap = _request('login_ldap');
21
+    $pass_ldap = _request('pass_ldap');
22
+    $port_ldap = _request('port_ldap');
23
+    $base_ldap = _request('base_ldap');
24
+    $base_ldap_text = _request('base_ldap_text');
25
+    if (!$base_ldap) {
26
+        $base_ldap = $base_ldap_text;
27
+    }
28
+
29
+    $minipage = new Spip\Afficher\Minipage\Installation();
30
+    echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']);
31
+
32
+    $ldap_link = ldap_connect($adresse_ldap, $port_ldap);
33
+    @ldap_bind($ldap_link, $login_ldap, $pass_ldap);
34
+
35
+    // Essayer de verifier le chemin fourni
36
+    $r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', '');
37
+    $fail = (ldap_errno($ldap_link) == 32);
38
+
39
+    if ($fail) {
40
+        echo info_etape(_T('info_chemin_acces_annuaire')),
41
+        info_progression_etape(3, 'etape_ldap', 'install/', true),
42
+            "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'),
43
+            ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>';
44
+    } else {
45
+        info_etape(_T('info_reglage_ldap'));
46
+        echo info_progression_etape(4, 'etape_ldap', 'install/');
47
+
48
+        $statuts = liste_statuts_ldap();
49
+        $statut_ldap = defined('_INSTALL_STATUT_LDAP')
50
+            ? _INSTALL_STATUT_LDAP
51
+            : $GLOBALS['liste_des_statuts']['info_redacteurs'];
52
+
53
+
54
+        $res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap'])
55
+            . "<input type='hidden' name='etape' value='ldap5' />"
56
+            . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />"
57
+            . fieldset(
58
+                _T('info_statut_utilisateurs_1'),
59
+                [
60
+                    'statut_ldap' => [
61
+                        'label' => _T('info_statut_utilisateurs_2') . '<br />',
62
+                        'valeur' => $statut_ldap,
63
+                        'alternatives' => $statuts
64
+                    ]
65
+                ]
66
+            )
67
+            . install_ldap_correspondances()
68
+            . bouton_suivant();
69
+
70
+        echo generer_form_ecrire('install', $res);
71
+    }
72
+
73
+    echo $minipage->installFinPage();
74 74
 }
75 75
 
76 76
 function liste_statuts_ldap() {
77
-	$recom = [
78
-		'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'),
79
-		'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'),
80
-		'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />')
81
-	];
82
-
83
-	$res = [];
84
-	foreach ($GLOBALS['liste_des_statuts'] as $k => $v) {
85
-		if (isset($recom[$k])) {
86
-			$res[$v] = $recom[$k];
87
-		}
88
-	}
89
-
90
-	return $res;
77
+    $recom = [
78
+        'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'),
79
+        'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'),
80
+        'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />')
81
+    ];
82
+
83
+    $res = [];
84
+    foreach ($GLOBALS['liste_des_statuts'] as $k => $v) {
85
+        if (isset($recom[$k])) {
86
+            $res[$v] = $recom[$k];
87
+        }
88
+    }
89
+
90
+    return $res;
91 91
 }
92 92
 
93 93
 function install_ldap_correspondances() {
94
-	$champs = [];
95
-	foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) {
96
-		$nom = 'ldap_' . $champ;
97
-		$val = is_array($v) ? join(',', $v) : strval($v);
98
-		$champs[$nom] = [
99
-			'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />',
100
-			'valeur' => $val
101
-		];
102
-	}
103
-
104
-	return !$champs ?
105
-		'' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />');
94
+    $champs = [];
95
+    foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) {
96
+        $nom = 'ldap_' . $champ;
97
+        $val = is_array($v) ? join(',', $v) : strval($v);
98
+        $champs[$nom] = [
99
+            'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />',
100
+            'valeur' => $val
101
+        ];
102
+    }
103
+
104
+    return !$champs ?
105
+        '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />');
106 106
 }
Please login to merge, or discard this patch.
ecrire/balise/formulaire_admin.php 2 patches
Indentation   +148 added lines, -148 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
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *     Pile complétée du code compilé
43 43
  **/
44 44
 function balise_FORMULAIRE_ADMIN($p) {
45
-	return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
45
+    return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
46 46
 }
47 47
 
48 48
 /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  *   - chaîne vide sinon.
60 60
  */
61 61
 function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
62
-	return $args;
62
+    return $args;
63 63
 }
64 64
 
65 65
 
@@ -84,66 +84,66 @@  discard block
 block discarded – undo
84 84
  **/
85 85
 function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') {
86 86
 
87
-	static $dejafait = false;
87
+    static $dejafait = false;
88 88
 
89
-	if (empty($_COOKIE['spip_admin'])) {
90
-		return '';
91
-	}
89
+    if (empty($_COOKIE['spip_admin'])) {
90
+        return '';
91
+    }
92 92
 
93
-	if (!is_array($debug)) {
94
-		if ($dejafait) {
95
-			return '';
96
-		}
97
-	} else {
98
-		if ($dejafait) {
99
-			if (empty($debug['sourcefile'])) {
100
-				return '';
101
-			}
102
-			foreach ($debug['sourcefile'] as $k => $v) {
103
-				if (strpos($v, 'administration.') !== false) {
104
-					if (isset($debug['resultat'][$k . 'tout'])) {
105
-						return $debug['resultat'][$k . 'tout'];
106
-					}
107
-				}
108
-			}
93
+    if (!is_array($debug)) {
94
+        if ($dejafait) {
95
+            return '';
96
+        }
97
+    } else {
98
+        if ($dejafait) {
99
+            if (empty($debug['sourcefile'])) {
100
+                return '';
101
+            }
102
+            foreach ($debug['sourcefile'] as $k => $v) {
103
+                if (strpos($v, 'administration.') !== false) {
104
+                    if (isset($debug['resultat'][$k . 'tout'])) {
105
+                        return $debug['resultat'][$k . 'tout'];
106
+                    }
107
+                }
108
+            }
109 109
 
110
-			return '';
111
-		}
112
-	}
110
+            return '';
111
+        }
112
+    }
113 113
 
114
-	include_spip('inc/autoriser');
115
-	include_spip('base/abstract_sql');
114
+    include_spip('inc/autoriser');
115
+    include_spip('base/abstract_sql');
116 116
 
117 117
 
118
-	$dejafait = true;
118
+    $dejafait = true;
119 119
 
120
-	// Preparer le #ENV des boutons
120
+    // Preparer le #ENV des boutons
121 121
 
122
-	$env = admin_objet();
122
+    $env = admin_objet();
123 123
 
124
-	// Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
-	if (!$env) {
126
-		$env['ecrire'] = _DIR_RESTREINT_ABS;
127
-	}
124
+    // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
+    if (!$env) {
126
+        $env['ecrire'] = _DIR_RESTREINT_ABS;
127
+    }
128 128
 
129
-	$env['divclass'] = $float;
130
-	$env['lang'] = admin_lang();
131
-	$env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
-	$env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug());
133
-	$env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
-	$env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
129
+    $env['divclass'] = $float;
130
+    $env['lang'] = admin_lang();
131
+    $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
+    $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug());
133
+    $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
+    $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
135 135
 
136
-	if (empty($GLOBALS['use_cache'])) {
137
-		$env['use_cache'] = ' *';
138
-	}
136
+    if (empty($GLOBALS['use_cache'])) {
137
+        $env['use_cache'] = ' *';
138
+    }
139 139
 
140
-	if (isset($debug['validation'])) {
141
-		$env['xhtml_error'] = $debug['validation'];
142
-	}
140
+    if (isset($debug['validation'])) {
141
+        $env['xhtml_error'] = $debug['validation'];
142
+    }
143 143
 
144
-	$env['_pipelines']['formulaire_admin'] = [];
144
+    $env['_pipelines']['formulaire_admin'] = [];
145 145
 
146
-	return ['formulaires/administration', 0, $env];
146
+    return ['formulaires/administration', 0, $env];
147 147
 }
148 148
 
149 149
 
@@ -161,47 +161,47 @@  discard block
 block discarded – undo
161 161
  *     Tableau de l'environnement calculé
162 162
  **/
163 163
 function admin_objet() {
164
-	include_spip('inc/urls');
165
-	$env = [];
166
-
167
-	$trouver_table = charger_fonction('trouver_table', 'base');
168
-	$objets = urls_liste_objets(false);
169
-	$objets = array_diff($objets, ['rubrique']);
170
-	$objets = array_reverse($objets);
171
-	array_unshift($objets, 'rubrique');
172
-	foreach ($objets as $obj) {
173
-		$type = $obj;
174
-		if (
175
-			$type == objet_type($type, false)
176
-			and $_id_type = id_table_objet($type)
177
-			and isset($GLOBALS['contexte'][$_id_type])
178
-			and $id = $GLOBALS['contexte'][$_id_type]
179
-			and !is_array($id)
180
-			and $id = intval($id)
181
-			and $desc = $trouver_table(table_objet_sql($type))
182
-		) {
183
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
184
-			if ($id) {
185
-				$env[$_id_type] = $id;
186
-				$env['objet'] = $type;
187
-				$env['id_objet'] = $id;
188
-				$env['voir_' . $obj] =
189
-					str_replace('&amp;', '&', generer_objet_url($id, $obj, '', '', false));
190
-				if (
191
-					isset($desc['field']['id_rubrique'])
192
-					and $type != 'rubrique'
193
-				) {
194
-					unset($env['id_rubrique']);
195
-					unset($env['voir_rubrique']);
196
-					if (admin_preview($type, $id, $desc)) {
197
-						$env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
198
-					}
199
-				}
200
-			}
201
-		}
202
-	}
203
-
204
-	return $env;
164
+    include_spip('inc/urls');
165
+    $env = [];
166
+
167
+    $trouver_table = charger_fonction('trouver_table', 'base');
168
+    $objets = urls_liste_objets(false);
169
+    $objets = array_diff($objets, ['rubrique']);
170
+    $objets = array_reverse($objets);
171
+    array_unshift($objets, 'rubrique');
172
+    foreach ($objets as $obj) {
173
+        $type = $obj;
174
+        if (
175
+            $type == objet_type($type, false)
176
+            and $_id_type = id_table_objet($type)
177
+            and isset($GLOBALS['contexte'][$_id_type])
178
+            and $id = $GLOBALS['contexte'][$_id_type]
179
+            and !is_array($id)
180
+            and $id = intval($id)
181
+            and $desc = $trouver_table(table_objet_sql($type))
182
+        ) {
183
+            $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
184
+            if ($id) {
185
+                $env[$_id_type] = $id;
186
+                $env['objet'] = $type;
187
+                $env['id_objet'] = $id;
188
+                $env['voir_' . $obj] =
189
+                    str_replace('&amp;', '&', generer_objet_url($id, $obj, '', '', false));
190
+                if (
191
+                    isset($desc['field']['id_rubrique'])
192
+                    and $type != 'rubrique'
193
+                ) {
194
+                    unset($env['id_rubrique']);
195
+                    unset($env['voir_rubrique']);
196
+                    if (admin_preview($type, $id, $desc)) {
197
+                        $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
198
+                    }
199
+                }
200
+            }
201
+        }
202
+    }
203
+
204
+    return $env;
205 205
 }
206 206
 
207 207
 
@@ -219,30 +219,30 @@  discard block
 block discarded – undo
219 219
  *     - Tableau d'un élément sinon.
220 220
  **/
221 221
 function admin_preview($type, $id, $desc = null) {
222
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
223
-		return '';
224
-	}
225
-
226
-	if (!$desc) {
227
-		$trouver_table = charger_fonction('trouver_table', 'base');
228
-		$desc = $trouver_table(table_objet_sql($type));
229
-	}
230
-	if (!$desc or !isset($desc['field']['statut'])) {
231
-		return '';
232
-	}
233
-
234
-	include_spip('inc/autoriser');
235
-	if (!autoriser('previsualiser')) {
236
-		return '';
237
-	}
238
-
239
-	$notpub = sql_in('statut', ['prop', 'prive']);
240
-
241
-	if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
243
-	}
244
-
245
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
222
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
223
+        return '';
224
+    }
225
+
226
+    if (!$desc) {
227
+        $trouver_table = charger_fonction('trouver_table', 'base');
228
+        $desc = $trouver_table(table_objet_sql($type));
229
+    }
230
+    if (!$desc or !isset($desc['field']['statut'])) {
231
+        return '';
232
+    }
233
+
234
+    include_spip('inc/autoriser');
235
+    if (!autoriser('previsualiser')) {
236
+        return '';
237
+    }
238
+
239
+    $notpub = sql_in('statut', ['prop', 'prive']);
240
+
241
+    if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
+        $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
243
+    }
244
+
245
+    return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
246 246
 }
247 247
 
248 248
 
@@ -253,25 +253,25 @@  discard block
 block discarded – undo
253 253
  *     Code de langue
254 254
  **/
255 255
 function admin_lang() {
256
-	$alang = '';
257
-	if (!empty($_COOKIE['spip_admin'])) {
258
-		$email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
-		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
260
-		if (!$alang) {
261
-			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
262
-		}
263
-	}
264
-	if (!$alang) {
265
-		return '';
266
-	}
267
-
268
-	$l = lang_select($alang);
269
-	$alang = $GLOBALS['spip_lang'];
270
-	if ($l) {
271
-		lang_select();
272
-	}
273
-
274
-	return $alang;
256
+    $alang = '';
257
+    if (!empty($_COOKIE['spip_admin'])) {
258
+        $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
+        $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
260
+        if (!$alang) {
261
+            $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
262
+        }
263
+    }
264
+    if (!$alang) {
265
+        return '';
266
+    }
267
+
268
+    $l = lang_select($alang);
269
+    $alang = $GLOBALS['spip_lang'];
270
+    if ($l) {
271
+        lang_select();
272
+    }
273
+
274
+    return $alang;
275 275
 }
276 276
 
277 277
 /**
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
  **/
282 282
 function admin_valider() {
283 283
 
284
-	return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285
-		(parametre_url(self(), 'var_mode', 'debug', '&')
286
-			. '&var_mode_affiche=validation') :
287
-		('http://validator.w3.org/check?uri='
288
-			. rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
284
+    return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285
+        (parametre_url(self(), 'var_mode', 'debug', '&')
286
+            . '&var_mode_affiche=validation') :
287
+        ('http://validator.w3.org/check?uri='
288
+            . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
289 289
 }
290 290
 
291 291
 /**
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
  * @return string
295 295
  **/
296 296
 function admin_debug() {
297
-	return ((
298
-			(isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
299
-			or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
300
-			or (
301
-				defined('_VAR_MODE') and _VAR_MODE == 'debug'
302
-				and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
303
-			)
304
-		) and autoriser('debug')
305
-	)
306
-		? parametre_url(self(), 'var_mode', 'debug', '&') : '';
297
+    return ((
298
+            (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
299
+            or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
300
+            or (
301
+                defined('_VAR_MODE') and _VAR_MODE == 'debug'
302
+                and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
303
+            )
304
+        ) and autoriser('debug')
305
+    )
306
+        ? parametre_url(self(), 'var_mode', 'debug', '&') : '';
307 307
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 			}
102 102
 			foreach ($debug['sourcefile'] as $k => $v) {
103 103
 				if (strpos($v, 'administration.') !== false) {
104
-					if (isset($debug['resultat'][$k . 'tout'])) {
105
-						return $debug['resultat'][$k . 'tout'];
104
+					if (isset($debug['resultat'][$k.'tout'])) {
105
+						return $debug['resultat'][$k.'tout'];
106 106
 					}
107 107
 				}
108 108
 			}
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 			and $id = intval($id)
181 181
 			and $desc = $trouver_table(table_objet_sql($type))
182 182
 		) {
183
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
183
+			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=".intval($id));
184 184
 			if ($id) {
185 185
 				$env[$_id_type] = $id;
186 186
 				$env['objet'] = $type;
187 187
 				$env['id_objet'] = $id;
188
-				$env['voir_' . $obj] =
188
+				$env['voir_'.$obj] =
189 189
 					str_replace('&amp;', '&', generer_objet_url($id, $obj, '', '', false));
190 190
 				if (
191 191
 					isset($desc['field']['id_rubrique'])
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	$notpub = sql_in('statut', ['prop', 'prive']);
240 240
 
241 241
 	if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
242
+		$notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).')';
243 243
 	}
244 244
 
245
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
245
+	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type).'='.$id." AND ($notpub)");
246 246
 }
247 247
 
248 248
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	$alang = '';
257 257
 	if (!empty($_COOKIE['spip_admin'])) {
258 258
 		$email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
-		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
259
+		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email='.sql_quote($email_or_login));
260 260
 		if (!$alang) {
261
-			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
261
+			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login='.sql_quote($email_or_login));
262 262
 		}
263 263
 	}
264 264
 	if (!$alang) {
@@ -283,9 +283,8 @@  discard block
 block discarded – undo
283 283
 
284 284
 	return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285 285
 		(parametre_url(self(), 'var_mode', 'debug', '&')
286
-			. '&var_mode_affiche=validation') :
287
-		('http://validator.w3.org/check?uri='
288
-			. rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
286
+			. '&var_mode_affiche=validation') : ('http://validator.w3.org/check?uri='
287
+			. rawurlencode('http://'.$_SERVER['HTTP_HOST'].nettoyer_uri())));
289 288
 }
290 289
 
291 290
 /**
Please login to merge, or discard this patch.
ecrire/balise/info_.php 2 patches
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
 /**
@@ -40,29 +40,29 @@  discard block
 block discarded – undo
40 40
  *     Pile complétée par le code à générer
41 41
  */
42 42
 function balise_INFO__dist($p) {
43
-	$info = $p->nom_champ;
44
-	$type_objet = interprete_argument_balise(1, $p);
45
-	$id_objet = interprete_argument_balise(2, $p);
46
-	if ($info === 'INFO_' or !$type_objet or !$id_objet) {
47
-		$msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']);
48
-		erreur_squelette($msg, $p);
49
-		$p->interdire_scripts = true;
43
+    $info = $p->nom_champ;
44
+    $type_objet = interprete_argument_balise(1, $p);
45
+    $id_objet = interprete_argument_balise(2, $p);
46
+    if ($info === 'INFO_' or !$type_objet or !$id_objet) {
47
+        $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']);
48
+        erreur_squelette($msg, $p);
49
+        $p->interdire_scripts = true;
50 50
 
51
-		return $p;
52
-	} else {
53
-		// Récupérer tous les params à la suite de objet et id_objet
54
-		$_params = '[';
55
-		$nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus
56
-		for ($i = 3; $i < $nb_params; $i++) {
57
-			$_params .= interprete_argument_balise($i, $p) . ',';
58
-		}
59
-		$_params .= ']';
51
+        return $p;
52
+    } else {
53
+        // Récupérer tous les params à la suite de objet et id_objet
54
+        $_params = '[';
55
+        $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus
56
+        for ($i = 3; $i < $nb_params; $i++) {
57
+            $_params .= interprete_argument_balise($i, $p) . ',';
58
+        }
59
+        $_params .= ']';
60 60
 
61
-		$info_sql = strtolower(substr($info, 5));
62
-		$code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)";
63
-		$p->code = champ_sql($info, $p, $code);
64
-		$p->interdire_scripts = true;
61
+        $info_sql = strtolower(substr($info, 5));
62
+        $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)";
63
+        $p->code = champ_sql($info, $p, $code);
64
+        $p->interdire_scripts = true;
65 65
 
66
-		return $p;
67
-	}
66
+        return $p;
67
+    }
68 68
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@
 block discarded – undo
54 54
 		$_params = '[';
55 55
 		$nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus
56 56
 		for ($i = 3; $i < $nb_params; $i++) {
57
-			$_params .= interprete_argument_balise($i, $p) . ',';
57
+			$_params .= interprete_argument_balise($i, $p).',';
58 58
 		}
59 59
 		$_params .= ']';
60 60
 
61 61
 		$info_sql = strtolower(substr($info, 5));
62
-		$code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)";
62
+		$code = "generer_objet_info($id_objet, $type_objet, '$info_sql', ".($p->etoile ? _q($p->etoile) : "''").", $_params)";
63 63
 		$p->code = champ_sql($info, $p, $code);
64 64
 		$p->interdire_scripts = true;
65 65
 
Please login to merge, or discard this patch.
ecrire/urls/page.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite
24 24
 define('_separateur_urls_page', '');
25 25
 # on peut indiquer '' si on a installe le .htaccess
26
-define('_debut_urls_page', get_spip_script('./') . '?');
26
+define('_debut_urls_page', get_spip_script('./').'?');
27 27
 #######
28 28
 
29 29
 
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 		}
47 47
 	}
48 48
 
49
-	$url = \_debut_urls_page . $objet . \_separateur_urls_page
50
-		. $id . \_terminaison_urls_page;
49
+	$url = \_debut_urls_page.$objet.\_separateur_urls_page
50
+		. $id.\_terminaison_urls_page;
51 51
 
52 52
 	if ($args) {
53 53
 		$args = strpos($url, '?') ? "&$args" : "?$args";
54 54
 	}
55 55
 
56
-	return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
56
+	return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : '');
57 57
 }
58 58
 
59 59
 /**
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 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
 defined('URLS_PAGE_EXEMPLE') || define('URLS_PAGE_EXEMPLE', 'spip.php?article12');
@@ -37,23 +37,23 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function urls_page_generer_url_objet_dist(int $id, string $objet, string $args = '', string $ancre = ''): string {
39 39
 
40
-	if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) {
41
-		$url = $generer_url_externe($id, $args, $ancre);
42
-		// une url === null indique "je ne traite pas cette url, appliquez le calcul standard"
43
-		// une url vide est une url vide, ne rien faire de plus
44
-		if (!is_null($url)) {
45
-			return $url;
46
-		}
47
-	}
40
+    if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) {
41
+        $url = $generer_url_externe($id, $args, $ancre);
42
+        // une url === null indique "je ne traite pas cette url, appliquez le calcul standard"
43
+        // une url vide est une url vide, ne rien faire de plus
44
+        if (!is_null($url)) {
45
+            return $url;
46
+        }
47
+    }
48 48
 
49
-	$url = \_debut_urls_page . $objet . \_separateur_urls_page
50
-		. $id . \_terminaison_urls_page;
49
+    $url = \_debut_urls_page . $objet . \_separateur_urls_page
50
+        . $id . \_terminaison_urls_page;
51 51
 
52
-	if ($args) {
53
-		$args = strpos($url, '?') ? "&$args" : "?$args";
54
-	}
52
+    if ($args) {
53
+        $args = strpos($url, '?') ? "&$args" : "?$args";
54
+    }
55 55
 
56
-	return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
56
+    return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
57 57
 }
58 58
 
59 59
 /**
@@ -69,27 +69,27 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function urls_page_decoder_url_dist(string $url, string $entite, array $contexte = []): array {
71 71
 
72
-	// traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
73
-	if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
74
-		return [[], '404'];
75
-	}
72
+    // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
73
+    if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
74
+        return [[], '404'];
75
+    }
76 76
 
77
-	include_spip('inc/urls');
78
-	$r = nettoyer_url_page($url, $contexte);
79
-	if ($r) {
80
-		array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici
81
-		return $r;
82
-	}
77
+    include_spip('inc/urls');
78
+    $r = nettoyer_url_page($url, $contexte);
79
+    if ($r) {
80
+        array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici
81
+        return $r;
82
+    }
83 83
 
84
-	/*
84
+    /*
85 85
 	 * Le bloc qui suit sert a faciliter les transitions depuis
86 86
 	 * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html'
87 87
 	 * Il est inutile de le recopier si vous personnalisez vos URLs
88 88
 	 * et votre .htaccess
89 89
 	 */
90
-	// Si on est revenu en mode html, mais c'est une ancienne url_propre
91
-	// on ne redirige pas, on assume le nouveau contexte (si possible)
92
-	$url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? '';
93
-	return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte);
94
-	/* Fin du bloc compatibilite url-propres */
90
+    // Si on est revenu en mode html, mais c'est une ancienne url_propre
91
+    // on ne redirige pas, on assume le nouveau contexte (si possible)
92
+    $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? '';
93
+    return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte);
94
+    /* Fin du bloc compatibilite url-propres */
95 95
 }
Please login to merge, or discard this patch.
ecrire/action/menu_rubriques.php 2 patches
Indentation   +156 added lines, -156 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/autoriser');
@@ -35,42 +35,42 @@  discard block
 block discarded – undo
35 35
  **/
36 36
 function action_menu_rubriques_dist() {
37 37
 
38
-	// si pas acces a ecrire, pas acces au menu
39
-	// on renvoi un 401 qui fait echouer la requete ajax silencieusement
40
-	if (!autoriser('ecrire')) {
41
-		$retour =
42
-		'<ul class="deroulant__sous-menu" data-profondeur="1">' .
43
-			'<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
44
-				'<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
45
-					'<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
46
-				'</a>' .
47
-			'</li>' .
48
-		'</ul>';
49
-		include_spip('inc/actions');
50
-		ajax_retour($retour);
51
-		exit;
52
-	}
53
-
54
-	if ($date = intval(_request('date'))) {
55
-		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
56
-	}
57
-
58
-	$r = gen_liste_rubriques();
59
-	if (
60
-		!$r
61
-		and isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
62
-		and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
63
-	) {
64
-		include_spip('inc/headers');
65
-		header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
66
-		http_response_code(304);
67
-		exit;
68
-	} else {
69
-		include_spip('inc/actions');
70
-		$ret = menu_rubriques();
71
-		ajax_retour($ret);
72
-		exit;
73
-	}
38
+    // si pas acces a ecrire, pas acces au menu
39
+    // on renvoi un 401 qui fait echouer la requete ajax silencieusement
40
+    if (!autoriser('ecrire')) {
41
+        $retour =
42
+        '<ul class="deroulant__sous-menu" data-profondeur="1">' .
43
+            '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
44
+                '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
45
+                    '<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
46
+                '</a>' .
47
+            '</li>' .
48
+        '</ul>';
49
+        include_spip('inc/actions');
50
+        ajax_retour($retour);
51
+        exit;
52
+    }
53
+
54
+    if ($date = intval(_request('date'))) {
55
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
56
+    }
57
+
58
+    $r = gen_liste_rubriques();
59
+    if (
60
+        !$r
61
+        and isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
62
+        and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
63
+    ) {
64
+        include_spip('inc/headers');
65
+        header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
66
+        http_response_code(304);
67
+        exit;
68
+    } else {
69
+        include_spip('inc/actions');
70
+        $ret = menu_rubriques();
71
+        ajax_retour($ret);
72
+        exit;
73
+    }
74 74
 }
75 75
 
76 76
 /**
@@ -84,44 +84,44 @@  discard block
 block discarded – undo
84 84
  *     Code HTML présentant la liste des rubriques
85 85
  **/
86 86
 function menu_rubriques($complet = true) {
87
-	$ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
88
-		. '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
89
-		. '<span class="libelle">' . _T('info_tout_site') . '</span>'
90
-		. '</a>'
91
-		. '</li>';
92
-
93
-	if (!$complet) {
94
-		return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
95
-	}
96
-
97
-	if (!isset($GLOBALS['db_art_cache'])) {
98
-		gen_liste_rubriques();
99
-	}
100
-	$arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
101
-
102
-	$total_lignes = $i = sizeof($arr_low);
103
-
104
-	if ($i > 0) {
105
-		$nb_col = min(8, ceil($total_lignes / 30));
106
-		if ($nb_col <= 1) {
107
-			$nb_col = ceil($total_lignes / 10);
108
-		}
109
-		foreach ($arr_low as $id_rubrique => $titre_rubrique) {
110
-			if (autoriser('voir', 'rubrique', $id_rubrique)) {
111
-				$ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
112
-				$i++;
113
-			}
114
-		}
115
-
116
-		$class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
117
-		$ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">"
118
-			. $ret
119
-			. "\n</ul>\n";
120
-	} else {
121
-		$ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
122
-	}
123
-
124
-	return $ret;
87
+    $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
88
+        . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
89
+        . '<span class="libelle">' . _T('info_tout_site') . '</span>'
90
+        . '</a>'
91
+        . '</li>';
92
+
93
+    if (!$complet) {
94
+        return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
95
+    }
96
+
97
+    if (!isset($GLOBALS['db_art_cache'])) {
98
+        gen_liste_rubriques();
99
+    }
100
+    $arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
101
+
102
+    $total_lignes = $i = sizeof($arr_low);
103
+
104
+    if ($i > 0) {
105
+        $nb_col = min(8, ceil($total_lignes / 30));
106
+        if ($nb_col <= 1) {
107
+            $nb_col = ceil($total_lignes / 10);
108
+        }
109
+        foreach ($arr_low as $id_rubrique => $titre_rubrique) {
110
+            if (autoriser('voir', 'rubrique', $id_rubrique)) {
111
+                $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
112
+                $i++;
113
+            }
114
+        }
115
+
116
+        $class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
117
+        $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">"
118
+            . $ret
119
+            . "\n</ul>\n";
120
+    } else {
121
+        $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
122
+    }
123
+
124
+    return $ret;
125 125
 }
126 126
 
127 127
 /**
@@ -142,48 +142,48 @@  discard block
 block discarded – undo
142 142
  *     Code HTML présentant la liste des rubriques
143 143
  **/
144 144
 function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) {
145
-	static $zmax = 6;
146
-	$profondeur_next = $profondeur + 1;
147
-
148
-	$nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
149
-		. '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
150
-		. "</a>\n";
151
-
152
-	// Limiter volontairement le nombre de sous-menus
153
-	if (!(--$zmax)) {
154
-		$zmax++;
155
-
156
-		return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
157
-	}
158
-
159
-	$arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
160
-	$i = sizeof($arr_rub);
161
-	if (!$i) {
162
-		$zmax++;
163
-
164
-		return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
165
-	}
166
-
167
-
168
-	$nb_col = 1;
169
-	if ($nb_rub = count($arr_rub)) {
170
-		$nb_col = min(10, max(1, ceil($nb_rub / 10)));
171
-	}
172
-	$class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
173
-	$ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">"
174
-	 . $nav
175
-	 . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">";
176
-	foreach ($arr_rub as $id_rub => $titre_rub) {
177
-		if (autoriser('voir', 'rubrique', $id_rub)) {
178
-			$titre = supprimer_numero(typo($titre_rub));
179
-			$ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next);
180
-			$i++;
181
-		}
182
-	}
183
-	$ret .= "</ul></li>\n";
184
-	$zmax++;
185
-
186
-	return $ret;
145
+    static $zmax = 6;
146
+    $profondeur_next = $profondeur + 1;
147
+
148
+    $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
149
+        . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
150
+        . "</a>\n";
151
+
152
+    // Limiter volontairement le nombre de sous-menus
153
+    if (!(--$zmax)) {
154
+        $zmax++;
155
+
156
+        return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
157
+    }
158
+
159
+    $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
160
+    $i = sizeof($arr_rub);
161
+    if (!$i) {
162
+        $zmax++;
163
+
164
+        return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
165
+    }
166
+
167
+
168
+    $nb_col = 1;
169
+    if ($nb_rub = count($arr_rub)) {
170
+        $nb_col = min(10, max(1, ceil($nb_rub / 10)));
171
+    }
172
+    $class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
173
+    $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">"
174
+        . $nav
175
+        . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">";
176
+    foreach ($arr_rub as $id_rub => $titre_rub) {
177
+        if (autoriser('voir', 'rubrique', $id_rub)) {
178
+            $titre = supprimer_numero(typo($titre_rub));
179
+            $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next);
180
+            $i++;
181
+        }
182
+    }
183
+    $ret .= "</ul></li>\n";
184
+    $zmax++;
185
+
186
+    return $ret;
187 187
 }
188 188
 
189 189
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  *     Liste des rubriques enfants de la rubrique (et leur titre)
202 202
  **/
203 203
 function extraire_article($id_p, $t) {
204
-	return array_key_exists($id_p, $t) ? $t[$id_p] : [];
204
+    return array_key_exists($id_p, $t) ? $t[$id_p] : [];
205 205
 }
206 206
 
207 207
 /**
@@ -217,42 +217,42 @@  discard block
 block discarded – undo
217 217
  **/
218 218
 function gen_liste_rubriques() {
219 219
 
220
-	$cache = null;
221
-	include_spip('inc/config');
222
-	// ici, un petit fichier cache ne fait pas de mal
223
-	$last = lire_config('date_calcul_rubriques', 0);
224
-	if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
225
-		[$date, $GLOBALS['db_art_cache']] = @unserialize($cache);
226
-		if ($date == $last) {
227
-			return false;
228
-		} // c'etait en cache :-)
229
-	}
230
-	// se restreindre aux rubriques utilisees recemment +secteurs
231
-
232
-	$where = sql_in_select(
233
-		'id_rubrique',
234
-		'id_rubrique',
235
-		'spip_rubriques',
236
-		'',
237
-		'',
238
-		'id_parent=0 DESC, date DESC',
239
-		_CACHE_RUBRIQUES_MAX
240
-	);
241
-
242
-	// puis refaire la requete pour avoir l'ordre alphabetique
243
-
244
-	$res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre');
245
-
246
-	// il ne faut pas filtrer le autoriser voir ici
247
-	// car on met le resultat en cache, commun a tout le monde
248
-	$GLOBALS['db_art_cache'] = [];
249
-	while ($r = sql_fetch($res)) {
250
-		$t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
251
-		$GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
252
-	}
253
-
254
-	$t = [$last ?: time(), $GLOBALS['db_art_cache']];
255
-	ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
256
-
257
-	return true;
220
+    $cache = null;
221
+    include_spip('inc/config');
222
+    // ici, un petit fichier cache ne fait pas de mal
223
+    $last = lire_config('date_calcul_rubriques', 0);
224
+    if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
225
+        [$date, $GLOBALS['db_art_cache']] = @unserialize($cache);
226
+        if ($date == $last) {
227
+            return false;
228
+        } // c'etait en cache :-)
229
+    }
230
+    // se restreindre aux rubriques utilisees recemment +secteurs
231
+
232
+    $where = sql_in_select(
233
+        'id_rubrique',
234
+        'id_rubrique',
235
+        'spip_rubriques',
236
+        '',
237
+        '',
238
+        'id_parent=0 DESC, date DESC',
239
+        _CACHE_RUBRIQUES_MAX
240
+    );
241
+
242
+    // puis refaire la requete pour avoir l'ordre alphabetique
243
+
244
+    $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre');
245
+
246
+    // il ne faut pas filtrer le autoriser voir ici
247
+    // car on met le resultat en cache, commun a tout le monde
248
+    $GLOBALS['db_art_cache'] = [];
249
+    while ($r = sql_fetch($res)) {
250
+        $t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
251
+        $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
252
+    }
253
+
254
+    $t = [$last ?: time(), $GLOBALS['db_art_cache']];
255
+    ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
256
+
257
+    return true;
258 258
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	// on renvoi un 401 qui fait echouer la requete ajax silencieusement
40 40
 	if (!autoriser('ecrire')) {
41 41
 		$retour =
42
-		'<ul class="deroulant__sous-menu" data-profondeur="1">' .
43
-			'<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
44
-				'<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
45
-					'<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
46
-				'</a>' .
47
-			'</li>' .
42
+		'<ul class="deroulant__sous-menu" data-profondeur="1">'.
43
+			'<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">'.
44
+				'<a class="deroulant__lien" href="'.generer_url_ecrire('accueil').'" data-profondeur="1">'.
45
+					'<span class="libelle">'._T('public:lien_connecter').'</span>'.
46
+				'</a>'.
47
+			'</li>'.
48 48
 		'</ul>';
49 49
 		include_spip('inc/actions');
50 50
 		ajax_retour($retour);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	if ($date = intval(_request('date'))) {
55
-		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
55
+		header('Last-Modified: '.gmdate('D, d M Y H:i:s', $date).' GMT');
56 56
 	}
57 57
 
58 58
 	$r = gen_liste_rubriques();
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
63 63
 	) {
64 64
 		include_spip('inc/headers');
65
-		header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
65
+		header('Content-Type: text/html; charset='.$GLOBALS['meta']['charset']);
66 66
 		http_response_code(304);
67 67
 		exit;
68 68
 	} else {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
  **/
86 86
 function menu_rubriques($complet = true) {
87 87
 	$ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
88
-		. '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
89
-		. '<span class="libelle">' . _T('info_tout_site') . '</span>'
88
+		. '<a class="deroulant__lien" href="'.generer_url_ecrire('plan').'" data-profondeur="1">'
89
+		. '<span class="libelle">'._T('info_tout_site').'</span>'
90 90
 		. '</a>'
91 91
 		. '</li>';
92 92
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	static $zmax = 6;
146 146
 	$profondeur_next = $profondeur + 1;
147 147
 
148
-	$nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
149
-		. '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
148
+	$nav = '<a class="deroulant__lien" href="'.generer_objet_url($id_rubrique, 'rubrique', '', '', false)."\" data-profondeur=\"$profondeur\">"
149
+		. '<span class="libelle">'.supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)).'</span>'
150 150
 		. "</a>\n";
151 151
 
152 152
 	// Limiter volontairement le nombre de sous-menus
Please login to merge, or discard this patch.
ecrire/action/redirect.php 1 patch
Indentation   +72 added lines, -72 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
 /**
@@ -36,56 +36,56 @@  discard block
 block discarded – undo
36 36
  *   ```
37 37
  **/
38 38
 function action_redirect_dist() {
39
-	$type = _request('type');
40
-	$id = intval(_request('id'));
41
-	$page = false;
39
+    $type = _request('type');
40
+    $id = intval(_request('id'));
41
+    $page = false;
42 42
 
43
-	// verifier le type ou page transmis
44
-	if (!preg_match('/^\w+$/', $type)) {
45
-		$page = _request('page');
46
-		if (!preg_match('/^\w+$/', $page)) {
47
-			return;
48
-		}
49
-	}
43
+    // verifier le type ou page transmis
44
+    if (!preg_match('/^\w+$/', $type)) {
45
+        $page = _request('page');
46
+        if (!preg_match('/^\w+$/', $page)) {
47
+            return;
48
+        }
49
+    }
50 50
 
51
-	if ($var_mode = _request('var_mode')) {
52
-		// forcer la mise a jour de l'url de cet objet !
53
-		if (!defined('_VAR_URLS')) {
54
-			define('_VAR_URLS', true);
55
-		}
56
-	}
51
+    if ($var_mode = _request('var_mode')) {
52
+        // forcer la mise a jour de l'url de cet objet !
53
+        if (!defined('_VAR_URLS')) {
54
+            define('_VAR_URLS', true);
55
+        }
56
+    }
57 57
 
58
-	if ($page) {
59
-		$url = generer_url_public($page, '', true);
60
-	} else {
61
-		$url = calculer_url_redirect_entite($type, $id, $var_mode);
62
-	}
58
+    if ($page) {
59
+        $url = generer_url_public($page, '', true);
60
+    } else {
61
+        $url = calculer_url_redirect_entite($type, $id, $var_mode);
62
+    }
63 63
 
64
-	$status = '302';
65
-	if ($url) {
66
-		if ($var_mode) {
67
-			$url = parametre_url($url, 'var_mode', $var_mode, '&');
68
-		}
64
+    $status = '302';
65
+    if ($url) {
66
+        if ($var_mode) {
67
+            $url = parametre_url($url, 'var_mode', $var_mode, '&');
68
+        }
69 69
 
70
-		if (
71
-			$var_mode == 'preview'
72
-			and defined('_PREVIEW_TOKEN')
73
-			and _PREVIEW_TOKEN
74
-			and autoriser('previsualiser')
75
-		) {
76
-			include_spip('inc/securiser_action');
77
-			$token = calculer_token_previsu($url);
78
-			$url = parametre_url($url, 'var_previewtoken', $token);
79
-		}
70
+        if (
71
+            $var_mode == 'preview'
72
+            and defined('_PREVIEW_TOKEN')
73
+            and _PREVIEW_TOKEN
74
+            and autoriser('previsualiser')
75
+        ) {
76
+            include_spip('inc/securiser_action');
77
+            $token = calculer_token_previsu($url);
78
+            $url = parametre_url($url, 'var_previewtoken', $token);
79
+        }
80 80
 
81
-		if (_request('status') and _request('status') == '301') {
82
-			$status = '301';
83
-		}
84
-	} else {
85
-		$url = generer_url_public('404', '', true);
86
-	}
81
+        if (_request('status') and _request('status') == '301') {
82
+            $status = '301';
83
+        }
84
+    } else {
85
+        $url = generer_url_public('404', '', true);
86
+    }
87 87
 
88
-	redirige_par_entete(str_replace('&amp;', '&', $url), '', $status);
88
+    redirige_par_entete(str_replace('&amp;', '&', $url), '', $status);
89 89
 }
90 90
 
91 91
 /**
@@ -100,35 +100,35 @@  discard block
 block discarded – undo
100 100
  * @return string|null
101 101
  */
102 102
 function calculer_url_redirect_entite($type, $id, $var_mode) {
103
-	$desc = null;
104
-	$publie = null;
105
-	$url = null;
106
-	// invalider le cache à chaque modif en bdd
107
-	$date = 0;
108
-	if (isset($GLOBALS['meta']['derniere_modif'])) {
109
-		$date = $GLOBALS['meta']['derniere_modif'];
110
-	}
111
-	$key = "url-$date-$type-$id";
103
+    $desc = null;
104
+    $publie = null;
105
+    $url = null;
106
+    // invalider le cache à chaque modif en bdd
107
+    $date = 0;
108
+    if (isset($GLOBALS['meta']['derniere_modif'])) {
109
+        $date = $GLOBALS['meta']['derniere_modif'];
110
+    }
111
+    $key = "url-$date-$type-$id";
112 112
 
113
-	// Obtenir l’url et si elle est publié du cache memoization
114
-	if (function_exists('cache_get') and $desc = cache_get($key)) {
115
-		[$url, $publie] = $desc;
116
-	}
117
-	// Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie
118
-	if (empty($desc) or $var_mode) {
119
-		$publie = objet_test_si_publie($type, $id);
120
-		$url = generer_objet_url_absolue($id, $type, '', '', true);
121
-		if (function_exists('cache_set')) {
122
-			cache_set($key, [$url, $publie], 3600);
123
-		}
124
-	}
113
+    // Obtenir l’url et si elle est publié du cache memoization
114
+    if (function_exists('cache_get') and $desc = cache_get($key)) {
115
+        [$url, $publie] = $desc;
116
+    }
117
+    // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie
118
+    if (empty($desc) or $var_mode) {
119
+        $publie = objet_test_si_publie($type, $id);
120
+        $url = generer_objet_url_absolue($id, $type, '', '', true);
121
+        if (function_exists('cache_set')) {
122
+            cache_set($key, [$url, $publie], 3600);
123
+        }
124
+    }
125 125
 
126
-	// On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation
127
-	if ($publie) {
128
-		return $url;
129
-	} elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) {
130
-		return $url;
131
-	}
126
+    // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation
127
+    if ($publie) {
128
+        return $url;
129
+    } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) {
130
+        return $url;
131
+    }
132 132
 
133
-	return;
133
+    return;
134 134
 }
Please login to merge, or discard this patch.
ecrire/inc/urls.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	) {
204 204
 		$r = nettoyer_url_page($url, $contexte);
205 205
 		if ($r) {
206
-			[$contexte, $type, , , $suite] = $r;
206
+			[$contexte, $type,,, $suite] = $r;
207 207
 			$_id = id_table_objet($type);
208 208
 			$id_objet = $contexte[$_id];
209 209
 			$url_propre = generer_objet_url($id_objet, $type);
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
  */
275 275
 function nettoyer_url_page($url, $contexte = []) {
276 276
 	$url_objets = urls_liste_objets();
277
-	$raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,';
278
-	$raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
279
-	$raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,';
277
+	$raccourci_url_page_html = ',^(?:[^?]*/)?('.$url_objets.')([0-9]+)(?:\.html)?([?&].*)?$,';
278
+	$raccourci_url_page_id = ',^(?:[^?]*/)?('.$url_objets.')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
279
+	$raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('.$url_objets.')([0-9]+)=?(&.*)?$,';
280 280
 
281 281
 	if (
282 282
 		preg_match($raccourci_url_page_html, $url, $regs)
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 	$id = intval($id);
315 315
 	if (!isset($furls[$objet])) {
316 316
 		if (
317
-			function_exists($f = 'generer_' . $objet . '_url_ecrire')
317
+			function_exists($f = 'generer_'.$objet.'_url_ecrire')
318 318
 			// ou definie par un plugin
319 319
 			or $f = charger_fonction($f, 'urls', true)
320 320
 			// deprecated
321
-			or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true)
321
+			or function_exists($f = 'generer_url_ecrire_'.$objet) or $f = charger_fonction($f, 'urls', true)
322 322
 		) {
323 323
 			$furls[$objet] = $f;
324 324
 		} else {
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
 	if ($public or $connect) {
337 337
 		return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect);
338 338
 	}
339
-	$a = id_table_objet($objet) . '=' . intval($id);
339
+	$a = id_table_objet($objet).'='.intval($id);
340 340
 	if (!function_exists('objet_info')) {
341 341
 		include_spip('inc/filtres');
342 342
 	}
343 343
 
344
-	return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : '');
344
+	return generer_url_ecrire(objet_info($objet, 'url_voir'), $a.($args ? "&$args" : '')).($ancre ? "#$ancre" : '');
345 345
 }
346 346
 
347 347
 /**
Please login to merge, or discard this patch.
Indentation   +205 added lines, -205 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
 include_spip('base/objets');
23 23
 
@@ -57,106 +57,106 @@  discard block
 block discarded – undo
57 57
  *
58 58
  */
59 59
 function urls_decoder_url($url, $fond = '', $contexte = [], $assembler = false) {
60
-	static $current_base = null;
60
+    static $current_base = null;
61 61
 
62
-	// les anciennes fonctions modifient directement les globales
63
-	// on les sauve avant l'appel, et on les retablit apres !
64
-	$save = [
65
-		$GLOBALS['fond'] ?? null,
66
-		$GLOBALS['contexte'] ?? null,
67
-		$_SERVER['REDIRECT_url_propre'] ?? null,
68
-		$_ENV['url_propre'] ?? null,
69
-		$GLOBALS['profondeur_url']
70
-	];
62
+    // les anciennes fonctions modifient directement les globales
63
+    // on les sauve avant l'appel, et on les retablit apres !
64
+    $save = [
65
+        $GLOBALS['fond'] ?? null,
66
+        $GLOBALS['contexte'] ?? null,
67
+        $_SERVER['REDIRECT_url_propre'] ?? null,
68
+        $_ENV['url_propre'] ?? null,
69
+        $GLOBALS['profondeur_url']
70
+    ];
71 71
 
72
-	if (is_null($current_base)) {
73
-		include_spip('inc/filtres_mini');
74
-		// le decodage des urls se fait toujours par rapport au site public
75
-		$current_base = url_absolue(_DIR_RACINE ?: './');
76
-	}
77
-	if (strncmp($url, $current_base, strlen($current_base)) == 0) {
78
-		$url = substr($url, strlen($current_base));
79
-	}
72
+    if (is_null($current_base)) {
73
+        include_spip('inc/filtres_mini');
74
+        // le decodage des urls se fait toujours par rapport au site public
75
+        $current_base = url_absolue(_DIR_RACINE ?: './');
76
+    }
77
+    if (strncmp($url, $current_base, strlen($current_base)) == 0) {
78
+        $url = substr($url, strlen($current_base));
79
+    }
80 80
 
81
-	// si on est en train d'assembler la page principale,
82
-	// recuperer l'url depuis les globales url propres si fournies
83
-	// sinon extraire la bonne portion d'url
84
-	if ($assembler) {
85
-		if (isset($_SERVER['REDIRECT_url_propre'])) {
86
-			$url = $_SERVER['REDIRECT_url_propre'];
87
-		} elseif (isset($_ENV['url_propre'])) {
88
-			$url = $_ENV['url_propre'];
89
-		} else {
90
-			$qs = explode('?', $url);
91
-			// ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee
92
-			$url = ltrim($qs[0], '/');
93
-			$url = explode('/', $url);
94
-			while (count($url) > $GLOBALS['profondeur_url'] + 1) {
95
-				array_shift($url);
96
-			}
97
-			$qs[0] = implode('/', $url);
98
-			$url = implode('?', $qs);
99
-		}
100
-	}
81
+    // si on est en train d'assembler la page principale,
82
+    // recuperer l'url depuis les globales url propres si fournies
83
+    // sinon extraire la bonne portion d'url
84
+    if ($assembler) {
85
+        if (isset($_SERVER['REDIRECT_url_propre'])) {
86
+            $url = $_SERVER['REDIRECT_url_propre'];
87
+        } elseif (isset($_ENV['url_propre'])) {
88
+            $url = $_ENV['url_propre'];
89
+        } else {
90
+            $qs = explode('?', $url);
91
+            // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee
92
+            $url = ltrim($qs[0], '/');
93
+            $url = explode('/', $url);
94
+            while (count($url) > $GLOBALS['profondeur_url'] + 1) {
95
+                array_shift($url);
96
+            }
97
+            $qs[0] = implode('/', $url);
98
+            $url = implode('?', $qs);
99
+        }
100
+    }
101 101
 
102
-	unset($_SERVER['REDIRECT_url_propre']);
103
-	unset($_ENV['url_propre']);
104
-	include_spip('inc/filtres_mini');
105
-	if (strpos($url, '://') === false) {
106
-		$GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/');
107
-	} else {
108
-		$GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/'));
109
-	}
102
+    unset($_SERVER['REDIRECT_url_propre']);
103
+    unset($_ENV['url_propre']);
104
+    include_spip('inc/filtres_mini');
105
+    if (strpos($url, '://') === false) {
106
+        $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/');
107
+    } else {
108
+        $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/'));
109
+    }
110 110
 
111
-	$url_redirect = '';
112
-	$decoder = charger_fonction_url('decoder');
113
-	if ($decoder) {
114
-		$a = $decoder($url, $fond, $contexte);
115
-		if (is_array($a)) {
116
-			[$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null);
117
-			$url_redirect ??= '';
118
-			if ($url_redirect === $url) {
119
-				$url_redirect = '';
120
-			} // securite pour eviter une redirection infinie
121
-			if ($assembler and strlen($url_redirect)) {
122
-				spip_log("Redirige $url vers $url_redirect");
123
-				include_spip('inc/headers');
124
-				redirige_par_entete($url_redirect, '', 301);
125
-			}
126
-			if (isset($nfond)) {
127
-				$fond = $nfond;
128
-			} else {
129
-				if (
130
-					$fond == ''
131
-					or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */
132
-				) {
133
-					$fond = $type;
134
-				}
135
-			}
136
-			if (isset($ncontexte)) {
137
-				$contexte = $ncontexte;
138
-			}
139
-			if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
140
-				$contexte['type'] = $type;
141
-			}
142
-			if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
143
-				$contexte['type-page'] = $type;
144
-			}
145
-		}
146
-	}
111
+    $url_redirect = '';
112
+    $decoder = charger_fonction_url('decoder');
113
+    if ($decoder) {
114
+        $a = $decoder($url, $fond, $contexte);
115
+        if (is_array($a)) {
116
+            [$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null);
117
+            $url_redirect ??= '';
118
+            if ($url_redirect === $url) {
119
+                $url_redirect = '';
120
+            } // securite pour eviter une redirection infinie
121
+            if ($assembler and strlen($url_redirect)) {
122
+                spip_log("Redirige $url vers $url_redirect");
123
+                include_spip('inc/headers');
124
+                redirige_par_entete($url_redirect, '', 301);
125
+            }
126
+            if (isset($nfond)) {
127
+                $fond = $nfond;
128
+            } else {
129
+                if (
130
+                    $fond == ''
131
+                    or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */
132
+                ) {
133
+                    $fond = $type;
134
+                }
135
+            }
136
+            if (isset($ncontexte)) {
137
+                $contexte = $ncontexte;
138
+            }
139
+            if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
140
+                $contexte['type'] = $type;
141
+            }
142
+            if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
143
+                $contexte['type-page'] = $type;
144
+            }
145
+        }
146
+    }
147 147
 
148
-	// retablir les globales
149
-	[$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save;
148
+    // retablir les globales
149
+    [$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save;
150 150
 
151
-	// vider les globales url propres qui ne doivent plus etre utilisees en cas
152
-	// d'inversion url => objet
153
-	// maintenir pour compat ?
154
-	#if ($assembler) {
155
-	#	unset($_SERVER['REDIRECT_url_propre']);
156
-	#	unset($_ENV['url_propre']);
157
-	#}
151
+    // vider les globales url propres qui ne doivent plus etre utilisees en cas
152
+    // d'inversion url => objet
153
+    // maintenir pour compat ?
154
+    #if ($assembler) {
155
+    #	unset($_SERVER['REDIRECT_url_propre']);
156
+    #	unset($_ENV['url_propre']);
157
+    #}
158 158
 
159
-	return [$fond, $contexte, $url_redirect];
159
+    return [$fond, $contexte, $url_redirect];
160 160
 }
161 161
 
162 162
 /**
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
  * @return array|false|string
170 170
  */
171 171
 function urls_transition_retrouver_anciennes_url_propres(string $url_propre, string $entite, array $contexte = []): array {
172
-	if ($url_propre) {
173
-		if ($GLOBALS['profondeur_url'] <= 0) {
174
-			$urls_anciennes = charger_fonction_url('decoder', 'propres');
175
-		} else {
176
-			$urls_anciennes = charger_fonction_url('decoder', 'arbo');
177
-		}
172
+    if ($url_propre) {
173
+        if ($GLOBALS['profondeur_url'] <= 0) {
174
+            $urls_anciennes = charger_fonction_url('decoder', 'propres');
175
+        } else {
176
+            $urls_anciennes = charger_fonction_url('decoder', 'arbo');
177
+        }
178 178
 
179
-		if ($urls_anciennes) {
180
-			$urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte);
181
-		}
182
-		return $urls_anciennes ?: [];
183
-	}
179
+        if ($urls_anciennes) {
180
+            $urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte);
181
+        }
182
+        return $urls_anciennes ?: [];
183
+    }
184 184
 
185
-	return [];
185
+    return [];
186 186
 }
187 187
 
188 188
 /**
@@ -195,41 +195,41 @@  discard block
 block discarded – undo
195 195
  * @return array|false|string
196 196
  */
197 197
 function urls_transition_retrouver_anciennes_url_html(string $url, string $entite, array $contexte = []): array {
198
-	// Migration depuis anciennes URLs ?
199
-	// traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23
200
-	if (
201
-		$url
202
-		and $GLOBALS['profondeur_url'] <= 0
203
-	) {
204
-		$r = nettoyer_url_page($url, $contexte);
205
-		if ($r) {
206
-			[$contexte, $type, , , $suite] = $r;
207
-			$_id = id_table_objet($type);
208
-			$id_objet = $contexte[$_id];
209
-			$url_propre = generer_objet_url($id_objet, $type);
210
-			if (
211
-				strlen($url_propre)
212
-				and !strstr($url, (string) $url_propre)
213
-				and (
214
-					objet_test_si_publie($type, $id_objet)
215
-					or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet))
216
-				)
217
-			) {
218
-				[, $hash] = array_pad(explode('#', $url_propre), 2, '');
219
-				$args = [];
220
-				foreach (array_filter(explode('&', $suite ?? '')) as $fragment) {
221
-					if ($fragment != "$_id=$id_objet") {
222
-						$args[] = $fragment;
223
-					}
224
-				}
225
-				$url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash);
198
+    // Migration depuis anciennes URLs ?
199
+    // traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23
200
+    if (
201
+        $url
202
+        and $GLOBALS['profondeur_url'] <= 0
203
+    ) {
204
+        $r = nettoyer_url_page($url, $contexte);
205
+        if ($r) {
206
+            [$contexte, $type, , , $suite] = $r;
207
+            $_id = id_table_objet($type);
208
+            $id_objet = $contexte[$_id];
209
+            $url_propre = generer_objet_url($id_objet, $type);
210
+            if (
211
+                strlen($url_propre)
212
+                and !strstr($url, (string) $url_propre)
213
+                and (
214
+                    objet_test_si_publie($type, $id_objet)
215
+                    or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet))
216
+                )
217
+            ) {
218
+                [, $hash] = array_pad(explode('#', $url_propre), 2, '');
219
+                $args = [];
220
+                foreach (array_filter(explode('&', $suite ?? '')) as $fragment) {
221
+                    if ($fragment != "$_id=$id_objet") {
222
+                        $args[] = $fragment;
223
+                    }
224
+                }
225
+                $url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash);
226 226
 
227
-				return [$contexte, $type, $url_redirect, $type];
228
-			}
229
-		}
230
-	}
231
-	/* Fin compatibilite anciennes urls */
232
-	return [];
227
+                return [$contexte, $type, $url_redirect, $type];
228
+            }
229
+        }
230
+    }
231
+    /* Fin compatibilite anciennes urls */
232
+    return [];
233 233
 }
234 234
 
235 235
 /**
@@ -242,24 +242,24 @@  discard block
 block discarded – undo
242 242
  * @return string|array
243 243
  */
244 244
 function urls_liste_objets($preg = true) {
245
-	static $url_objets = null;
246
-	if (is_null($url_objets)) {
247
-		$url_objets = [];
248
-		// recuperer les tables_objets_sql declarees
249
-		$tables_objets = lister_tables_objets_sql();
250
-		foreach ($tables_objets as $t => $infos) {
251
-			if ($infos['page']) {
252
-				$url_objets[] = $infos['type'];
253
-				$url_objets = array_merge($url_objets, $infos['type_surnoms']);
254
-			}
255
-		}
256
-		$url_objets = pipeline('declarer_url_objets', $url_objets);
257
-	}
258
-	if (!$preg) {
259
-		return $url_objets;
260
-	}
245
+    static $url_objets = null;
246
+    if (is_null($url_objets)) {
247
+        $url_objets = [];
248
+        // recuperer les tables_objets_sql declarees
249
+        $tables_objets = lister_tables_objets_sql();
250
+        foreach ($tables_objets as $t => $infos) {
251
+            if ($infos['page']) {
252
+                $url_objets[] = $infos['type'];
253
+                $url_objets = array_merge($url_objets, $infos['type_surnoms']);
254
+            }
255
+        }
256
+        $url_objets = pipeline('declarer_url_objets', $url_objets);
257
+    }
258
+    if (!$preg) {
259
+        return $url_objets;
260
+    }
261 261
 
262
-	return implode('|', array_map('preg_quote', $url_objets));
262
+    return implode('|', array_map('preg_quote', $url_objets));
263 263
 }
264 264
 
265 265
 /**
@@ -273,26 +273,26 @@  discard block
 block discarded – undo
273 273
  * @return array
274 274
  */
275 275
 function nettoyer_url_page($url, $contexte = []) {
276
-	$url_objets = urls_liste_objets();
277
-	$raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,';
278
-	$raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
279
-	$raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,';
276
+    $url_objets = urls_liste_objets();
277
+    $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,';
278
+    $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
279
+    $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,';
280 280
 
281
-	if (
282
-		preg_match($raccourci_url_page_html, $url, $regs)
283
-		or preg_match($raccourci_url_page_id, $url, $regs)
284
-		or preg_match($raccourci_url_page_spip, $url, $regs)
285
-	) {
286
-		$regs = array_pad($regs, 4, null);
287
-		$type = objet_type($regs[1]);
288
-		$_id = id_table_objet($type);
289
-		$contexte[$_id] = $regs[2];
290
-		$suite = $regs[3];
281
+    if (
282
+        preg_match($raccourci_url_page_html, $url, $regs)
283
+        or preg_match($raccourci_url_page_id, $url, $regs)
284
+        or preg_match($raccourci_url_page_spip, $url, $regs)
285
+    ) {
286
+        $regs = array_pad($regs, 4, null);
287
+        $type = objet_type($regs[1]);
288
+        $_id = id_table_objet($type);
289
+        $contexte[$_id] = $regs[2];
290
+        $suite = $regs[3];
291 291
 
292
-		return [$contexte, $type, null, $type, $suite];
293
-	}
292
+        return [$contexte, $type, null, $type, $suite];
293
+    }
294 294
 
295
-	return [];
295
+    return [];
296 296
 }
297 297
 
298 298
 /**
@@ -310,38 +310,38 @@  discard block
 block discarded – undo
310 310
  * @return string
311 311
  */
312 312
 function generer_objet_url_ecrire($id, string $objet, string $args = '', string $ancre = '', ?bool $public = null, string $connect = ''): string {
313
-	static $furls = [];
314
-	$id = intval($id);
315
-	if (!isset($furls[$objet])) {
316
-		if (
317
-			function_exists($f = 'generer_' . $objet . '_url_ecrire')
318
-			// ou definie par un plugin
319
-			or $f = charger_fonction($f, 'urls', true)
320
-			// deprecated
321
-			or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true)
322
-		) {
323
-			$furls[$objet] = $f;
324
-		} else {
325
-			$furls[$objet] = '';
326
-		}
327
-	}
328
-	if ($furls[$objet]) {
329
-		return $furls[$objet]($id, $args, $ancre, $public, $connect);
330
-	}
331
-	// si pas de flag public fourni
332
-	// le calculer en fonction de la declaration de statut
333
-	if (is_null($public) and !$connect) {
334
-		$public = objet_test_si_publie($objet, $id, $connect);
335
-	}
336
-	if ($public or $connect) {
337
-		return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect);
338
-	}
339
-	$a = id_table_objet($objet) . '=' . intval($id);
340
-	if (!function_exists('objet_info')) {
341
-		include_spip('inc/filtres');
342
-	}
313
+    static $furls = [];
314
+    $id = intval($id);
315
+    if (!isset($furls[$objet])) {
316
+        if (
317
+            function_exists($f = 'generer_' . $objet . '_url_ecrire')
318
+            // ou definie par un plugin
319
+            or $f = charger_fonction($f, 'urls', true)
320
+            // deprecated
321
+            or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true)
322
+        ) {
323
+            $furls[$objet] = $f;
324
+        } else {
325
+            $furls[$objet] = '';
326
+        }
327
+    }
328
+    if ($furls[$objet]) {
329
+        return $furls[$objet]($id, $args, $ancre, $public, $connect);
330
+    }
331
+    // si pas de flag public fourni
332
+    // le calculer en fonction de la declaration de statut
333
+    if (is_null($public) and !$connect) {
334
+        $public = objet_test_si_publie($objet, $id, $connect);
335
+    }
336
+    if ($public or $connect) {
337
+        return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect);
338
+    }
339
+    $a = id_table_objet($objet) . '=' . intval($id);
340
+    if (!function_exists('objet_info')) {
341
+        include_spip('inc/filtres');
342
+    }
343 343
 
344
-	return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : '');
344
+    return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : '');
345 345
 }
346 346
 
347 347
 /**
@@ -349,5 +349,5 @@  discard block
 block discarded – undo
349 349
  * @see generer_objet_url_ecrire
350 350
  */
351 351
 function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, string $connect = '') {
352
-	return generer_objet_url_ecrire($id, $objet, $args, $ancre, $public, $connect);
352
+    return generer_objet_url_ecrire($id, $objet, $args, $ancre, $public, $connect);
353 353
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_liste.php 2 patches
Indentation   +75 added lines, -75 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
 include_spip('inc/charsets');
17 17
 
@@ -27,90 +27,90 @@  discard block
 block discarded – undo
27 27
  * @return string
28 28
  */
29 29
 function plugins_afficher_liste_dist(
30
-	$url_page,
31
-	$liste_plugins,
32
-	$liste_plugins_checked,
33
-	$liste_plugins_actifs,
34
-	$dir_plugins = _DIR_PLUGINS,
35
-	$afficher_un = 'afficher_plugin'
30
+    $url_page,
31
+    $liste_plugins,
32
+    $liste_plugins_checked,
33
+    $liste_plugins_actifs,
34
+    $dir_plugins = _DIR_PLUGINS,
35
+    $afficher_un = 'afficher_plugin'
36 36
 ) {
37
-	$get_infos = charger_fonction('get_infos', 'plugins');
38
-	$ligne_plug = charger_fonction($afficher_un, 'plugins');
37
+    $get_infos = charger_fonction('get_infos', 'plugins');
38
+    $ligne_plug = charger_fonction($afficher_un, 'plugins');
39 39
 
40
-	$all_infos = $get_infos($liste_plugins, false, $dir_plugins);
40
+    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
41 41
 
42
-	$all_infos = pipeline(
43
-		'filtrer_liste_plugins',
44
-		[
45
-			'args' => [
46
-				'liste_plugins' => $liste_plugins,
47
-				'liste_plugins_checked' => $liste_plugins_checked,
48
-				'liste_plugins_actifs' => $liste_plugins_actifs,
49
-				'dir_plugins' => $dir_plugins
50
-			],
51
-			'data' => $all_infos
52
-		]
53
-	);
42
+    $all_infos = pipeline(
43
+        'filtrer_liste_plugins',
44
+        [
45
+            'args' => [
46
+                'liste_plugins' => $liste_plugins,
47
+                'liste_plugins_checked' => $liste_plugins_checked,
48
+                'liste_plugins_actifs' => $liste_plugins_actifs,
49
+                'dir_plugins' => $dir_plugins
50
+            ],
51
+            'data' => $all_infos
52
+        ]
53
+    );
54 54
 
55
-	$liste_plugins = array_flip($liste_plugins);
56
-	foreach ($liste_plugins as $chemin => $v) {
57
-		// des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
-		if (isset($all_infos[$chemin])) {
59
-			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
-		} else {
61
-			unset($liste_plugins[$chemin]);
62
-		}
63
-	}
64
-	asort($liste_plugins);
65
-	$exposed = urldecode(_request('plugin') ?? '');
55
+    $liste_plugins = array_flip($liste_plugins);
56
+    foreach ($liste_plugins as $chemin => $v) {
57
+        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
+        if (isset($all_infos[$chemin])) {
59
+            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
+        } else {
61
+            unset($liste_plugins[$chemin]);
62
+        }
63
+    }
64
+    asort($liste_plugins);
65
+    $exposed = urldecode(_request('plugin') ?? '');
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
68
-	$fast_liste_plugins_actifs = [];
69
-	$fast_liste_plugins_checked = [];
70
-	if (is_array($liste_plugins_actifs)) {
71
-		$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
-	}
73
-	if (is_array($liste_plugins_checked)) {
74
-		$fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
-	}
67
+    $block_par_lettre = false;//count($liste_plugins)>10;
68
+    $fast_liste_plugins_actifs = [];
69
+    $fast_liste_plugins_checked = [];
70
+    if (is_array($liste_plugins_actifs)) {
71
+        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
+    }
73
+    if (is_array($liste_plugins_checked)) {
74
+        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
+    }
76 76
 
77
-	$res = '';
78
-	$block = '';
79
-	$initiale = '';
80
-	$block_actif = false;
81
-	foreach ($liste_plugins as $plug => $nom) {
82
-		if (($i = substr($nom, 0, 1)) !== $initiale) {
83
-			$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
-			$initiale = $i;
85
-			$block = '';
86
-			$block_actif = false;
87
-		}
88
-		// le rep suivant
89
-		$actif = isset($fast_liste_plugins_actifs[$plug]);
90
-		$checked = isset($fast_liste_plugins_checked[$plug]);
91
-		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
93
-			$dir_plugins,
94
-			strlen(_DIR_RACINE)
95
-		) . $plug));
96
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
97
-	}
98
-	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99
-	$class = basename($dir_plugins);
77
+    $res = '';
78
+    $block = '';
79
+    $initiale = '';
80
+    $block_actif = false;
81
+    foreach ($liste_plugins as $plug => $nom) {
82
+        if (($i = substr($nom, 0, 1)) !== $initiale) {
83
+            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
+            $initiale = $i;
85
+            $block = '';
86
+            $block_actif = false;
87
+        }
88
+        // le rep suivant
89
+        $actif = isset($fast_liste_plugins_actifs[$plug]);
90
+        $checked = isset($fast_liste_plugins_checked[$plug]);
91
+        $block_actif = $block_actif | $actif;
92
+        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
93
+            $dir_plugins,
94
+            strlen(_DIR_RACINE)
95
+        ) . $plug));
96
+        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
97
+    }
98
+    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99
+    $class = basename($dir_plugins);
100 100
 
101
-	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
101
+    return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
102 102
 }
103 103
 
104 104
 
105 105
 function affiche_block_initiale($initiale, $block, $block_actif) {
106
-	if (strlen($block)) {
107
-		return "<li class='item'>"
108
-		. bouton_block_depliable($initiale, $block_actif ? true : false)
109
-		. debut_block_depliable($block_actif)
110
-		. "<ul>$block</ul>"
111
-		. fin_block()
112
-		. '</li>';
113
-	}
106
+    if (strlen($block)) {
107
+        return "<li class='item'>"
108
+        . bouton_block_depliable($initiale, $block_actif ? true : false)
109
+        . debut_block_depliable($block_actif)
110
+        . "<ul>$block</ul>"
111
+        . fin_block()
112
+        . '</li>';
113
+    }
114 114
 
115
-	return '';
115
+    return '';
116 116
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	asort($liste_plugins);
65 65
 	$exposed = urldecode(_request('plugin') ?? '');
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
67
+	$block_par_lettre = false; //count($liste_plugins)>10;
68 68
 	$fast_liste_plugins_actifs = [];
69 69
 	$fast_liste_plugins_checked = [];
70 70
 	if (is_array($liste_plugins_actifs)) {
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 		$actif = isset($fast_liste_plugins_actifs[$plug]);
90 90
 		$checked = isset($fast_liste_plugins_checked[$plug]);
91 91
 		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
92
+		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins.$plug or $exposed == substr(
93 93
 			$dir_plugins,
94 94
 			strlen(_DIR_RACINE)
95
-		) . $plug));
96
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
95
+		).$plug));
96
+		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins)."\n";
97 97
 	}
98 98
 	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99 99
 	$class = basename($dir_plugins);
Please login to merge, or discard this patch.