Completed
Push — master ( 567fae...5b6c4c )
by cam
01:19
created
ecrire/inc/layer.php 2 patches
Indentation   +109 added lines, -109 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
 /**
@@ -26,70 +26,70 @@  discard block
 block discarded – undo
26 26
  * @return string Code HTML du cadre dépliable
27 27
  **/
28 28
 function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') {
29
-	$bouton = bouton_block_depliable($titre, $deplie, $ids);
30
-
31
-	return
32
-		debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
33
-		. debut_block_depliable($deplie, $ids)
34
-		. "<div class='cadre_padding'>\n"
35
-		. $contenu
36
-		. "</div>\n"
37
-		. fin_block()
38
-		. fin_cadre();
29
+    $bouton = bouton_block_depliable($titre, $deplie, $ids);
30
+
31
+    return
32
+        debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
33
+        . debut_block_depliable($deplie, $ids)
34
+        . "<div class='cadre_padding'>\n"
35
+        . $contenu
36
+        . "</div>\n"
37
+        . fin_block()
38
+        . fin_cadre();
39 39
 }
40 40
 
41 41
 function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) {
42
-	return "\n"
43
-	. bouton_block_depliable($invite, $visible, $nom)
44
-	. debut_block_depliable($visible, $nom)
45
-	. $masque
46
-	. fin_block();
42
+    return "\n"
43
+    . bouton_block_depliable($invite, $visible, $nom)
44
+    . debut_block_depliable($visible, $nom)
45
+    . $masque
46
+    . fin_block();
47 47
 }
48 48
 
49 49
 function debut_block_depliable($deplie, $id = '') {
50
-	$class = ' blocdeplie';
51
-	// si on n'accepte pas js, ne pas fermer
52
-	if (!$deplie) {
53
-		$class = ' blocreplie';
54
-	}
50
+    $class = ' blocdeplie';
51
+    // si on n'accepte pas js, ne pas fermer
52
+    if (!$deplie) {
53
+        $class = ' blocreplie';
54
+    }
55 55
 
56
-	return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
56
+    return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
57 57
 }
58 58
 
59 59
 function fin_block() {
60
-	return "<div class='nettoyeur'></div>\n</div>";
60
+    return "<div class='nettoyeur'></div>\n</div>";
61 61
 }
62 62
 
63 63
 // $texte : texte du bouton
64 64
 // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page
65 65
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
66 66
 function bouton_block_depliable($texte, $deplie, $ids = '') {
67
-	$bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
68
-
69
-	$class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
70
-	if (strlen($ids)) {
71
-		$cible = explode(',', $ids);
72
-		$cible = '#' . implode(',#', $cible);
73
-	} else {
74
-		$cible = "#$bouton_id + div.bloc_depliable";
75
-	}
76
-
77
-	$b = (strpos($texte, '<h') === false ? 'h3' : 'div');
78
-
79
-	return "<$b "
80
-	. ($bouton_id ? "id='$bouton_id' " : '')
81
-	. "class='titrem$class'"
82
-	. (($deplie === -1)
83
-		? ''
84
-		: " onmouseover=\"jQuery(this).depliant('$cible');\""
85
-	)
86
-	. '>'
87
-	// une ancre pour rendre accessible au clavier le depliage du sous bloc
88
-	. "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
89
-	. "$texte</$b>"
90
-	. http_script(($deplie === 'incertain')
91
-		? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
92
-		: '');
67
+    $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
68
+
69
+    $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
70
+    if (strlen($ids)) {
71
+        $cible = explode(',', $ids);
72
+        $cible = '#' . implode(',#', $cible);
73
+    } else {
74
+        $cible = "#$bouton_id + div.bloc_depliable";
75
+    }
76
+
77
+    $b = (strpos($texte, '<h') === false ? 'h3' : 'div');
78
+
79
+    return "<$b "
80
+    . ($bouton_id ? "id='$bouton_id' " : '')
81
+    . "class='titrem$class'"
82
+    . (($deplie === -1)
83
+        ? ''
84
+        : " onmouseover=\"jQuery(this).depliant('$cible');\""
85
+    )
86
+    . '>'
87
+    // une ancre pour rendre accessible au clavier le depliage du sous bloc
88
+    . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
89
+    . "$texte</$b>"
90
+    . http_script(($deplie === 'incertain')
91
+        ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
92
+        : '');
93 93
 }
94 94
 
95 95
 //
@@ -97,66 +97,66 @@  discard block
 block discarded – undo
97 97
 //
