Completed
Push — master ( 5d4b0b...2986c5 )
by cam
01:06
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/inc/lien.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
99 99
 }
100 100
 
101
-define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
101
+define('_EXTRAIRE_LIEN', ',^\s*(?:'._PROTOCOLES_STD.'):?/?/?\s*$,iS');
102 102
 
103 103
 function traiter_lien_explicite($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) {
104 104
 	if (preg_match(_EXTRAIRE_LIEN, $ref)) {
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 		$lien_court = charger_fonction('lien_court', 'inc');
115 115
 		$texte = $lien_court($texte);
116 116
 		if ($echappe_typo) {
117
-			$texte = '<html>' . quote_amp($texte) . '</html>';
117
+			$texte = '<html>'.quote_amp($texte).'</html>';
118 118
 		}
119 119
 	}
120 120
 
121 121
 	// petites corrections d'URL
122 122
 	if (preg_match('/^www\.[^@]+$/S', $lien)) {
123
-		$lien = 'http://' . $lien;
123
+		$lien = 'http://'.$lien;
124 124
 	} else {
125 125
 		if (strpos($lien, '@') && email_valide($lien)) {
126 126
 			if (!$texte) {
127 127
 				$texte = $lien;
128 128
 			}
129
-			$lien = 'mailto:' . $lien;
129
+			$lien = 'mailto:'.$lien;
130 130
 		}
131 131
 	}
132 132
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 }
143 143
 
144 144
 function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, string $connect = '') {
145
-	if (function_exists($f = 'glossaire_' . $ancre)) {
145
+	if (function_exists($f = 'glossaire_'.$ancre)) {
146 146
 		$url = $f($texte, $id);
147 147
 	} else {
148 148
 		$url = glossaire_std($texte);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	if (!($match = typer_raccourci($ref))) {
157 157
 		return false;
158 158
 	}
159
-	[$type, , $id, , $args, , $ancre] = array_pad($match, 7, null);
159
+	[$type,, $id,, $args,, $ancre] = array_pad($match, 7, null);
160 160
 	// attention dans le cas des sites le lien doit pointer non pas sur
161 161
 	// la page locale du site, mais directement sur le site lui-meme
162 162
 	if ($f = charger_fonction("implicite_$type", 'liens', true)) {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		$r['titre'] = $texte;
184 184
 	}
185 185
 	if (!@$r['titre']) {
186
-		$r['titre'] = _T($type) . " $id";
186
+		$r['titre'] = _T($type)." $id";
187 187
 	}
188 188
 	if ($pour == 'titre') {
189 189
 		return $r['titre'];
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		and $mime = sql_getfetsel(
197 197
 			'mime_type',
198 198
 			'spip_types_documents',
199
-			'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')',
199
+			'extension IN ('.sql_get_select('extension', 'spip_documents', 'id_document='.sql_quote($id)).')',
200 200
 			'',
201 201
 			'',
202 202
 			'',
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	'(<([a-z_-]{3,})' # <modele
298 298
 	. '\s*([0-9]*)\s*' # id
299 299
 	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
300
-	. '\s*/?' . '>)' # fin du modele >
300
+	. '\s*/?'.'>)' # fin du modele >
301 301
 	. '\s*(<\/a>)?' # eventuel </a>
302 302
 );
303 303
 
304
-define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS');
304
+define('_RACCOURCI_MODELE_DEBUT', '@^'._RACCOURCI_MODELE.'@isS');
305 305
 
306 306
 function traiter_modeles($texte, $doublons = false, $echap = '', string $connect = '', $liens = null, $env = []) {
307 307
 	// preserver la compatibilite : true = recherche des documents
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 						if (test_espace_prive()) {
381 381
 							$modele = entites_html(substr($texte, $a, $cherche));
382 382
 							if (!is_null($liens)) {
383
-								$modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>';
383
+								$modele = '<pre>'.str_replace($liens[0], $liens[1], $modele).'</pre>';
384 384
 							}
385 385
 						}
386 386
 					}
Please login to merge, or discard this patch.
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('base/abstract_sql');
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 //
24 24
 
25 25
 function inc_lien_dist(
26
-	$lien,
27
-	$texte = '',
28
-	$class = '',
29
-	$title = '',
30
-	$hlang = '',
31
-	$rel = '',
32
-	string $connect = '',
33
-	$env = []
26
+    $lien,
27
+    $texte = '',
28
+    $class = '',
29
+    $title = '',
30
+    $hlang = '',
31
+    $rel = '',
32
+    string $connect = '',
33
+    $env = []
34 34
 ) {
35
-	return $lien;
35
+    return $lien;
36 36
 }
37 37
 
38 38
 // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip
@@ -43,28 +43,28 @@  discard block
 block discarded – undo
43 43
 
44 44
 function expanser_liens($t, string $connect = '', $env = []) {
45 45
 
46
-	$t = pipeline('pre_liens', $t);
46
+    $t = pipeline('pre_liens', $t);
47 47
 
48
-	// on passe a traiter_modeles la liste des liens reperes pour lui permettre
49
-	// de remettre le texte d'origine dans les parametres du modele
50
-	$t = traiter_modeles($t, false, false, $connect);
48
+    // on passe a traiter_modeles la liste des liens reperes pour lui permettre
49
+    // de remettre le texte d'origine dans les parametres du modele
50
+    $t = traiter_modeles($t, false, false, $connect);
51 51
 
52
-	return $t;
52
+    return $t;
53 53
 }
54 54
 
55 55
 // Meme analyse mais pour eliminer les liens
56 56
 // et ne laisser que leur titre, a expliciter si ce n'est fait
57 57
 function nettoyer_raccourcis_typo($texte, string $connect = '') {
58
-	return $texte;
58
+    return $texte;
59 59
 }
60 60
 
61 61
 // Repere dans la partie texte d'un raccourci [texte->...]
62 62
 // la langue et la bulle eventuelles
63 63
 function traiter_raccourci_lien_atts($texte) {
64
-	$bulle = '';
65
-	$hlang = '';
64
+    $bulle = '';
65
+    $hlang = '';
66 66
 
67
-	return [trim($texte), $bulle, $hlang];
67
+    return [trim($texte), $bulle, $hlang];
68 68
 }
69 69
 
70 70
 define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/');
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
  * @return string
81 81
  */
82 82
 function virtuel_redirige($virtuel, $url = false) {
83
-	return $virtuel;
83
+    return $virtuel;
84 84
 }
85 85
 
86 86
 // Cherche un lien du type [->raccourci 123]
@@ -93,121 +93,121 @@  discard block
 block discarded – undo
93 93
 // 'url':   seulement U  (i.e. generer_url_RACCOURCI)
94 94
 
95 95
 function calculer_url($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) {
96
-	$r = traiter_lien_implicite($ref, $texte, $pour, $connect);
96
+    $r = traiter_lien_implicite($ref, $texte, $pour, $connect);
97 97
 
98
-	return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
98
+    return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
99 99
 }
100 100
 
101 101
 define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
102 102
 
103 103
 function traiter_lien_explicite($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) {
104
-	if (preg_match(_EXTRAIRE_LIEN, $ref)) {
105
-		return ($pour != 'tout') ? '' : ['', '', '', ''];
106
-	}
107
-
108
-	$lien = entites_html(trim($ref));
109
-
110
-	// Liens explicites
111
-	if (!$texte) {
112
-		$texte = str_replace('"', '', $lien);
113
-		// evite l'affichage de trops longues urls.
114
-		$lien_court = charger_fonction('lien_court', 'inc');
115
-		$texte = $lien_court($texte);
116
-		if ($echappe_typo) {
117
-			$texte = '<html>' . quote_amp($texte) . '</html>';
118
-		}
119
-	}
120
-
121
-	// petites corrections d'URL
122
-	if (preg_match('/^www\.[^@]+$/S', $lien)) {
123
-		$lien = 'http://' . $lien;
124
-	} else {
125
-		if (strpos($lien, '@') && email_valide($lien)) {
126
-			if (!$texte) {
127
-				$texte = $lien;
128
-			}
129
-			$lien = 'mailto:' . $lien;
130
-		}
131
-	}
132
-
133
-	if ($pour == 'url') {
134
-		return $lien;
135
-	}
136
-
137
-	if ($pour == 'titre') {
138
-		return $texte;
139
-	}
140
-
141
-	return ['url' => $lien, 'titre' => $texte];
104
+    if (preg_match(_EXTRAIRE_LIEN, $ref)) {
105
+        return ($pour != 'tout') ? '' : ['', '', '', ''];
106
+    }
107
+
108
+    $lien = entites_html(trim($ref));
109
+
110
+    // Liens explicites
111
+    if (!$texte) {
112
+        $texte = str_replace('"', '', $lien);
113
+        // evite l'affichage de trops longues urls.
114
+        $lien_court = charger_fonction('lien_court', 'inc');
115
+        $texte = $lien_court($texte);
116
+        if ($echappe_typo) {
117
+            $texte = '<html>' . quote_amp($texte) . '</html>';
118
+        }
119
+    }
120
+
121
+    // petites corrections d'URL
122
+    if (preg_match('/^www\.[^@]+$/S', $lien)) {
123
+        $lien = 'http://' . $lien;
124
+    } else {
125
+        if (strpos($lien, '@') && email_valide($lien)) {
126
+            if (!$texte) {
127
+                $texte = $lien;
128
+            }
129
+            $lien = 'mailto:' . $lien;
130
+        }
131
+    }
132
+
133
+    if ($pour == 'url') {
134
+        return $lien;
135
+    }
136
+
137
+    if ($pour == 'titre') {
138
+        return $texte;
139
+    }
140
+
141
+    return ['url' => $lien, 'titre' => $texte];
142 142
 }
143 143
 
144 144
 function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, string $connect = '') {
145
-	if (function_exists($f = 'glossaire_' . $ancre)) {
146
-		$url = $f($texte, $id);
147
-	} else {
148
-		$url = glossaire_std($texte);
149
-	}
145
+    if (function_exists($f = 'glossaire_' . $ancre)) {
146
+        $url = $f($texte, $id);
147
+    } else {
148
+        $url = glossaire_std($texte);
149
+    }
150 150
 
151
-	return $url;
151
+    return $url;
152 152
 }
153 153
 
154 154
 function traiter_lien_implicite($ref, $texte = '', $pour = 'url', string $connect = '') {
155
-	$url = null;
156
-	if (!($match = typer_raccourci($ref))) {
157
-		return false;
158
-	}
159
-	[$type, , $id, , $args, , $ancre] = array_pad($match, 7, null);
160
-	// attention dans le cas des sites le lien doit pointer non pas sur
161
-	// la page locale du site, mais directement sur le site lui-meme
162
-	if ($f = charger_fonction("implicite_$type", 'liens', true)) {
163
-		$url = $f($texte, $id, $type, $args, $ancre, $connect);
164
-	}
165
-	if (!$url) {
166
-		$url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', null, '', $connect);
167
-	}
168
-	if (!$url) {
169
-		return false;
170
-	}
171
-	if (is_array($url)) {
172
-		[$type, $id] = array_pad($url, 2, null);
173
-		$url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', null, '', $connect);
174
-	}
175
-	if ($pour === 'url') {
176
-		return $url;
177
-	}
178
-	$r = traiter_raccourci_titre($id, $type, $connect);
179
-	if ($r) {
180
-		$r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
181
-	}
182
-	if ($texte = trim($texte)) {
183
-		$r['titre'] = $texte;
184
-	}
185
-	if (!@$r['titre']) {
186
-		$r['titre'] = _T($type) . " $id";
187
-	}
188
-	if ($pour == 'titre') {
189
-		return $r['titre'];
190
-	}
191
-	$r['url'] = $url;
192
-
193
-	// dans le cas d'un lien vers un doc, ajouter le type='mime/type'
194
-	if (
195
-		$type == 'document'
196
-		and $mime = sql_getfetsel(
197
-			'mime_type',
198
-			'spip_types_documents',
199
-			'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')',
200
-			'',
201
-			'',
202
-			'',
203
-			'',
204
-			$connect
205
-		)
206
-	) {
207
-		$r['mime'] = $mime;
208
-	}
209
-
210
-	return $r;
155
+    $url = null;
156
+    if (!($match = typer_raccourci($ref))) {
157
+        return false;
158
+    }
159
+    [$type, , $id, , $args, , $ancre] = array_pad($match, 7, null);
160
+    // attention dans le cas des sites le lien doit pointer non pas sur
161
+    // la page locale du site, mais directement sur le site lui-meme
162
+    if ($f = charger_fonction("implicite_$type", 'liens', true)) {
163
+        $url = $f($texte, $id, $type, $args, $ancre, $connect);
164
+    }
165
+    if (!$url) {
166
+        $url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', null, '', $connect);
167
+    }
168
+    if (!$url) {
169
+        return false;
170
+    }
171
+    if (is_array($url)) {
172
+        [$type, $id] = array_pad($url, 2, null);
173
+        $url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', null, '', $connect);
174
+    }
175
+    if ($pour === 'url') {
176
+        return $url;
177
+    }
178
+    $r = traiter_raccourci_titre($id, $type, $connect);
179
+    if ($r) {
180
+        $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
181
+    }
182
+    if ($texte = trim($texte)) {
183
+        $r['titre'] = $texte;
184
+    }
185
+    if (!@$r['titre']) {
186
+        $r['titre'] = _T($type) . " $id";
187
+    }
188
+    if ($pour == 'titre') {
189
+        return $r['titre'];
190
+    }
191
+    $r['url'] = $url;
192
+
193
+    // dans le cas d'un lien vers un doc, ajouter le type='mime/type'
194
+    if (
195
+        $type == 'document'
196
+        and $mime = sql_getfetsel(
197
+            'mime_type',
198
+            'spip_types_documents',
199
+            'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')',
200
+            '',
201
+            '',
202
+            '',
203
+            '',
204
+            $connect
205
+        )
206
+    ) {
207
+        $r['mime'] = $mime;
208
+    }
209
+
210
+    return $r;
211 211
 }
212 212
 
213 213
 // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes
@@ -215,41 +215,41 @@  discard block
 block discarded – undo
215 215
 define('_RACCOURCI_URL', '/^\s*(\w*?)\s*(\d+)(\?(.*?))?(#([^\s]*))?\s*$/S');
216 216
 
217 217
 function typer_raccourci($lien) {
218
-	if (!preg_match(_RACCOURCI_URL, $lien, $match)) {
219
-		return [];
220
-	}
221
-	$f = $match[1];
222
-	// valeur par defaut et alias historiques
223
-	if (!$f) {
224
-		$f = 'article';
225
-	} else {
226
-		if ($f == 'art') {
227
-			$f = 'article';
228
-		} else {
229
-			if ($f == 'br') {
230
-				$f = 'breve';
231
-			} else {
232
-				if ($f == 'rub') {
233
-					$f = 'rubrique';
234
-				} else {
235
-					if ($f == 'aut') {
236
-						$f = 'auteur';
237
-					} else {
238
-						if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') {
239
-							$f = 'document';
240
-						} else {
241
-							if (preg_match('/^br..?ve$/S', $f)) {
242
-								$f = 'breve';
243
-							}
244
-						}
245
-					}
246
-				}
247
-			}
248
-		}
249
-	} # accents :(
250
-	$match[0] = $f;
251
-
252
-	return $match;
218
+    if (!preg_match(_RACCOURCI_URL, $lien, $match)) {
219
+        return [];
220
+    }
221
+    $f = $match[1];
222
+    // valeur par defaut et alias historiques
223
+    if (!$f) {
224
+        $f = 'article';
225
+    } else {
226
+        if ($f == 'art') {
227
+            $f = 'article';
228
+        } else {
229
+            if ($f == 'br') {
230
+                $f = 'breve';
231
+            } else {
232
+                if ($f == 'rub') {
233
+                    $f = 'rubrique';
234
+                } else {
235
+                    if ($f == 'aut') {
236
+                        $f = 'auteur';
237
+                    } else {
238
+                        if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') {
239
+                            $f = 'document';
240
+                        } else {
241
+                            if (preg_match('/^br..?ve$/S', $f)) {
242
+                                $f = 'breve';
243
+                            }
244
+                        }
245
+                    }
246
+                }
247
+            }
248
+        }
249
+    } # accents :(
250
+    $match[0] = $f;
251
+
252
+    return $match;
253 253
 }
254 254
 
255 255
 /**
@@ -264,25 +264,25 @@  discard block
 block discarded – undo
264 264
  * }
265 265
  **/
266 266
 function traiter_raccourci_titre($id, $type, $connect = null) {
267
-	$trouver_table = charger_fonction('trouver_table', 'base');
268
-	$desc = $trouver_table(table_objet($type));
269
-	if (!($desc and $s = $desc['titre'])) {
270
-		return [];
271
-	}
272
-	$_id = $desc['key']['PRIMARY KEY'];
273
-	$r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
274
-	if (!$r) {
275
-		return [];
276
-	}
277
-	$r['titre'] = supprimer_numero($r['titre']);
278
-	if (!$r['titre'] and !empty($r['surnom'])) {
279
-		$r['titre'] = $r['surnom'];
280
-	}
281
-	if (!isset($r['lang'])) {
282
-		$r['lang'] = '';
283
-	}
284
-
285
-	return $r;
267
+    $trouver_table = charger_fonction('trouver_table', 'base');
268
+    $desc = $trouver_table(table_objet($type));
269
+    if (!($desc and $s = $desc['titre'])) {
270
+        return [];
271
+    }
272
+    $_id = $desc['key']['PRIMARY KEY'];
273
+    $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
274
+    if (!$r) {
275
+        return [];
276
+    }
277
+    $r['titre'] = supprimer_numero($r['titre']);
278
+    if (!$r['titre'] and !empty($r['surnom'])) {
279
+        $r['titre'] = $r['surnom'];
280
+    }
281
+    if (!isset($r['lang'])) {
282
+        $r['lang'] = '';
283
+    }
284
+
285
+    return $r;
286 286
 }
287 287
 
288 288
 // traite les modeles (dans la fonction typo), en remplacant
@@ -293,136 +293,136 @@  discard block
 block discarded – undo
293 293
 // mais on renvoie les params (pour l'indexation par le moteur de recherche)
294 294
 
295 295
 define(
296
-	'_RACCOURCI_MODELE',
297
-	'(<([a-z_-]{3,})' # <modele
298
-	. '\s*([0-9]*)\s*' # id
299
-	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
300
-	. '\s*/?' . '>)' # fin du modele >
301
-	. '\s*(<\/a>)?' # eventuel </a>
296
+    '_RACCOURCI_MODELE',
297
+    '(<([a-z_-]{3,})' # <modele
298
+    . '\s*([0-9]*)\s*' # id
299
+    . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
300
+    . '\s*/?' . '>)' # fin du modele >
301
+    . '\s*(<\/a>)?' # eventuel </a>
302 302
 );
303 303
 
304 304
 define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS');
305 305
 