98 98
 function verif_butineur() {
99 99
 
100
-	preg_match(',^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,', $_SERVER['HTTP_USER_AGENT'], $match);
101
-	$GLOBALS['browser_name'] = $match[1];
102
-	$GLOBALS['browser_version'] = $match[2];
103
-	$GLOBALS['browser_description'] = $match[3];
104
-	$GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
105
-	$GLOBALS['browser_barre'] = '';
106
-
107
-	if (!preg_match(',opera,i', $GLOBALS['browser_description']) && preg_match(',opera,i', $GLOBALS['browser_name'])) {
108
-		$GLOBALS['browser_name'] = 'Opera';
109
-		$GLOBALS['browser_version'] = $match[2];
110
-		$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
111
-	} else {
112
-		if (preg_match(',opera,i', $GLOBALS['browser_description'])) {
113
-			preg_match(',Opera ([^\ ]*),i', $GLOBALS['browser_description'], $match);
114
-			$GLOBALS['browser_name'] = 'Opera';
115
-			$GLOBALS['browser_version'] = $match[1];
116
-			$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
117
-		} else {
118
-			if (preg_match(',msie,i', $GLOBALS['browser_description'])) {
119
-				preg_match(',MSIE ([^;]*),i', $GLOBALS['browser_description'], $match);
120
-				$GLOBALS['browser_name'] = 'MSIE';
121
-				$GLOBALS['browser_version'] = $match[1];
122
-				$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5);
123
-			} else {
124
-				if (
125
-					preg_match(',KHTML,i', $GLOBALS['browser_description']) &&
126
-					preg_match(',Safari/([^;]*),', $GLOBALS['browser_description'], $match)
127
-				) {
128
-					$GLOBALS['browser_name'] = 'Safari';
129
-					$GLOBALS['browser_version'] = $match[1];
130
-					$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0);
131
-				} else {
132
-					if (preg_match(',mozilla,i', $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) {
133
-						// Numero de version pour Mozilla "authentique"
134
-						if (preg_match(',rv:([0-9]+\.[0-9]+),', $GLOBALS['browser_description'], $match)) {
135
-							$GLOBALS['browser_rev'] = doubleval($match[1]);
136
-						} // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
137
-						else {
138
-							if (
139
-								strpos($GLOBALS['browser_description'], 'Gecko') and !strpos(
140
-									$GLOBALS['browser_description'],
141
-									'KHTML'
142
-								)
143
-							) {
144
-								$GLOBALS['browser_rev'] = 1.4;
145
-							} // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
146
-							else {
147
-								$GLOBALS['browser_rev'] = 1.0;
148
-							}
149
-						}
150
-						$GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3;
151
-					}
152
-				}
153
-			}
154
-		}
155
-	}
156
-
157
-	if (!$GLOBALS['browser_name']) {
158
-		$GLOBALS['browser_name'] = 'Mozilla';
159
-	}
100
+    preg_match(',^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,', $_SERVER['HTTP_USER_AGENT'], $match);
101
+    $GLOBALS['browser_name'] = $match[1];
102
+    $GLOBALS['browser_version'] = $match[2];
103
+    $GLOBALS['browser_description'] = $match[3];
104
+    $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
105
+    $GLOBALS['browser_barre'] = '';
106
+
107
+    if (!preg_match(',opera,i', $GLOBALS['browser_description']) && preg_match(',opera,i', $GLOBALS['browser_name'])) {
108
+        $GLOBALS['browser_name'] = 'Opera';
109
+        $GLOBALS['browser_version'] = $match[2];
110
+        $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
111
+    } else {
112
+        if (preg_match(',opera,i', $GLOBALS['browser_description'])) {
113
+            preg_match(',Opera ([^\ ]*),i', $GLOBALS['browser_description'], $match);
114
+            $GLOBALS['browser_name'] = 'Opera';
115
+            $GLOBALS['browser_version'] = $match[1];
116
+            $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
117
+        } else {
118
+            if (preg_match(',msie,i', $GLOBALS['browser_description'])) {
119
+                preg_match(',MSIE ([^;]*),i', $GLOBALS['browser_description'], $match);
120
+                $GLOBALS['browser_name'] = 'MSIE';
121
+                $GLOBALS['browser_version'] = $match[1];
122
+                $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5);
123
+            } else {
124
+                if (
125
+                    preg_match(',KHTML,i', $GLOBALS['browser_description']) &&
126
+                    preg_match(',Safari/([^;]*),', $GLOBALS['browser_description'], $match)
127
+                ) {
128
+                    $GLOBALS['browser_name'] = 'Safari';
129
+                    $GLOBALS['browser_version'] = $match[1];
130
+                    $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0);
131
+                } else {
132
+                    if (preg_match(',mozilla,i', $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) {
133
+                        // Numero de version pour Mozilla "authentique"
134
+                        if (preg_match(',rv:([0-9]+\.[0-9]+),', $GLOBALS['browser_description'], $match)) {
135
+                            $GLOBALS['browser_rev'] = doubleval($match[1]);
136
+                        } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
137
+                        else {
138
+                            if (
139
+                                strpos($GLOBALS['browser_description'], 'Gecko') and !strpos(
140
+                                    $GLOBALS['browser_description'],
141
+                                    'KHTML'
142
+                                )
143
+                            ) {
144
+                                $GLOBALS['browser_rev'] = 1.4;
145
+                            } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
146
+                            else {
147
+                                $GLOBALS['browser_rev'] = 1.0;
148
+                            }
149
+                        }
150
+                        $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3;
151
+                    }
152
+                }
153
+            }
154
+        }
155
+    }
156
+
157
+    if (!$GLOBALS['browser_name']) {
158
+        $GLOBALS['browser_name'] = 'Mozilla';
159
+    }
160 160
 }