306 306
 function traiter_modeles($texte, $doublons = false, $echap = '', string $connect = '', $liens = null, $env = []) {
307
-	// preserver la compatibilite : true = recherche des documents
308
-	if ($doublons === true) {
309
-		$doublons = ['documents' => ['doc', 'emb', 'img']];
310
-	}
311
-	// detecter les modeles (rapide)
312
-	if (
313
-		strpos($texte, '<') !== false and
314
-		preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)
315
-	) {
316
-		include_spip('public/assembler');
317
-		$wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true);
318
-		foreach ($matches as $match) {
319
-			// Recuperer l'appel complet (y compris un eventuel lien)
320
-
321
-			$a = strpos($texte, (string) $match[0]);
322
-			preg_match(
323
-				_RACCOURCI_MODELE_DEBUT,
324
-				substr($texte, $a),
325
-				$regs
326
-			);
327
-			$regs[] = ''; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
328
-			[, $mod, $type, $id, $params, $fin] = $regs;
329
-			if (
330
-				$fin and
331
-				preg_match(
332
-					'/<a\s[^<>]*>\s*$/i',
333
-					substr($texte, 0, $a),
334
-					$r
335
-				)
336
-			) {
337
-				$lien = [
338
-					'href' => extraire_attribut($r[0], 'href'),
339
-					'class' => extraire_attribut($r[0], 'class'),
340
-					'mime' => extraire_attribut($r[0], 'type'),
341
-					'title' => extraire_attribut($r[0], 'title'),
342
-					'hreflang' => extraire_attribut($r[0], 'hreflang')
343
-				];
344
-				$n = strlen($r[0]);
345
-				$a -= $n;
346
-				$cherche = $n + strlen($regs[0]);
347
-			} else {
348
-				$lien = false;
349
-				$cherche = strlen($mod);
350
-			}
351
-
352
-			// calculer le modele
353
-			# hack indexation
354
-			if ($doublons) {
355
-				$texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
356
-			} # version normale
357
-			else {
358
-				// si un tableau de liens a ete passe, reinjecter le contenu d'origine
359
-				// dans les parametres, plutot que les liens echappes
360
-				if (!is_null($liens)) {
361
-					$params = str_replace($liens[0], $liens[1], $params);
362
-				}
363
-				$modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
364
-				// en cas d'echec,
365
-				// si l'objet demande a une url,
366
-				// creer un petit encadre vers elle
367
-				if ($modele === false) {
368
-					if (!$lien) {
369
-						$lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
370
-					}
371
-					if ($lien) {
372
-						$modele = '<a href="'
373
-							. $lien['url']
374
-							. '" class="spip_modele'
375
-							. '">'
376
-							. sinon($lien['titre'], _T('ecrire:info_sans_titre'))
377
-							. '</a>';
378
-					} else {
379
-						$modele = '';
380
-						if (test_espace_prive()) {
381
-							$modele = entites_html(substr($texte, $a, $cherche));
382
-							if (!is_null($liens)) {
383
-								$modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>';
384
-							}
385
-						}
386
-					}
387
-				}
388
-				// le remplacer dans le texte
389
-				if ($modele !== false) {
390
-					$modele = protege_js_modeles($modele);
391
-					if ($wrap_embed_html) {
392
-						$modele = $wrap_embed_html($mod, $modele);
393
-					}
394
-					$rempl = code_echappement($modele, $echap);
395
-					$texte = substr($texte, 0, $a)
396
-						. $rempl
397
-						. substr($texte, $a + $cherche);
398
-				}
399
-			}
400
-
401
-			// hack pour tout l'espace prive
402
-			if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) {
403
-				foreach ($doublons ?: ['documents' => ['doc', 'emb', 'img']] as $quoi => $modeles) {
404
-					if (in_array($type, $modeles)) {
405
-						$GLOBALS["doublons_{$quoi}_inclus"][] = $id;
406
-					}
407
-				}
408
-			}
409
-		}
410
-	}
411
-
412
-	return $texte;
307
+    // preserver la compatibilite : true = recherche des documents
308
+    if ($doublons === true) {
309
+        $doublons = ['documents' => ['doc', 'emb', 'img']];
310
+    }
311
+    // detecter les modeles (rapide)
312
+    if (
313
+        strpos($texte, '<') !== false and
314
+        preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)
315
+    ) {
316
+        include_spip('public/assembler');
317
+        $wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true);
318
+        foreach ($matches as $match) {
319
+            // Recuperer l'appel complet (y compris un eventuel lien)
320
+
321
+            $a = strpos($texte, (string) $match[0]);
322
+            preg_match(
323
+                _RACCOURCI_MODELE_DEBUT,
324
+                substr($texte, $a),
325
+                $regs
326
+            );
327
+            $regs[] = ''; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
328
+            [, $mod, $type, $id, $params, $fin] = $regs;
329
+            if (
330
+                $fin and
331
+                preg_match(
332
+                    '/<a\s[^<>]*>\s*$/i',
333
+                    substr($texte, 0, $a),
334
+                    $r
335
+                )
336
+            ) {
337
+                $lien = [
338
+                    'href' => extraire_attribut($r[0], 'href'),
339
+                    'class' => extraire_attribut($r[0], 'class'),
340
+                    'mime' => extraire_attribut($r[0], 'type'),
341
+                    'title' => extraire_attribut($r[0], 'title'),
342
+                    'hreflang' => extraire_attribut($r[0], 'hreflang')
343
+                ];
344
+                $n = strlen($r[0]);
345
+                $a -= $n;
346
+                $cherche = $n + strlen($regs[0]);
347
+            } else {
348
+                $lien = false;
349
+                $cherche = strlen($mod);
350
+            }
351
+
352
+            // calculer le modele
353
+            # hack indexation
354
+            if ($doublons) {
355
+                $texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
356
+            } # version normale
357
+            else {
358
+                // si un tableau de liens a ete passe, reinjecter le contenu d'origine
359
+                // dans les parametres, plutot que les liens echappes
360
+                if (!is_null($liens)) {
361
+                    $params = str_replace($liens[0], $liens[1], $params);
362
+                }
363
+                $modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
364
+                // en cas d'echec,
365
+                // si l'objet demande a une url,
366
+                // creer un petit encadre vers elle
367
+                if ($modele === false) {
368
+                    if (!$lien) {
369
+                        $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
370
+                    }
371
+                    if ($lien) {
372
+                        $modele = '<a href="'
373
+                            . $lien['url']
374
+                            . '" class="spip_modele'
375
+                            . '">'
376
+                            . sinon($lien['titre'], _T('ecrire:info_sans_titre'))
377
+                            . '</a>';
378
+                    } else {
379
+                        $modele = '';
380
+                        if (test_espace_prive()) {
381
+                            $modele = entites_html(substr($texte, $a, $cherche));
382
+                            if (!is_null($liens)) {
383
+                                $modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>';
384
+                            }
385
+                        }
386
+                    }
387
+                }
388
+                // le remplacer dans le texte
389
+                if ($modele !== false) {
390
+                    $modele = protege_js_modeles($modele);
391
+                    if ($wrap_embed_html) {
392
+                        $modele = $wrap_embed_html($mod, $modele);
393
+                    }
394
+                    $rempl = code_echappement($modele, $echap);
395
+                    $texte = substr($texte, 0, $a)
396
+                        . $rempl
397
+                        . substr($texte, $a + $cherche);
398
+                }
399
+            }
400
+
401
+            // hack pour tout l'espace prive
402
+            if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) {
403
+                foreach ($doublons ?: ['documents' => ['doc', 'emb', 'img']] as $quoi => $modeles) {
404
+                    if (in_array($type, $modeles)) {
405
+                        $GLOBALS["doublons_{$quoi}_inclus"][] = $id;
406
+                    }
407
+                }
408
+            }
409
+        }
410
+    }
411
+
412
+    return $texte;
413 413
 }
414 414
 
415 415
 //
416 416
 // Raccourcis ancre [#ancre<-]
417 417
 //
418 418
 function traiter_raccourci_ancre($letexte) {
419
-	return $letexte;
419
+    return $letexte;
420 420
 }
421 421
 
422 422
 function traiter_raccourci_glossaire($texte) {
423
-	return $texte;
423
+    return $texte;
424 424
 }
425 425
 
426 426
 function glossaire_std($terme) {
427
-	return $terme;
427
+    return $terme;
428 428
 }
Please login to merge, or discard this patch.
ecrire/inc/texte_mini.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	// celle du texte) et public (spip_lang est la langue du texte)
45 45
 	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
47
+	$p = 'puce'.(test_espace_prive() ? '_prive' : '');
48 48
 	if ($dir == 'rtl') {
49 49
 		$p .= '_rtl';
50 50
 	}
51 51
 
52 52
 	if (!isset($GLOBALS[$p])) {
53
-		$GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
53
+		$GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>';
54 54
 	}
55 55
 
56 56
 	return $GLOBALS[$p];
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 }
69 69
 
70 70
 if (!defined('_BALISES_BLOCS_REGEXP')) {
71
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
71
+	define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS');
72 72
 }
73 73
 
74 74
 //
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 	// Tester si on echappe en span ou en div
87 87
 	if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
88
+		$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89 89
 	}
90 90
 
91 91
 	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	) {
121 121
 		foreach ($matches as $m) {
122 122
 			if ($m[1] === 'code') {
123
-				$code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
123
+				$code = '<code'.$m[2].'>'.spip_htmlspecialchars($m[3]).'</code>';
124 124
 				$pre = str_replace($m[0], $code, $pre);
125 125
 			}
126 126
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 // Echapper les <code>...</ code>
132 132
 function traiter_echap_code_dist($regs) {
133
-	[, , $att, $corps] = $regs;
133
+	[,, $att, $corps] = $regs;
134 134
 	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
135 135
 
136 136
 	// ne pas mettre le <div...> s'il n'y a qu'une ligne
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 		$echap = nl2br($echap);
142 142
 		$echap = "<div style='text-align: left;' "
143 143
 			. "class='spip_code' dir='ltr'><code$att>"
144
-			. $echap . '</code></div>';
144
+			. $echap.'</code></div>';
145 145
 	} else {
146
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>';
146
+		$echap = "<code$att class='spip_code' dir='ltr'>".$echap.'</code>';
147 147
 	}
148 148
 
149 149
 	$echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 			} // sinon les traiter selon le cas
230 230
 			else {
231 231
 				if (
232
-					function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
233
-					or function_exists($f = $f . '_dist')
232
+					function_exists($f = $callback_prefix.'traiter_echap_'.strtolower($regs[1]))
233
+					or function_exists($f = $f.'_dist')
234 234
 				) {
235 235
 					$echap = $f($regs);
236 236
 				}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	// dans une callback autonommee
252 252
 	if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
253 253
 		if (
254
-			strpos($letexte, '<' . '?') !== false and preg_match_all(
254
+			strpos($letexte, '<'.'?') !== false and preg_match_all(
255 255
 				',<[?].*($|[?]>),UisS',
256 256
 				$letexte,
257 257
 				$matches,
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 			strpos($letexte, '<') !== false
284 284
 			and
285 285
 			preg_match_all(
286
-				',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
286
+				',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS',
287 287
 				$letexte,
288 288
 				$regs,
289 289
 				PREG_SET_ORDER
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 					}
301 301
 				}
302 302
 				if ($at) {
303
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
303
+					$rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>';
304 304
 					foreach ($at as $attr => $a) {
305 305
 						$rempl = inserer_attribut($rempl, $attr, $a);
306 306
 					}
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	$texte = nettoyer_raccourcis_typo($texte);
382 382
 
383 383
 	// balises de sauts de ligne et paragraphe
384
-	$texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
385
-	$texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
384
+	$texte = preg_replace('/<p( [^>]*)?'.'>/', "\r", $texte);
385
+	$texte = preg_replace('/<br( [^>]*)?'.'>/', "\n", $texte);
386 386
 
387 387
 	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
388 388
 	$texte = str_replace("\n\n", "\r", $texte);
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	// supprimer les tags
391 391
 	$texte = supprimer_tags($texte);
392 392
 	$texte = trim(str_replace("\n", ' ', $texte));
393
-	$texte .= "\n";  // marquer la fin
393
+	$texte .= "\n"; // marquer la fin
394 394
 
395 395
 	// corriger la longueur de coupe
396 396
 	// en fonction de la presence de caracteres utf
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	// couper au mot precedent
406 406
 	$long = spip_substr($texte, 0, max($taille - 4, 1));
407 407
 	$u = $GLOBALS['meta']['pcre_u'];
408
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
408
+	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
409 409
 	if (is_null($suite)) {
410 410
 		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
411 411
 	}
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
416 416
 		$points = '';
417 417
 		$long = spip_substr($texte, 0, $taille);
418
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
418
+		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
419 419
 		// encore trop court ? couper au caractere
420 420
 		if (spip_strlen($texte) < 0.75 * $taille) {
421 421
 			$texte = $long;
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	// supprimer l'eventuelle entite finale mal coupee
435 435
 	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
436 436
 
437
-	return quote_amp(trim($texte)) . $points;
437
+	return quote_amp(trim($texte)).$points;
438 438
 }
439 439
 
440 440
 
@@ -446,16 +446,16 @@  discard block
 block discarded – undo
446 446
 				define('_PROTEGE_JS_MODELES', creer_uniqid());
447 447
 			}
448 448
 			foreach ($r as $regs) {
449
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
449
+				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t);
450 450
 			}
451 451
 		}
452
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
452
+		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) {
453 453
 			if (!defined('_PROTEGE_PHP_MODELES')) {
454 454
 				include_spip('inc/acces');
455 455
 				define('_PROTEGE_PHP_MODELES', creer_uniqid());
456 456
 			}
457 457
 			foreach ($r as $regs) {
458
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
458
+				$t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t);
459 459
 			}
460 460
 		}