161 161
 
162 162
 verif_butineur();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$class = ' blocreplie';
54 54
 	}
55 55
 
56
-	return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
56
+	return '<div '.($id ? "id='$id' " : '')."class='bloc_depliable$class'>";
57 57
 }
58 58
 
59 59
 function fin_block() {
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page
65 65
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
66 66
 function bouton_block_depliable($texte, $deplie, $ids = '') {
67
-	$bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
67
+	$bouton_id = 'b'.substr(md5($texte.microtime()), 0, 8);
68 68
 
69 69
 	$class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
70 70
 	if (strlen($ids)) {
71 71
 		$cible = explode(',', $ids);
72
-		$cible = '#' . implode(',#', $cible);
72
+		$cible = '#'.implode(',#', $cible);
73 73
 	} else {
74 74
 		$cible = "#$bouton_id + div.bloc_depliable";
75 75
 	}
Please login to merge, or discard this patch.
ecrire/inc/genie.php 1 patch
Indentation   +88 added lines, -88 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
 /**
@@ -75,28 +75,28 @@  discard block
 block discarded – undo
75 75
  * @return
76 76
  **/
77 77
 function inc_genie_dist($taches = []) {
78
-	include_spip('inc/queue');
79
-
80
-	if (_request('exec') == 'job_queue') {
81
-		return false;
82
-	}
83
-
84
-	$force_jobs = [];
85
-	// l'ancienne facon de lancer une tache cron immediatement
86
-	// etait de la passer en parametre a ing_genie_dist
87
-	// on reroute en ajoutant simplement le job a la queue, ASAP
88
-	foreach ($taches as $function => $period) {
89
-		$force_jobs[] = queue_add_job(
90
-			$function,
91
-			_T('tache_cron_asap', ['function' => $function]),
92
-			[time() - abs($period)],
93
-			'genie/'
94
-		);
95
-	}
96
-
97
-	// et on passe la main a la gestion de la queue !
98
-	// en forcant eventuellement les jobs ajoute a l'instant
99
-	return queue_schedule(count($force_jobs) ? $force_jobs : null);
78
+    include_spip('inc/queue');
79
+
80
+    if (_request('exec') == 'job_queue') {
81
+        return false;
82
+    }
83
+
84
+    $force_jobs = [];
85
+    // l'ancienne facon de lancer une tache cron immediatement
86
+    // etait de la passer en parametre a ing_genie_dist
87
+    // on reroute en ajoutant simplement le job a la queue, ASAP
88
+    foreach ($taches as $function => $period) {
89
+        $force_jobs[] = queue_add_job(
90
+            $function,
91
+            _T('tache_cron_asap', ['function' => $function]),
92
+            [time() - abs($period)],
93
+            'genie/'
94
+        );
95
+    }
96
+
97
+    // et on passe la main a la gestion de la queue !
98
+    // en forcant eventuellement les jobs ajoute a l'instant
99
+    return queue_schedule(count($force_jobs) ? $force_jobs : null);
100 100
 }
101 101
 
102 102
 //
@@ -109,33 +109,33 @@  discard block
 block discarded – undo
109 109
 //
110 110
 function taches_generales($taches_generales = []) {
111 111
 
112
-	// verifier que toutes les taches cron sont planifiees
113
-	// c'est une tache cron !
114
-	$taches_generales['queue_watch'] = 3600 * 24;
112
+    // verifier que toutes les taches cron sont planifiees
113
+    // c'est une tache cron !
114
+    $taches_generales['queue_watch'] = 3600 * 24;
115 115
 
116
-	// MAJ des rubriques publiques (cas de la publication post-datee)
117
-	// est fait au coup par coup a present
118
-	//	$taches_generales['rubriques'] = 3600;
116
+    // MAJ des rubriques publiques (cas de la publication post-datee)
117
+    // est fait au coup par coup a present
118
+    //	$taches_generales['rubriques'] = 3600;
119 119
 
120
-	// Optimisation de la base
121
-	$taches_generales['optimiser'] = 3600 * 48;
120
+    // Optimisation de la base
121
+    $taches_generales['optimiser'] = 3600 * 48;
122 122
 
123
-	// nouveautes
124
-	if (
125
-		isset($GLOBALS['meta']['adresse_neuf']) and $GLOBALS['meta']['adresse_neuf']
126
-		and $GLOBALS['meta']['jours_neuf']
127
-		and ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')
128
-	) {
129
-		$taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf'];
130
-	}
123
+    // nouveautes
124
+    if (
125
+        isset($GLOBALS['meta']['adresse_neuf']) and $GLOBALS['meta']['adresse_neuf']
126
+        and $GLOBALS['meta']['jours_neuf']
127
+        and ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')
128
+    ) {
129
+        $taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf'];
130
+    }
131 131
 
132
-	// maintenance (ajax, verifications diverses)
133
-	$taches_generales['maintenance'] = 3600 * 2;
132
+    // maintenance (ajax, verifications diverses)
133
+    $taches_generales['maintenance'] = 3600 * 2;
134 134
 
135
-	// verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
136
-	$taches_generales['mise_a_jour'] = 3 * 24 * 3600;
135
+    // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
136
+    $taches_generales['mise_a_jour'] = 3 * 24 * 3600;
137 137
 
138
-	return pipeline('taches_generales_cron', $taches_generales);
138
+    return pipeline('taches_generales_cron', $taches_generales);
139 139
 }
140 140
 
141 141
 /**
@@ -151,22 +151,22 @@  discard block
 block discarded – undo
151 151
  * @return int
152 152
  */
153 153
 function genie_queue_watch_dist() {
154
-	static $deja_la = false;
155
-	if ($deja_la) {
156
-		return;
157
-	} // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple)
158
-	$deja_la = true;
159
-	$taches = taches_generales();
160
-	$programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches)));
161
-	$programmees = array_column($programmees, 'fonction');
162
-	foreach ($taches as $tache => $periode) {
163
-		if (!in_array($tache, $programmees)) {
164
-			queue_genie_replan_job($tache, $periode, time() - round(random_int(1, $periode)), 0);
165
-		}
166
-	}
167
-	$deja_la = false;
168
-
169
-	return 1;
154
+    static $deja_la = false;
155
+    if ($deja_la) {
156
+        return;
157
+    } // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple)
158
+    $deja_la = true;
159
+    $taches = taches_generales();
160
+    $programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches)));
161
+    $programmees = array_column($programmees, 'fonction');
162
+    foreach ($taches as $tache => $periode) {
163
+        if (!in_array($tache, $programmees)) {
164
+            queue_genie_replan_job($tache, $periode, time() - round(random_int(1, $periode)), 0);
165
+        }
166
+    }
167
+    $deja_la = false;
168
+
169
+    return 1;
170 170
 }