461 461
 	}
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		if (!function_exists('attribut_html')) {
529 529
 			include_spip('inc/filtres');
530 530
 		}
531
-		$texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
531
+		$texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
532 532
 	}
533 533
 
534 534
 	return $texte;
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
  **/
599 599
 function supprime_img($letexte, $message = null) {
600 600
 	if ($message === null) {
601
-		$message = '(' . _T('img_indisponible') . ')';
601
+		$message = '('._T('img_indisponible').')';
602 602
 	}
603 603
 
604 604
 	return preg_replace(
605
-		',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
605
+		',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i',
606 606
 		$message,
607 607
 		$letexte
608 608
 	);
Please login to merge, or discard this patch.
Indentation   +389 added lines, -389 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 include_spip('inc/filtres');
23 23
 include_spip('inc/lang');
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
  **/
40 40
 function definir_puce() {
41 41
 
42
-	// Attention au sens, qui n'est pas defini de la meme facon dans
43
-	// l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
-	// celle du texte) et public (spip_lang est la langue du texte)
45
-	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
42
+    // Attention au sens, qui n'est pas defini de la meme facon dans
43
+    // l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
+    // celle du texte) et public (spip_lang est la langue du texte)
45
+    $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
-	if ($dir == 'rtl') {
49
-		$p .= '_rtl';
50
-	}
47
+    $p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
+    if ($dir == 'rtl') {
49
+        $p .= '_rtl';
50
+    }
51 51
 
52
-	if (!isset($GLOBALS[$p])) {
53
-		$GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
54
-	}
52
+    if (!isset($GLOBALS[$p])) {
53
+        $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
54
+    }
55 55
 
56
-	return $GLOBALS[$p];
56
+    return $GLOBALS[$p];
57 57
 }
58 58
 
59 59
 
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 // dont on souhaite qu'ils provoquent un saut de paragraphe
62 62
 
63 63
 if (!defined('_BALISES_BLOCS')) {
64
-	define(
65
-		'_BALISES_BLOCS',
66
-		'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
67
-	);
64
+    define(
65
+        '_BALISES_BLOCS',
66
+        'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
67
+    );
68 68
 }
69 69
 
70 70
 if (!defined('_BALISES_BLOCS_REGEXP')) {
71
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
71
+    define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
72 72
 }
73 73
 
74 74
 //
@@ -79,106 +79,106 @@  discard block
 block discarded – undo
79 79
 // une $source differente ; le script detecte automagiquement si ce qu'on
80 80
 // echappe est un div ou un span
81 81
 function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) {
82
-	if (!strlen($rempl)) {
83
-		return '';
84
-	}
85
-
86
-	// Tester si on echappe en span ou en div
87
-	if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
-	}
90
-
91
-	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
-	$taille = 30000;
93
-	$return = '';
94
-	for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
-		// Convertir en base64 et cacher dans un attribut
96
-		// utiliser les " pour eviter le re-encodage de ' et &#8217
97
-		$base64 = base64_encode(substr($rempl, $i, $taille));
98
-		$return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
-	}
100
-
101
-	return $return;
82
+    if (!strlen($rempl)) {
83
+        return '';
84
+    }
85
+
86
+    // Tester si on echappe en span ou en div
87
+    if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
88
+        $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
+    }
90
+
91
+    // Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
+    $taille = 30000;
93
+    $return = '';
94
+    for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
+        // Convertir en base64 et cacher dans un attribut
96
+        // utiliser les " pour eviter le re-encodage de ' et &#8217
97
+        $base64 = base64_encode(substr($rempl, $i, $taille));
98
+        $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
+    }
100
+
101
+    return $return;
102 102
 }
103 103
 
104 104
 
105 105
 // Echapper les <html>...</ html>
106 106
 function traiter_echap_html_dist($regs) {
107
-	return $regs[3];
107
+    return $regs[3];
108 108
 }
109 109
 
110 110
 // Echapper les <pre>...</ pre>
111 111
 function traiter_echap_pre_dist($regs) {
112
-	// echapper les <code> dans <pre>
113
-	$pre = $regs[3];
114
-
115
-	// echapper les < dans <code>
116
-	// on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
117
-	if (
118
-		strpos($pre, '<') !== false
119
-		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)
120
-	) {
121
-		foreach ($matches as $m) {
122
-			if ($m[1] === 'code') {
123
-				$code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
124
-				$pre = str_replace($m[0], $code, $pre);
125
-			}
126
-		}
127
-	}
128
-	return "<pre>$pre</pre>";
112
+    // echapper les <code> dans <pre>
113
+    $pre = $regs[3];
114
+
115
+    // echapper les < dans <code>
116
+    // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
117
+    if (
118
+        strpos($pre, '<') !== false
119
+        and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)
120
+    ) {
121
+        foreach ($matches as $m) {
122
+            if ($m[1] === 'code') {
123
+                $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
124
+                $pre = str_replace($m[0], $code, $pre);
125
+            }
126
+        }
127
+    }
128
+    return "<pre>$pre</pre>";
129 129
 }
130 130
 
131 131
 // Echapper les <code>...</ code>
132 132
 function traiter_echap_code_dist($regs) {
133
-	[, , $att, $corps] = $regs;
134
-	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
135
-
136
-	// ne pas mettre le <div...> s'il n'y a qu'une ligne
137
-	if (is_int(strpos($echap, "\n"))) {
138
-		// supprimer les sauts de ligne debut/fin
139
-		// (mais pas les espaces => ascii art).
140
-		$echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $echap);
141
-		$echap = nl2br($echap);
142
-		$echap = "<div style='text-align: left;' "
143
-			. "class='spip_code' dir='ltr'><code$att>"
144
-			. $echap . '</code></div>';
145
-	} else {
146
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>';
147
-	}
148
-
149
-	$echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
150
-	$echap = str_replace('  ', ' &nbsp;', $echap);
151
-
152
-	return $echap;
133
+    [, , $att, $corps] = $regs;
134
+    $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
135
+
136
+    // ne pas mettre le <div...> s'il n'y a qu'une ligne
137
+    if (is_int(strpos($echap, "\n"))) {
138
+        // supprimer les sauts de ligne debut/fin
139
+        // (mais pas les espaces => ascii art).
140
+        $echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $echap);
141
+        $echap = nl2br($echap);
142
+        $echap = "<div style='text-align: left;' "
143
+            . "class='spip_code' dir='ltr'><code$att>"
144
+            . $echap . '</code></div>';
145
+    } else {
146
+        $echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>';
147
+    }
148
+
149
+    $echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
150
+    $echap = str_replace('  ', ' &nbsp;', $echap);
151
+
152
+    return $echap;
153 153
 }
154 154
 
155 155
 // Echapper les <cadre>...</ cadre> aka <frame>...</ frame>
156 156
 function traiter_echap_cadre_dist($regs) {
157
-	$echap = trim(entites_html($regs[3]));
158
-	// compter les lignes un peu plus finement qu'avec les \n
159
-	$lignes = explode("\n", trim($echap));
160
-	$n = 0;
161
-	foreach ($lignes as $l) {
162
-		$n += floor(strlen($l) / 60) + 1;
163
-	}
164
-	$n = max($n, 2);
165
-	$echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
166
-
167
-	return $echap;
157
+    $echap = trim(entites_html($regs[3]));
158
+    // compter les lignes un peu plus finement qu'avec les \n
159
+    $lignes = explode("\n", trim($echap));
160
+    $n = 0;
161
+    foreach ($lignes as $l) {
162
+        $n += floor(strlen($l) / 60) + 1;
163
+    }
164
+    $n = max($n, 2);
165
+    $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
166
+
167
+    return $echap;
168 168
 }
169 169
 
170 170
 function traiter_echap_frame_dist($regs) {
171
-	return traiter_echap_cadre_dist($regs);
171
+    return traiter_echap_cadre_dist($regs);
172 172
 }
173 173
 
174 174
 function traiter_echap_script_dist($regs) {
175
-	// rendre joli (et inactif) si c'est un script language=php
176
-	if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
177
-		return highlight_string($regs[0], true);
178
-	}
175
+    // rendre joli (et inactif) si c'est un script language=php
176
+    if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
177
+        return highlight_string($regs[0], true);
178
+    }
179 179
 
180
-	// Cas normal : le script passe tel quel
181
-	return $regs[0];
180
+    // Cas normal : le script passe tel quel
181
+    return $regs[0];
182 182
 }
183 183
 
184 184
 define('_PROTEGE_BLOCS', ',<(html|pre|code|cadre|frame|script|style)(\b[^>]*)?>(.*)</\1>,UimsS');
@@ -196,67 +196,67 @@  discard block
 block discarded – undo
196 196
  * @return string|string[]
197 197
  */
198 198
 function echappe_html(
199
-	$letexte,
200
-	$source = '',
201
-	$no_transform = false,
202
-	$preg = '',
203
-	$callback_prefix = ''
199
+    $letexte,
200
+    $source = '',
201
+    $no_transform = false,
202
+    $preg = '',
203
+    $callback_prefix = ''
204 204
 ) {
205
-	if (!is_string($letexte) or !strlen($letexte)) {
206
-		return $letexte;
207
-	}
208
-
209
-	if (
210
-		($preg or strpos($letexte, '<') !== false)
211
-		and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
212
-	) {
213
-		foreach ($matches as $regs) {
214
-			// echappements tels quels ?
215
-			if ($no_transform) {
216
-				$echap = $regs[0];
217
-			} // sinon les traiter selon le cas
218
-			else {
219
-				if (
220
-					function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
221
-					or function_exists($f = $f . '_dist')
222
-				) {
223
-					$echap = $f($regs);
224
-				}
225
-			}
226
-
227
-			$p = strpos($letexte, (string) $regs[0]);
228
-			$letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
229
-		}
230
-	}
231
-
232
-	if ($no_transform) {
233
-		return $letexte;
234
-	}
235
-
236
-	// Echapper le php pour faire joli (ici, c'est pas pour la securite)
237
-	// seulement si on a echappe les <script>
238
-	// (derogatoire car on ne peut pas faire passer < ? ... ? >
239
-	// dans une callback autonommee
240
-	if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
241
-		if (
242
-			strpos($letexte, '<' . '?') !== false and preg_match_all(
243
-				',<[?].*($|[?]>),UisS',
244
-				$letexte,
245
-				$matches,
246
-				PREG_SET_ORDER
247
-			)
248
-		) {
249
-			foreach ($matches as $regs) {
250
-				$letexte = str_replace(
251
-					$regs[0],
252
-					code_echappement(highlight_string($regs[0], true), $source),
253
-					$letexte
254
-				);
255
-			}
256
-		}
257
-	}
258
-
259
-	return $letexte;
205
+    if (!is_string($letexte) or !strlen($letexte)) {
206
+        return $letexte;
207
+    }
208
+
209
+    if (
210
+        ($preg or strpos($letexte, '<') !== false)
211
+        and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
212
+    ) {
213
+        foreach ($matches as $regs) {
214
+            // echappements tels quels ?
215
+            if ($no_transform) {
216
+                $echap = $regs[0];
217
+            } // sinon les traiter selon le cas
218
+            else {
219
+                if (
220
+                    function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
221
+                    or function_exists($f = $f . '_dist')
222
+                ) {
223
+                    $echap = $f($regs);
224
+                }
225
+            }
226
+
227
+            $p = strpos($letexte, (string) $regs[0]);
228
+            $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
229
+        }
230
+    }
231
+
232
+    if ($no_transform) {
233
+        return $letexte;
234
+    }
235
+
236
+    // Echapper le php pour faire joli (ici, c'est pas pour la securite)
237
+    // seulement si on a echappe les <script>
238
+    // (derogatoire car on ne peut pas faire passer < ? ... ? >
239
+    // dans une callback autonommee
240
+    if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
241
+        if (
242
+            strpos($letexte, '<' . '?') !== false and preg_match_all(
243
+                ',<[?].*($|[?]>),UisS',
244
+                $letexte,
245
+                $matches,
246
+                PREG_SET_ORDER
247
+            )
248
+        ) {
249
+            foreach ($matches as $regs) {
250
+                $letexte = str_replace(
251
+                    $regs[0],
252
+                    code_echappement(highlight_string($regs[0], true), $source),
253
+                    $letexte
254
+                );
255
+            }
256
+        }
257
+    }
258
+
259
+    return $letexte;
260 260
 }
261 261
 
262 262
 //
@@ -264,57 +264,57 @@  discard block
 block discarded – undo
264 264
 // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes
265 265
 // par propre() : exemple dans multi et dans typo()
266 266
 function echappe_retour($letexte, $source = '', $filtre = '') {
267
-	if (strpos($letexte, (string) "base64$source")) {
268
-		# spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
269
-		$max_prof = 5;
270
-		while (
271
-			strpos($letexte, '<') !== false
272
-			and
273
-			preg_match_all(
274
-				',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
275
-				$letexte,
276
-				$regs,
277
-				PREG_SET_ORDER
278
-			)
279
-			and $max_prof--
280
-		) {
281
-			foreach ($regs as $reg) {
282
-				$rempl = base64_decode(extraire_attribut($reg[0], 'title'));
283
-				// recherche d'attributs supplementaires
284
-				$at = [];
285
-				foreach (['lang', 'dir'] as $attr) {
286
-					if ($a = extraire_attribut($reg[0], $attr)) {
287
-						$at[$attr] = $a;
288
-					}
289
-				}
290
-				if ($at) {
291
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
292
-					foreach ($at as $attr => $a) {
293
-						$rempl = inserer_attribut($rempl, $attr, $a);
294
-					}
295
-				}
296
-				if ($filtre) {
297
-					$rempl = $filtre($rempl);
298
-				}
299
-				$letexte = str_replace($reg[0], $rempl, $letexte);
300
-			}
301
-		}
302
-	}
303
-
304
-	return $letexte;
267
+    if (strpos($letexte, (string) "base64$source")) {
268
+        # spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
269
+        $max_prof = 5;
270
+        while (
271
+            strpos($letexte, '<') !== false
272
+            and
273
+            preg_match_all(
274
+                ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
275
+                $letexte,
276
+                $regs,
277
+                PREG_SET_ORDER
278
+            )
279
+            and $max_prof--
280
+        ) {
281
+            foreach ($regs as $reg) {
282
+                $rempl = base64_decode(extraire_attribut($reg[0], 'title'));
283
+                // recherche d'attributs supplementaires
284
+                $at = [];
285
+                foreach (['lang', 'dir'] as $attr) {
286
+                    if ($a = extraire_attribut($reg[0], $attr)) {
287
+                        $at[$attr] = $a;
288
+                    }
289
+                }
290
+                if ($at) {
291
+                    $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
292
+                    foreach ($at as $attr => $a) {
293
+                        $rempl = inserer_attribut($rempl, $attr, $a);
294
+                    }
295
+                }
296
+                if ($filtre) {
297
+                    $rempl = $filtre($rempl);
298
+                }
299
+                $letexte = str_replace($reg[0], $rempl, $letexte);
300
+            }
301
+        }
302
+    }
303
+
304
+    return $letexte;
305 305
 }
306 306
 
307 307
 // Reinserer le javascript de confiance (venant des modeles)
308 308
 
309 309
 function echappe_retour_modeles($letexte, $interdire_scripts = false) {
310
-	$letexte = echappe_retour($letexte);
310
+    $letexte = echappe_retour($letexte);
311 311
 
312
-	// Dans les appels directs hors squelette, securiser aussi ici
313
-	if ($interdire_scripts) {
314
-		$letexte = interdire_scripts($letexte);
315
-	}
312
+    // Dans les appels directs hors squelette, securiser aussi ici
313
+    if ($interdire_scripts) {
314
+        $letexte = interdire_scripts($letexte);
315
+    }
316 316
 
317
-	return trim($letexte);
317
+    return trim($letexte);
318 318
 }
319 319
 
320 320
 
@@ -342,131 +342,131 @@  discard block
 block discarded – undo
342 342
  *     Texte coupé
343 343
  **/
344 344
 function couper($texte, $taille = 50, $suite = null) {
345
-	if (!($length = strlen($texte)) or $taille <= 0) {
346
-		return '';
347
-	}
348
-	$offset = 400 + 2 * $taille;
349
-	while (
350
-		$offset < $length
351
-		and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
352
-	) {
353
-		$offset = 2 * $offset;
354
-	}
355
-	if (
356
-		$offset < $length
357
-		&& ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
358
-	) {
359
-		$p_tag_fermant = strpos($texte, '>', $offset);
360
-		if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
361
-			$offset = $p_tag_fermant + 1;
362
-		} // prolonger la coupe jusqu'au tag fermant suivant eventuel
363
-	}
364
-	$texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
365
-
366
-	if (!function_exists('nettoyer_raccourcis_typo')) {
367
-		include_spip('inc/lien');
368
-	}
369
-	$texte = nettoyer_raccourcis_typo($texte);
370
-
371
-	// balises de sauts de ligne et paragraphe
372
-	$texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
373
-	$texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
374
-
375
-	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
376
-	$texte = str_replace("\n\n", "\r", $texte);
377
-
378
-	// supprimer les tags
379
-	$texte = supprimer_tags($texte);
380
-	$texte = trim(str_replace("\n", ' ', $texte));
381
-	$texte .= "\n";  // marquer la fin
382
-
383
-	// corriger la longueur de coupe
384
-	// en fonction de la presence de caracteres utf
385
-	if ($GLOBALS['meta']['charset'] == 'utf-8') {
386
-		$long = charset2unicode($texte);
387
-		$long = spip_substr($long, 0, max($taille, 1));
388
-		$nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
389
-		$taille += $nbcharutf;
390
-	}
391
-
392
-
393
-	// couper au mot precedent
394
-	$long = spip_substr($texte, 0, max($taille - 4, 1));
395
-	$u = $GLOBALS['meta']['pcre_u'];
396
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
397
-	if (is_null($suite)) {
398
-		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
399
-	}
400
-	$points = $suite;
401
-
402
-	// trop court ? ne pas faire de (...)
403
-	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
404
-		$points = '';
405
-		$long = spip_substr($texte, 0, $taille);
406
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
407
-		// encore trop court ? couper au caractere
408
-		if (spip_strlen($texte) < 0.75 * $taille) {
409
-			$texte = $long;
410
-		}
411
-	} else {
412
-		$texte = $court;
413
-	}
414
-
415
-	if (strpos($texte, "\n")) {  // la fin est encore la : c'est qu'on n'a pas de texte de suite
416
-	$points = '';
417
-	}
418
-
419
-	// remettre les paragraphes
420
-	$texte = preg_replace("/\r+/", "\n\n", $texte);
421
-
422
-	// supprimer l'eventuelle entite finale mal coupee
423
-	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
424
-
425
-	return quote_amp(trim($texte)) . $points;
345
+    if (!($length = strlen($texte)) or $taille <= 0) {
346
+        return '';
347
+    }
348
+    $offset = 400 + 2 * $taille;
349
+    while (
350
+        $offset < $length
351
+        and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
352
+    ) {
353
+        $offset = 2 * $offset;
354
+    }
355
+    if (
356
+        $offset < $length
357
+        && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
358
+    ) {
359
+        $p_tag_fermant = strpos($texte, '>', $offset);
360
+        if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
361
+            $offset = $p_tag_fermant + 1;
362
+        } // prolonger la coupe jusqu'au tag fermant suivant eventuel
363
+    }
364
+    $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
365
+
366
+    if (!function_exists('nettoyer_raccourcis_typo')) {
367
+        include_spip('inc/lien');
368
+    }
369
+    $texte = nettoyer_raccourcis_typo($texte);
370
+
371
+    // balises de sauts de ligne et paragraphe
372
+    $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
373
+    $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
374
+
375
+    // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
376
+    $texte = str_replace("\n\n", "\r", $texte);
377
+
378
+    // supprimer les tags
379
+    $texte = supprimer_tags($texte);
380
+    $texte = trim(str_replace("\n", ' ', $texte));
381
+    $texte .= "\n";  // marquer la fin
382
+
383
+    // corriger la longueur de coupe
384
+    // en fonction de la presence de caracteres utf
385
+    if ($GLOBALS['meta']['charset'] == 'utf-8') {
386
+        $long = charset2unicode($texte);
387
+        $long = spip_substr($long, 0, max($taille, 1));
388
+        $nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
389
+        $taille += $nbcharutf;
390
+    }
391
+
392
+
393
+    // couper au mot precedent
394
+    $long = spip_substr($texte, 0, max($taille - 4, 1));
395
+    $u = $GLOBALS['meta']['pcre_u'];
396
+    $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
397
+    if (is_null($suite)) {
398
+        $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
399
+    }
400
+    $points = $suite;
401
+
402
+    // trop court ? ne pas faire de (...)
403
+    if (spip_strlen($court) < max(0.75 * $taille, 2)) {
404
+        $points = '';
405
+        $long = spip_substr($texte, 0, $taille);
406
+        $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
407
+        // encore trop court ? couper au caractere
408
+        if (spip_strlen($texte) < 0.75 * $taille) {
409
+            $texte = $long;
410
+        }
411
+    } else {
412
+        $texte = $court;
413
+    }
414
+
415
+    if (strpos($texte, "\n")) {  // la fin est encore la : c'est qu'on n'a pas de texte de suite
416
+    $points = '';
417
+    }
418
+
419
+    // remettre les paragraphes
420
+    $texte = preg_replace("/\r+/", "\n\n", $texte);
421
+
422
+    // supprimer l'eventuelle entite finale mal coupee
423
+    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
424
+
425
+    return quote_amp(trim($texte)) . $points;
426 426
 }
427 427
 
428 428
 