171 171
 
172 172
 /**
@@ -187,32 +187,32 @@  discard block
 block discarded – undo
187 187
  * @return void
188 188
  */
189 189
 function queue_genie_replan_job($function, $period, $last = 0, $time = null, $priority = 0) {
190
-	static $done = [];
191
-	if (isset($done[$function])) {
192
-		return;
193
-	}
194
-	$done[$function] = true;
195
-	if (is_null($time)) {
196
-		$time = time();
197
-		if ($last) {
198
-			$time = max($last + $period, $time);
199
-		}
200
-	}
201
-	if (!$last) {
202
-		$last = $time - $period;
203
-	}
204
-	spip_log("replan_job $function $period $last $time $priority", 'queue');
205
-	include_spip('inc/queue');
206
-	// on replanifie un job cron
207
-	// uniquement si il n'y en a pas deja un avec le meme nom
208
-	// independament de l'argument
209
-	queue_add_job(
210
-		$function,
211
-		_T('tache_cron_secondes', ['function' => $function, 'nb' => $period]),
212
-		[$last],
213
-		'genie/',
214
-		'function_only',
215
-		$time,
216
-		$priority
217
-	);
190
+    static $done = [];
191
+    if (isset($done[$function])) {
192
+        return;
193
+    }
194
+    $done[$function] = true;
195
+    if (is_null($time)) {
196
+        $time = time();
197
+        if ($last) {
198
+            $time = max($last + $period, $time);
199
+        }
200
+    }
201
+    if (!$last) {
202
+        $last = $time - $period;
203
+    }
204
+    spip_log("replan_job $function $period $last $time $priority", 'queue');
205
+    include_spip('inc/queue');
206
+    // on replanifie un job cron
207
+    // uniquement si il n'y en a pas deja un avec le meme nom
208
+    // independament de l'argument
209
+    queue_add_job(
210
+        $function,
211
+        _T('tache_cron_secondes', ['function' => $function, 'nb' => $period]),
212
+        [$last],
213
+        'genie/',
214
+        'function_only',
215
+        $time,
216
+        $priority
217
+    );
218 218
 }
Please login to merge, or discard this patch.
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.