429 429
 function protege_js_modeles($t) {
430
-	if (isset($GLOBALS['visiteur_session'])) {
431
-		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
432
-			if (!defined('_PROTEGE_JS_MODELES')) {
433
-				include_spip('inc/acces');
434
-				define('_PROTEGE_JS_MODELES', creer_uniqid());
435
-			}
436
-			foreach ($r as $regs) {
437
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
438
-			}
439
-		}
440
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
441
-			if (!defined('_PROTEGE_PHP_MODELES')) {
442
-				include_spip('inc/acces');
443
-				define('_PROTEGE_PHP_MODELES', creer_uniqid());
444
-			}
445
-			foreach ($r as $regs) {
446
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
447
-			}
448
-		}
449
-	}
450
-
451
-	return $t;
430
+    if (isset($GLOBALS['visiteur_session'])) {
431
+        if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
432
+            if (!defined('_PROTEGE_JS_MODELES')) {
433
+                include_spip('inc/acces');
434
+                define('_PROTEGE_JS_MODELES', creer_uniqid());
435
+            }
436
+            foreach ($r as $regs) {
437
+                $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
438
+            }
439
+        }
440
+        if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
441
+            if (!defined('_PROTEGE_PHP_MODELES')) {
442
+                include_spip('inc/acces');
443
+                define('_PROTEGE_PHP_MODELES', creer_uniqid());
444
+            }
445
+            foreach ($r as $regs) {
446
+                $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
447
+            }
448
+        }
449
+    }
450
+
451
+    return $t;
452 452
 }
453 453
 
454 454
 
455 455
 function echapper_faux_tags($letexte) {
456
-	if (strpos($letexte, '<') === false) {
457
-		return $letexte;
458
-	}
459
-	$textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
460
-
461
-	$letexte = '';
462
-	while (is_countable($textMatches) ? count($textMatches) : 0) {
463
-		// un texte a echapper
464
-		$letexte .= str_replace('<', '&lt;', array_shift($textMatches));
465
-		// un tag html qui a servit a faite le split
466
-		$letexte .= array_shift($textMatches);
467
-	}
468
-
469
-	return $letexte;
456
+    if (strpos($letexte, '<') === false) {
457
+        return $letexte;
458
+    }
459
+    $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
460
+
461
+    $letexte = '';
462
+    while (is_countable($textMatches) ? count($textMatches) : 0) {
463
+        // un texte a echapper
464
+        $letexte .= str_replace('<', '&lt;', array_shift($textMatches));
465
+        // un tag html qui a servit a faite le split
466
+        $letexte .= array_shift($textMatches);
467
+    }
468
+
469
+    return $letexte;
470 470
 }
471 471
 
472 472
 /**
@@ -479,47 +479,47 @@  discard block
 block discarded – undo
479 479
  * @return string
480 480
  */
481 481
 function echapper_html_suspect($texte, $strict = true) {
482
-	static $echapper_html_suspect;
483
-	if (!$texte or !is_string($texte)) {
484
-		return $texte;
485
-	}
486
-
487
-	if (!isset($echapper_html_suspect)) {
488
-		$echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
489
-	}
490
-	// si fonction personalisee, on delegue
491
-	if ($echapper_html_suspect) {
492
-		return $echapper_html_suspect($texte, $strict);
493
-	}
494
-
495
-	if (
496
-		strpos($texte, '<') === false
497
-		or strpos($texte, '=') === false
498
-	) {
499
-		return $texte;
500
-	}
501
-
502
-	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
503
-	// car sinon on declenche sur les modeles ou ressources
504
-	if (
505
-		!$strict and
506
-		(strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
507
-	) {
508
-		return $texte;
509
-	}
510
-
511
-	// on teste sur strlen car safehtml supprime le contenu dangereux
512
-	// mais il peut aussi changer des ' en " sur les attributs html,
513
-	// donc un test d'egalite est trop strict
514
-	if (strlen(safehtml($texte)) !== strlen($texte)) {
515
-		$texte = str_replace('<', '&lt;', $texte);
516
-		if (!function_exists('attribut_html')) {
517
-			include_spip('inc/filtres');
518
-		}
519
-		$texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
520
-	}
521
-
522
-	return $texte;
482
+    static $echapper_html_suspect;
483
+    if (!$texte or !is_string($texte)) {
484
+        return $texte;
485
+    }
486
+
487
+    if (!isset($echapper_html_suspect)) {
488
+        $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
489
+    }
490
+    // si fonction personalisee, on delegue
491
+    if ($echapper_html_suspect) {
492
+        return $echapper_html_suspect($texte, $strict);
493
+    }
494
+
495
+    if (
496
+        strpos($texte, '<') === false
497
+        or strpos($texte, '=') === false
498
+    ) {
499
+        return $texte;
500
+    }
501
+
502
+    // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
503
+    // car sinon on declenche sur les modeles ou ressources
504
+    if (
505
+        !$strict and
506
+        (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
507
+    ) {
508
+        return $texte;
509
+    }
510
+
511
+    // on teste sur strlen car safehtml supprime le contenu dangereux
512
+    // mais il peut aussi changer des ' en " sur les attributs html,
513
+    // donc un test d'egalite est trop strict
514
+    if (strlen(safehtml($texte)) !== strlen($texte)) {
515
+        $texte = str_replace('<', '&lt;', $texte);
516
+        if (!function_exists('attribut_html')) {
517
+            include_spip('inc/filtres');
518
+        }
519
+        $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
520
+    }
521
+
522
+    return $texte;
523 523
 }
524 524
 
525 525
 
@@ -540,30 +540,30 @@  discard block
 block discarded – undo
540 540
  *      Texte sécurisé
541 541
  **/
542 542
 function safehtml($t) {
543
-	static $safehtml;
544
-
545
-	if (!$t or !is_string($t)) {
546
-		return $t;
547
-	}
548
-	# attention safehtml nettoie deux ou trois caracteres de plus. A voir
549
-	if (strpos($t, '<') === false) {
550
-		return str_replace("\x00", '', $t);
551
-	}
552
-
553
-	if (!function_exists('interdire_scripts')) {
554
-		include_spip('inc/texte');
555
-	}
556
-	$t = interdire_scripts($t); // jolifier le php
557
-	$t = echappe_js($t);
558
-
559
-	if (!isset($safehtml)) {
560
-		$safehtml = charger_fonction('safehtml', 'inc', true);
561
-	}
562
-	if ($safehtml) {
563
-		$t = $safehtml($t);
564
-	}
565
-
566
-	return interdire_scripts($t); // interdire le php (2 precautions)
543
+    static $safehtml;
544
+
545
+    if (!$t or !is_string($t)) {
546
+        return $t;
547
+    }
548
+    # attention safehtml nettoie deux ou trois caracteres de plus. A voir
549
+    if (strpos($t, '<') === false) {
550
+        return str_replace("\x00", '', $t);
551
+    }
552
+
553
+    if (!function_exists('interdire_scripts')) {
554
+        include_spip('inc/texte');
555
+    }
556
+    $t = interdire_scripts($t); // jolifier le php
557
+    $t = echappe_js($t);
558
+
559
+    if (!isset($safehtml)) {
560
+        $safehtml = charger_fonction('safehtml', 'inc', true);
561
+    }
562
+    if ($safehtml) {
563
+        $t = $safehtml($t);
564
+    }
565
+
566
+    return interdire_scripts($t); // interdire le php (2 precautions)
567 567
 }
568 568
 
569 569
 
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
  *     Texte sans les modèles d'image
586 586
  **/
587 587
 function supprime_img($letexte, $message = null) {
588
-	if ($message === null) {
589
-		$message = '(' . _T('img_indisponible') . ')';
590
-	}
591
-
592
-	return preg_replace(
593
-		',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
594
-		$message,
595
-		$letexte
596
-	);
588
+    if ($message === null) {
589
+        $message = '(' . _T('img_indisponible') . ')';
590
+    }
591
+
592
+    return preg_replace(
593
+        ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
594
+        $message,
595
+        $letexte
596
+    );
597 597
 }
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   +293 added lines, -293 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
 /**
@@ -22,320 +22,320 @@  discard block
 block discarded – undo
22 22
  *     on a les memes methodes et variables que l'indenteur
23 23
  **/
24 24
 class ValidateurXML {
25
-	public function validerElement($phraseur, $name, $attrs) {
26
-		if (!($p = isset($this->dtc->elements[$name]))) {
27
-			if ($p = strpos($name, ':')) {
28
-				$name = substr($name, $p + 1);
29
-				$p = isset($this->dtc->elements[$name]);
30
-			}
31
-			if (!$p) {
32
-				coordonnees_erreur($this, " <b>$name</b>&nbsp;: "
33
-					. _T('zxml_inconnu_balise'));
25
+    public function validerElement($phraseur, $name, $attrs) {
26
+        if (!($p = isset($this->dtc->elements[$name]))) {
27
+            if ($p = strpos($name, ':')) {
28
+                $name = substr($name, $p + 1);
29
+                $p = isset($this->dtc->elements[$name]);
30
+            }
31
+            if (!$p) {
32
+                coordonnees_erreur($this, " <b>$name</b>&nbsp;: "
33
+                    . _T('zxml_inconnu_balise'));
34 34
 
35
-				return;
36
-			}
37
-		}
38
-		// controler les filles illegitimes, ca suffit
39
-		$depth = $this->depth;
40
-		$ouvrant = $this->ouvrant;
41
-		#spip_log("trouve $name apres " . $ouvrant[$depth]);
42
-		if (isset($ouvrant[$depth])) {
43
-			if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
44
-				$pere = $r[1];
45
-				#spip_log("pere $pere");
46
-				if (isset($this->dtc->elements[$pere])) {
47
-					$fils = $this->dtc->elements[$pere];
48
-					#spip_log("rejeton $name fils " . @join(',',$fils));
49
-					if (!($p = @in_array($name, $fils))) {
50
-						if ($p = strpos($name, ':')) {
51
-							$p = substr($name, $p + 1);
52
-							$p = @in_array($p, $fils);
53
-						}
54
-					}
55
-					if (!$p) {
56
-						$bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]);
57
-						coordonnees_erreur($this, " <b>$name</b> "
58
-							. _T('zxml_non_fils')
59
-							. ' <b>'
60
-							. $pere
61
-							. '</b>'
62
-							. (!$bons_peres ? ''
63
-								: ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
64
-					} elseif ($this->dtc->regles[$pere][0] == '/') {
65
-						$frat = substr($depth, 2);
66
-						if (!isset($this->fratrie[$frat])) {
67
-							$this->fratrie[$frat] = '';
68
-						}
69
-						$this->fratrie[$frat] .= "$name ";
70
-					}
71
-				}
72
-			}
73
-		}
74
-		// Init de la suite des balises a memoriser si regle difficile
75
-		if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') {
76
-			$this->fratrie[$depth] = '';
77
-		}
78
-		if (isset($this->dtc->attributs[$name])) {
79
-			foreach ($this->dtc->attributs[$name] as $n => $v) {
80
-				if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) {
81
-					coordonnees_erreur($this, " <b>$n</b>"
82
-						. '&nbsp;:&nbsp;'
83
-						. _T('zxml_obligatoire_attribut')
84
-						. " <b>$name</b>");
85
-				}
86
-			}
87
-		}
88
-	}
35
+                return;
36
+            }
37
+        }
38
+        // controler les filles illegitimes, ca suffit
39
+        $depth = $this->depth;
40
+        $ouvrant = $this->ouvrant;
41
+        #spip_log("trouve $name apres " . $ouvrant[$depth]);
42
+        if (isset($ouvrant[$depth])) {
43
+            if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
44
+                $pere = $r[1];
45
+                #spip_log("pere $pere");
46
+                if (isset($this->dtc->elements[$pere])) {
47
+                    $fils = $this->dtc->elements[$pere];
48
+                    #spip_log("rejeton $name fils " . @join(',',$fils));
49
+                    if (!($p = @in_array($name, $fils))) {
50
+                        if ($p = strpos($name, ':')) {
51
+                            $p = substr($name, $p + 1);
52
+                            $p = @in_array($p, $fils);
53
+                        }
54
+                    }
55
+                    if (!$p) {
56
+                        $bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]);
57
+                        coordonnees_erreur($this, " <b>$name</b> "
58
+                            . _T('zxml_non_fils')
59
+                            . ' <b>'
60
+                            . $pere
61
+                            . '</b>'
62
+                            . (!$bons_peres ? ''
63
+                                : ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
64
+                    } elseif ($this->dtc->regles[$pere][0] == '/') {
65
+                        $frat = substr($depth, 2);
66
+                        if (!isset($this->fratrie[$frat])) {
67
+                            $this->fratrie[$frat] = '';
68
+                        }
69
+                        $this->fratrie[$frat] .= "$name ";
70
+                    }
71
+                }
72
+            }
73
+        }
74
+        // Init de la suite des balises a memoriser si regle difficile
75
+        if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') {
76
+            $this->fratrie[$depth] = '';
77
+        }
78
+        if (isset($this->dtc->attributs[$name])) {
79
+            foreach ($this->dtc->attributs[$name] as $n => $v) {
80
+                if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) {
81
+                    coordonnees_erreur($this, " <b>$n</b>"
82
+                        . '&nbsp;:&nbsp;'
83
+                        . _T('zxml_obligatoire_attribut')
84
+                        . " <b>$name</b>");
85
+                }
86
+            }
87
+        }
88
+    }
89 89
 
90
-	public function validerAttribut($phraseur, $name, $val, $bal) {
91
-		// Si la balise est inconnue, eviter d'insister
92
-		if (!isset($this->dtc->attributs[$bal])) {
93
-			return;
94
-		}
90
+    public function validerAttribut($phraseur, $name, $val, $bal) {
91
+        // Si la balise est inconnue, eviter d'insister
92
+        if (!isset($this->dtc->attributs[$bal])) {
93
+            return;
94
+        }
95 95
 
96
-		$a = $this->dtc->attributs[$bal];
97
-		if (!isset($a[$name])) {
98
-			$bons = join(', ', array_keys($a));
99
-			if ($bons) {
100
-				$bons = " title=' " .
101
-					_T('zxml_connus_attributs') .
102
-					'&nbsp;: ' .
103
-					$bons .
104
-					"'";
105
-			}
106
-			$bons .= " style='font-weight: bold'";
107
-			coordonnees_erreur($this, " <b>$name</b> "
108
-				. _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
109
-				. " <a$bons>$bal</a> ("
110
-				. _T('zxml_survoler')
111
-				. ')');
112
-		} else {
113
-			$type = $a[$name][0];
114
-			if (!preg_match('/^\w+$/', $type)) {
115
-				$this->valider_motif($phraseur, $name, $val, $bal, $type);
116
-			} else {
117
-				if (method_exists($this, $f = 'validerAttribut_' . $type)) {
118
-					$this->$f($phraseur, $name, $val, $bal);
119
-				}
120
-			}
121
-			#		else spip_log("$type type d'attribut inconnu");
122
-		}
123
-	}
96
+        $a = $this->dtc->attributs[$bal];
97
+        if (!isset($a[$name])) {
98
+            $bons = join(', ', array_keys($a));
99
+            if ($bons) {
100
+                $bons = " title=' " .
101
+                    _T('zxml_connus_attributs') .
102
+                    '&nbsp;: ' .
103
+                    $bons .
104
+                    "'";
105
+            }
106
+            $bons .= " style='font-weight: bold'";
107
+            coordonnees_erreur($this, " <b>$name</b> "
108
+                . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
109
+                . " <a$bons>$bal</a> ("
110
+                . _T('zxml_survoler')
111
+                . ')');
112
+        } else {
113
+            $type = $a[$name][0];
114
+            if (!preg_match('/^\w+$/', $type)) {
115
+                $this->valider_motif($phraseur, $name, $val, $bal, $type);
116
+            } else {
117
+                if (method_exists($this, $f = 'validerAttribut_' . $type)) {
118
+                    $this->$f($phraseur, $name, $val, $bal);
119
+                }
120
+            }
121
+            #		else spip_log("$type type d'attribut inconnu");
122
+        }
123
+    }
124 124
 
125
-	public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) {
126
-		$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN);
127
-	}
125
+    public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) {
126
+        $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN);
127
+    }
128 128
 
129
-	public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) {
130
-		$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS);
131
-	}
129
+    public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) {
130
+        $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS);
131
+    }
132 132
 
133
-	public function validerAttribut_ID($phraseur, $name, $val, $bal) {
134
-		if (isset($this->ids[$val])) {
135
-			[$l, $c] = $this->ids[$val];
136
-			coordonnees_erreur($this, " <p><b>$val</b> "
137
-				. _T('zxml_valeur_attribut')
138
-				. " <b>$name</b> "
139
-				. _T('zxml_de')
140
-				. " <b>$bal</b> "
141
-				. _T('zxml_vu')
142
-				. " (L$l,C$c)");
143
-		} else {
144
-			$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID);
145
-			$this->ids[$val] = [xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
146
-		}
147
-	}
133
+    public function validerAttribut_ID($phraseur, $name, $val, $bal) {
134
+        if (isset($this->ids[$val])) {
135
+            [$l, $c] = $this->ids[$val];
136
+            coordonnees_erreur($this, " <p><b>$val</b> "
137
+                . _T('zxml_valeur_attribut')
138
+                . " <b>$name</b> "
139
+                . _T('zxml_de')
140
+                . " <b>$bal</b> "
141
+                . _T('zxml_vu')
142
+                . " (L$l,C$c)");
143
+        } else {
144
+            $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID);
145
+            $this->ids[$val] = [xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
146
+        }
147
+    }
148 148
 
149
-	public function validerAttribut_IDREF($phraseur, $name, $val, $bal) {
150
-		$this->idrefs[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
151
-	}
149
+    public function validerAttribut_IDREF($phraseur, $name, $val, $bal) {
150
+        $this->idrefs[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
151
+    }
152 152
 
153
-	public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) {
154
-		$this->idrefss[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
155
-	}
153
+    public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) {
154
+        $this->idrefss[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
155
+    }
156 156
 
157
-	public function valider_motif($phraseur, $name, $val, $bal, $motif) {
158
-		if (!preg_match($motif, $val)) {
159
-			coordonnees_erreur($this, "<b>$val</b> "
160
-				. _T('zxml_valeur_attribut')
161
-				. " <b>$name</b> "
162
-				. _T('zxml_de')
163
-				. " <b>$bal</b> "
164
-				. _T('zxml_non_conforme')
165
-				. '</p><p>'
166
-				. '<b>' . $motif . '</b>');
167
-		}
168
-	}
157
+    public function valider_motif($phraseur, $name, $val, $bal, $motif) {
158
+        if (!preg_match($motif, $val)) {
159
+            coordonnees_erreur($this, "<b>$val</b> "
160
+                . _T('zxml_valeur_attribut')
161
+                . " <b>$name</b> "
162
+                . _T('zxml_de')
163
+                . " <b>$bal</b> "
164
+                . _T('zxml_non_conforme')
165
+                . '</p><p>'
166
+                . '<b>' . $motif . '</b>');
167
+        }
168
+    }
169 169
 
170
-	public function valider_idref($nom, $ligne, $col) {
171
-		if (!isset($this->ids[$nom])) {
172
-			$this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
173
-		}
174
-	}
170
+    public function valider_idref($nom, $ligne, $col) {
171
+        if (!isset($this->ids[$nom])) {
172
+            $this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
173
+        }
174
+    }
175 175
 
176
-	public function valider_passe2() {
177
-		if (!$this->err) {
178
-			foreach ($this->idrefs as $idref) {
179
-				[$nom, $ligne, $col] = $idref;
180
-				$this->valider_idref($nom, $ligne, $col);
181
-			}
182
-			foreach ($this->idrefss as $idref) {
183
-				[$noms, $ligne, $col] = $idref;
184
-				foreach (preg_split('/\s+/', $noms) as $nom) {
185
-					$this->valider_idref($nom, $ligne, $col);
186
-				}
187
-			}
188
-		}
189
-	}
176
+    public function valider_passe2() {
177
+        if (!$this->err) {
178
+            foreach ($this->idrefs as $idref) {
179
+                [$nom, $ligne, $col] = $idref;
180
+                $this->valider_idref($nom, $ligne, $col);
181
+            }
182
+            foreach ($this->idrefss as $idref) {
183
+                [$noms, $ligne, $col] = $idref;
184
+                foreach (preg_split('/\s+/', $noms) as $nom) {
185
+                    $this->valider_idref($nom, $ligne, $col);
186
+                }
187
+            }
188
+        }
189
+    }
190 190
 
191
-	public function debutElement($phraseur, $name, $attrs) {
192
-		if ($this->dtc->elements) {
193
-			$this->validerElement($phraseur, $name, $attrs);
194
-		}
191
+    public function debutElement($phraseur, $name, $attrs) {
192
+        if ($this->dtc->elements) {
193
+            $this->validerElement($phraseur, $name, $attrs);
194
+        }
195 195
 
196
-		if ($f = $this->process['debut']) {
197
-			$f($this, $name, $attrs);
198
-		}
199
-		$depth = $this->depth;
200
-		$this->debuts[$depth] = strlen($this->res);
201
-		foreach ($attrs as $k => $v) {
202
-			$this->validerAttribut($phraseur, $k, $v, $name);
203
-		}
204
-	}
196
+        if ($f = $this->process['debut']) {
197
+            $f($this, $name, $attrs);
198
+        }
199
+        $depth = $this->depth;
200
+        $this->debuts[$depth] = strlen($this->res);
201
+        foreach ($attrs as $k => $v) {
202
+            $this->validerAttribut($phraseur, $k, $v, $name);
203
+        }
204
+    }
205 205
 
206
-	public function finElement($phraseur, $name) {
207
-		$depth = $this->depth;
208
-		$contenu = $this->contenu;
206
+    public function finElement($phraseur, $name) {
207
+        $depth = $this->depth;
208
+        $contenu = $this->contenu;
209 209
 
210
-		$n = strlen($this->res);
211
-		$c = strlen(trim($contenu[$depth]));
212
-		$k = $this->debuts[$depth];
210
+        $n = strlen($this->res);
211
+        $c = strlen(trim($contenu[$depth]));
212
+        $k = $this->debuts[$depth];
213 213
 
214
-		$regle = $this->dtc->regles[$name] ?? false;
215
-		$vide = ($regle == 'EMPTY');
216
-		// controler que les balises devant etre vides le sont
217
-		if ($vide) {
218
-			if ($n <> ($k + $c)) {
219
-				coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
220
-			}
221
-			// pour les regles PCDATA ou iteration de disjonction, tout est fait
222
-		} elseif ($regle and ($regle != '*')) {
223
-			if ($regle == '+') {
224
-				// iteration de disjonction non vide: 1 balise au -
225
-				if ($n == $k) {
226
-					coordonnees_erreur($this, "<p>\n<b>$name</b> "
227
-						. _T('zxml_vide_balise'));
228
-				}
229
-			} else {
230
-				$f = $this->fratrie[substr($depth, 2)] ?? null;
231
-				if (is_null($f) or !preg_match($regle, $f)) {
232
-					coordonnees_erreur(
233
-						$this,
234
-						" <p>\n<b>$name</b> "
235
-						. _T('zxml_succession_fils_incorrecte')
236
-						. '&nbsp;: <b>'
237
-						. $f
238
-						. '</b>'
239
-					);
240
-				}
241
-			}
242
-		}
243
-		if ($f = $this->process['fin']) {
244
-			$f($this, $name, $vide);
245
-		}
246
-	}
214
+        $regle = $this->dtc->regles[$name] ?? false;
215
+        $vide = ($regle == 'EMPTY');
216
+        // controler que les balises devant etre vides le sont
217
+        if ($vide) {
218
+            if ($n <> ($k + $c)) {
219
+                coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
220
+            }
221
+            // pour les regles PCDATA ou iteration de disjonction, tout est fait
222
+        } elseif ($regle and ($regle != '*')) {
223
+            if ($regle == '+') {
224
+                // iteration de disjonction non vide: 1 balise au -
225
+                if ($n == $k) {
226
+                    coordonnees_erreur($this, "<p>\n<b>$name</b> "
227
+                        . _T('zxml_vide_balise'));
228
+                }
229
+            } else {
230
+                $f = $this->fratrie[substr($depth, 2)] ?? null;
231
+                if (is_null($f) or !preg_match($regle, $f)) {
232
+                    coordonnees_erreur(
233
+                        $this,
234
+                        " <p>\n<b>$name</b> "
235
+                        . _T('zxml_succession_fils_incorrecte')
236
+                        . '&nbsp;: <b>'
237
+                        . $f
238
+                        . '</b>'
239
+                    );
240
+                }
241
+            }
242
+        }
243
+        if ($f = $this->process['fin']) {
244
+            $f($this, $name, $vide);
245
+        }
246
+    }
247 247
 
248
-	public function textElement($phraseur, $data) {
249
-		if (trim($data)) {
250
-			$d = $this->depth;
251
-			$d = $this->ouvrant[$d];
252
-			preg_match('/^\s*(\S+)/', $d, $m);
253
-			if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
254
-				coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
255
-					. _T('zxml_nonvide_balise')); // message a affiner
256
-			}
257
-		}
258
-		if ($f = $this->process['text']) {
259
-			$f($this, $data);
260
-		}
261
-	}
248
+    public function textElement($phraseur, $data) {
249
+        if (trim($data)) {
250
+            $d = $this->depth;
251
+            $d = $this->ouvrant[$d];
252
+            preg_match('/^\s*(\S+)/', $d, $m);
253
+            if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
254
+                coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
255
+                    . _T('zxml_nonvide_balise')); // message a affiner
256
+            }
257
+        }
258
+        if ($f = $this->process['text']) {
259
+            $f($this, $data);
260
+        }
261
+    }
262 262
 
263
-	public function piElement($phraseur, $target, $data) {
264
-		if ($f = $this->process['pi']) {
265
-			$f($this, $target, $data);
266
-		}
267
-	}
263
+    public function piElement($phraseur, $target, $data) {
264
+        if ($f = $this->process['pi']) {
265
+            $f($this, $target, $data);
266
+        }
267
+    }
268 268
 
269
-	// Denonciation des entitees XML inconnues
270
-	// Pour contourner le bug de conception de SAX qui ne signale pas si elles
271
-	// sont dans un attribut, les  entites les plus frequentes ont ete
272
-	// transcodees au prealable  (sauf & < > " que SAX traite correctement).
273
-	// On ne les verra donc pas passer a cette etape, contrairement a ce que
274
-	// le source de la page laisse legitimement supposer.
269
+    // Denonciation des entitees XML inconnues
270
+    // Pour contourner le bug de conception de SAX qui ne signale pas si elles
271
+    // sont dans un attribut, les  entites les plus frequentes ont ete
272
+    // transcodees au prealable  (sauf & < > " que SAX traite correctement).
273
+    // On ne les verra donc pas passer a cette etape, contrairement a ce que
274
+    // le source de la page laisse legitimement supposer.
275 275
 
276
-	public function defaultElement($phraseur, $data) {
277
-		if (
278
-			!preg_match('/^<!--/', $data)
279
-			and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))
280
-		) {
281
-			foreach ($r as $m) {
282
-				[$t, $e] = $m;
283
-				if (!isset($this->dtc->entites[$e])) {
284
-					coordonnees_erreur($this, " <b>$e</b> "
285
-						. _T('zxml_inconnu_entite')
286
-						. ' ');
287
-				}
288
-			}
289
-		}
290
-		if (isset($this->process['default']) and ($f = $this->process['default'])) {
291
-			$f($this, $data);
292
-		}
293
-	}
276
+    public function defaultElement($phraseur, $data) {
277
+        if (
278
+            !preg_match('/^<!--/', $data)
279
+            and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))
280
+        ) {
281
+            foreach ($r as $m) {
282
+                [$t, $e] = $m;
283
+                if (!isset($this->dtc->entites[$e])) {
284
+                    coordonnees_erreur($this, " <b>$e</b> "
285
+                        . _T('zxml_inconnu_entite')
286
+                        . ' ');
287
+                }
288
+            }
289
+        }
290
+        if (isset($this->process['default']) and ($f = $this->process['default'])) {
291
+            $f($this, $data);
292
+        }
293
+    }
294 294
 
295
-	public function phraserTout($phraseur, $data) {
296
-		xml_parsestring($this, $data);
295
+    public function phraserTout($phraseur, $data) {
296
+        xml_parsestring($this, $data);
297 297
 
298
-		if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
299
-			$this->err[] = ['DOCTYPE ?', 0, 0];
300
-		} else {
301
-			$this->valider_passe2();
302
-		}
303
-	}
298
+        if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
299
+            $this->err[] = ['DOCTYPE ?', 0, 0];
300
+        } else {
301
+            $this->valider_passe2();
302
+        }
303
+    }
304 304
 
305
-	/**
306
-	 * Constructeur
307
-	 *
308
-	 * @param array $process ?
309
-	 **/
310
-	public function __construct($process = []) {
311
-		if (is_array($process)) {
312
-			$this->process = $process;
313
-		}
314
-	}
305
+    /**
306
+     * Constructeur
307
+     *
308
+     * @param array $process ?
309
+     **/
310
+    public function __construct($process = []) {
311
+        if (is_array($process)) {
312
+            $this->process = $process;
313
+        }
314
+    }
315 315
 
316
-	public $ids = [];
317
-	public $idrefs = [];
318
-	public $idrefss = [];
319
-	public $debuts = [];
320
-	public $fratrie = [];
316
+    public $ids = [];
317
+    public $idrefs = [];
318
+    public $idrefss = [];
319
+    public $debuts = [];
320
+    public $fratrie = [];
321 321
 
322
-	public $dtc = null;
323
-	public $sax = null;
324
-	public $depth = '';
325
-	public $entete = '';
326
-	public $page = '';
327
-	public $res = '';
328
-	public $err = [];
329
-	public $contenu = [];
330
-	public $ouvrant = [];
331
-	public $reperes = [];
332
-	public $process = [
333
-		'debut' => 'xml_debutElement',
334
-		'fin' => 'xml_finElement',
335
-		'text' => 'xml_textElement',
336
-		'pi' => 'xml_piElement',
337
-		'default' => 'xml_defaultElement'
338
-	];
322
+    public $dtc = null;
323
+    public $sax = null;
324
+    public $depth = '';
325
+    public $entete = '';
326
+    public $page = '';
327
+    public $res = '';
328
+    public $err = [];
329
+    public $contenu = [];
330
+    public $ouvrant = [];
331
+    public $reperes = [];
332
+    public $process = [
333
+        'debut' => 'xml_debutElement',
334
+        'fin' => 'xml_finElement',
335
+        'text' => 'xml_textElement',
336
+        'pi' => 'xml_piElement',
337
+        'default' => 'xml_defaultElement'
338
+    ];
339 339
 }
340 340
 
341 341
 
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
  *
346 346
  **/
347 347
 function xml_valider_dist($page, $apply = false, $process = false, $doctype = '', $charset = null) {
348
-	$f = new ValidateurXML($process);
349
-	$sax = charger_fonction('sax', 'xml');
348
+    $f = new ValidateurXML($process);
349
+    $sax = charger_fonction('sax', 'xml');
350 350
 
351
-	return $sax($page, $apply, $f, $doctype, $charset);
351
+    return $sax($page, $apply, $f, $doctype, $charset);
352 352
 }
Please login to merge, or discard this patch.
ecrire/install/etape_ldap4.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -11,96 +11,96 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('auth/ldap');
18 18
 
19 19
 function install_etape_ldap4_dist() {
20
-	$adresse_ldap = _request('adresse_ldap');
21
-	$login_ldap = _request('login_ldap');
22
-	$pass_ldap = _request('pass_ldap');
23
-	$port_ldap = _request('port_ldap');
24
-	$base_ldap = _request('base_ldap');
25
-	$base_ldap_text = _request('base_ldap_text');
26
-	if (!$base_ldap) {
27
-		$base_ldap = $base_ldap_text;
28
-	}
29
-
30
-	echo install_debut_html('AUTO', ' 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 install_fin_html();
20
+    $adresse_ldap = _request('adresse_ldap');
21
+    $login_ldap = _request('login_ldap');
22
+    $pass_ldap = _request('pass_ldap');
23
+    $port_ldap = _request('port_ldap');
24
+    $base_ldap = _request('base_ldap');
25
+    $base_ldap_text = _request('base_ldap_text');
26
+    if (!$base_ldap) {
27
+        $base_ldap = $base_ldap_text;
28
+    }
29
+
30
+    echo install_debut_html('AUTO', ' 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 install_fin_html();
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.
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.
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.