Completed
Push — master ( 09834f...75dce3 )
by cam
02:05
created
ecrire/balise/url_logout.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  *     Pile complétée du code compilé
36 36
  **/
37 37
 function balise_URL_LOGOUT($p) {
38
-	return calculer_balise_dynamique($p, 'URL_LOGOUT', []);
38
+    return calculer_balise_dynamique($p, 'URL_LOGOUT', []);
39 39
 }
40 40
 
41 41
 
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
  *   Liste (url) des arguments collectés.
52 52
  */
53 53
 function balise_URL_LOGOUT_stat($args, $context_compil) {
54
-	$url = $args[0] ?? '';
54
+    $url = $args[0] ?? '';
55 55
 
56
-	return [$url];
56
+    return [$url];
57 57
 }
58 58
 
59 59
 /**
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
  **/
69 69
 function balise_URL_LOGOUT_dyn($cible) {
70 70
 
71
-	if (empty($GLOBALS['visiteur_session']['login']) && empty($GLOBALS['visiteur_session']['statut'])) {
72
-		return '';
73
-	}
71
+    if (empty($GLOBALS['visiteur_session']['login']) && empty($GLOBALS['visiteur_session']['statut'])) {
72
+        return '';
73
+    }
74 74
 
75
-	return generer_url_action('logout', 'logout=public&url=' . rawurlencode((string) ($cible ?: self('&'))));
75
+    return generer_url_action('logout', 'logout=public&url=' . rawurlencode((string) ($cible ?: self('&'))));
76 76
 }
Please login to merge, or discard this patch.
ecrire/balise/menu_lang.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  *     Pile complétée du code compilé
37 37
  **/
38 38
 function balise_MENU_LANG($p) {
39
-	return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']);
39
+    return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']);
40 40
 }
41 41
 
42 42
 /**
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
  *   string: (vide) si pas de multilinguisme
56 56
  */
57 57
 function balise_MENU_LANG_stat($args, $context_compil) {
58
-	if (!str_contains((string) $GLOBALS['meta']['langues_multilingue'], ',')) {
59
-		return '';
60
-	}
58
+    if (!str_contains((string) $GLOBALS['meta']['langues_multilingue'], ',')) {
59
+        return '';
60
+    }
61 61
 
62
-	return $args;
62
+    return $args;
63 63
 }
64 64
 
65 65
 /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
  *     Liste : Chemin du squelette, durée du cache, contexte
76 76
  **/
77 77
 function balise_MENU_LANG_dyn($opt) {
78
-	include_spip('balise/menu_lang_ecrire');
78
+    include_spip('balise/menu_lang_ecrire');
79 79
 
80
-	return menu_lang_pour_tous('var_lang', $opt);
80
+    return menu_lang_pour_tous('var_lang', $opt);
81 81
 }
Please login to merge, or discard this patch.
ecrire/balise/menu_lang_ecrire.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  *     Pile complétée du code compilé
37 37
  **/
38 38
 function balise_MENU_LANG_ECRIRE($p) {
39
-	return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']);
39
+    return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']);
40 40
 }
41 41
 
42 42
 /**
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
  *   - string: Si pas de multilinguisme
56 56
  */
57 57
 function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) {
58
-	include_spip('inc/lang');
59
-	if (!str_contains((string) $GLOBALS['meta']['langues_proposees'], ',')) {
60
-		return '';
61
-	}
58
+    include_spip('inc/lang');
59
+    if (!str_contains((string) $GLOBALS['meta']['langues_proposees'], ',')) {
60
+        return '';
61
+    }
62 62
 
63
-	return $args;
63
+    return $args;
64 64
 }
65 65
 
66 66
 /**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
  *     Liste : Chemin du squelette, durée du cache, contexte
77 77
  **/
78 78
 function balise_MENU_LANG_ECRIRE_dyn($opt) {
79
-	return menu_lang_pour_tous('var_lang_ecrire', $opt);
79
+    return menu_lang_pour_tous('var_lang_ecrire', $opt);
80 80
 }
81 81
 
82 82
 /**
@@ -96,30 +96,30 @@  discard block
 block discarded – undo
96 96
  *     Liste : Chemin du squelette, durée du cache, contexte
97 97
  **/
98 98
 function menu_lang_pour_tous($nom, $default) {
99
-	include_spip('inc/lang');
99
+    include_spip('inc/lang');
100 100
 
101
-	if ($GLOBALS['spip_lang'] != $default) {
102
-		$opt = lang_select($default);  # et remplace
103
-		if ($GLOBALS['spip_lang'] != $default) {
104
-			$default = '';  # annule tout choix par defaut
105
-			if ($opt) {
106
-				lang_select();
107
-			}
108
-		}
109
-	}
101
+    if ($GLOBALS['spip_lang'] != $default) {
102
+        $opt = lang_select($default);  # et remplace
103
+        if ($GLOBALS['spip_lang'] != $default) {
104
+            $default = '';  # annule tout choix par defaut
105
+            if ($opt) {
106
+                lang_select();
107
+            }
108
+        }
109
+    }
110 110
 
111
-	# lien a partir de /
112
-	$cible = parametre_url(self(), 'lang', '', '&');
113
-	$post = generer_url_action('converser', 'redirect=' . rawurlencode((string) $cible), true);
111
+    # lien a partir de /
112
+    $cible = parametre_url(self(), 'lang', '', '&');
113
+    $post = generer_url_action('converser', 'redirect=' . rawurlencode((string) $cible), true);
114 114
 
115
-	return [
116
-		'formulaires/menu_lang',
117
-		3600,
118
-		[
119
-			'nom' => $nom,
120
-			'url' => $post,
121
-			'name' => $nom,
122
-			'default' => $default,
123
-		]
124
-	];
115
+    return [
116
+        'formulaires/menu_lang',
117
+        3600,
118
+        [
119
+            'nom' => $nom,
120
+            'url' => $post,
121
+            'name' => $nom,
122
+            'default' => $default,
123
+        ]
124
+    ];
125 125
 }
Please login to merge, or discard this patch.
ecrire/balise/formulaire_admin.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  *     Pile complétée du code compilé
42 42
  **/
43 43
 function balise_FORMULAIRE_ADMIN($p) {
44
-	return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
44
+    return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
45 45
 }
46 46
 
47 47
 /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
  *   - chaîne vide sinon.
59 59
  */
60 60
 function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
61
-	return $args;
61
+    return $args;
62 62
 }
63 63
 
64 64
 
@@ -83,64 +83,64 @@  discard block
 block discarded – undo
83 83
  **/
84 84
 function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') {
85 85
 
86
-	static $dejafait = false;
86
+    static $dejafait = false;
87 87
 
88
-	if (empty($_COOKIE['spip_admin'])) {
89
-		return '';
90
-	}
88
+    if (empty($_COOKIE['spip_admin'])) {
89
+        return '';
90
+    }
91 91
 
92
-	if (!is_array($debug)) {
93
-		if ($dejafait) {
94
-			return '';
95
-		}
96
-	} else {
97
-		if ($dejafait) {
98
-			if (empty($debug['sourcefile'])) {
99
-				return '';
100
-			}
101
-			foreach ($debug['sourcefile'] as $k => $v) {
102
-				if (str_contains((string) $v, 'administration.') && isset($debug['resultat'][$k . 'tout'])) {
103
-					return $debug['resultat'][$k . 'tout'];
104
-				}
105
-			}
92
+    if (!is_array($debug)) {
93
+        if ($dejafait) {
94
+            return '';
95
+        }
96
+    } else {
97
+        if ($dejafait) {
98
+            if (empty($debug['sourcefile'])) {
99
+                return '';
100
+            }
101
+            foreach ($debug['sourcefile'] as $k => $v) {
102
+                if (str_contains((string) $v, 'administration.') && isset($debug['resultat'][$k . 'tout'])) {
103
+                    return $debug['resultat'][$k . 'tout'];
104
+                }
105
+            }
106 106
 
107
-			return '';
108
-		}
109
-	}
107
+            return '';
108
+        }
109
+    }
110 110
 
111
-	include_spip('inc/autoriser');
112
-	include_spip('base/abstract_sql');
111
+    include_spip('inc/autoriser');
112
+    include_spip('base/abstract_sql');
113 113
 
114 114
 
115
-	$dejafait = true;
115
+    $dejafait = true;
116 116
 
117
-	// Preparer le #ENV des boutons
117
+    // Preparer le #ENV des boutons
118 118
 
119
-	$env = admin_objet();
119
+    $env = admin_objet();
120 120
 
121
-	// Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
122
-	if (!$env) {
123
-		$env['ecrire'] = _DIR_RESTREINT_ABS;
124
-	}
121
+    // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
122
+    if (!$env) {
123
+        $env['ecrire'] = _DIR_RESTREINT_ABS;
124
+    }
125 125
 
126
-	$env['divclass'] = $float;
127
-	$env['lang'] = admin_lang();
128
-	$env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
129
-	$env['debug'] = ((defined('_VAR_PREVIEW') && _VAR_PREVIEW) ? '' : admin_debug());
130
-	$env['analyser'] = (!$env['debug'] && !$GLOBALS['xhtml']) ? '' : admin_valider();
131
-	$env['inclure'] = ((defined('_VAR_INCLURE') && _VAR_INCLURE) ? 'inclure' : '');
126
+    $env['divclass'] = $float;
127
+    $env['lang'] = admin_lang();
128
+    $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
129
+    $env['debug'] = ((defined('_VAR_PREVIEW') && _VAR_PREVIEW) ? '' : admin_debug());
130
+    $env['analyser'] = (!$env['debug'] && !$GLOBALS['xhtml']) ? '' : admin_valider();
131
+    $env['inclure'] = ((defined('_VAR_INCLURE') && _VAR_INCLURE) ? 'inclure' : '');
132 132
 
133
-	if (empty($GLOBALS['use_cache'])) {
134
-		$env['use_cache'] = ' *';
135
-	}
133
+    if (empty($GLOBALS['use_cache'])) {
134
+        $env['use_cache'] = ' *';
135
+    }
136 136
 
137
-	if (isset($debug['validation'])) {
138
-		$env['xhtml_error'] = $debug['validation'];
139
-	}
137
+    if (isset($debug['validation'])) {
138
+        $env['xhtml_error'] = $debug['validation'];
139
+    }
140 140
 
141
-	$env['_pipelines']['formulaire_admin'] = [];
141
+    $env['_pipelines']['formulaire_admin'] = [];
142 142
 
143
-	return ['formulaires/administration', 0, $env];
143
+    return ['formulaires/administration', 0, $env];
144 144
 }
145 145
 
146 146
 
@@ -158,46 +158,46 @@  discard block
 block discarded – undo
158 158
  *     Tableau de l'environnement calculé
159 159
  **/
160 160
 function admin_objet() {
161
-	include_spip('inc/urls');
162
-	$env = [];
163
-
164
-	$trouver_table = charger_fonction('trouver_table', 'base');
165
-	$objets = urls_liste_objets(false);
166
-	$objets = array_diff($objets, ['rubrique']);
167
-	$objets = array_reverse($objets);
168
-	array_unshift($objets, 'rubrique');
169
-	foreach ($objets as $obj) {
170
-		$type = $obj;
171
-		if (
172
-			$type == objet_type($type, false)
173
-			&& ($_id_type = id_table_objet($type))
174
-			&& isset($GLOBALS['contexte'][$_id_type])
175
-			&& ($id = $GLOBALS['contexte'][$_id_type])
176
-			&& !is_array($id)
177
-			&& ($id = (int) $id)
178
-			&& ($desc = $trouver_table(table_objet_sql($type)))
179
-		) {
180
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . (int) $id);
181
-			if ($id) {
182
-				$env[$_id_type] = $id;
183
-				$env['objet'] = $type;
184
-				$env['id_objet'] = $id;
185
-				$env['voir_' . $obj] = str_replace('&', '&', (string) generer_objet_url($id, $obj, '', '', false));
186
-				if (
187
-					isset($desc['field']['id_rubrique'])
188
-					&& $type != 'rubrique'
189
-				) {
190
-					unset($env['id_rubrique']);
191
-					unset($env['voir_rubrique']);
192
-					if (admin_preview($type, $id, $desc)) {
193
-						$env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
194
-					}
195
-				}
196
-			}
197
-		}
198
-	}
199
-
200
-	return $env;
161
+    include_spip('inc/urls');
162
+    $env = [];
163
+
164
+    $trouver_table = charger_fonction('trouver_table', 'base');
165
+    $objets = urls_liste_objets(false);
166
+    $objets = array_diff($objets, ['rubrique']);
167
+    $objets = array_reverse($objets);
168
+    array_unshift($objets, 'rubrique');
169
+    foreach ($objets as $obj) {
170
+        $type = $obj;
171
+        if (
172
+            $type == objet_type($type, false)
173
+            && ($_id_type = id_table_objet($type))
174
+            && isset($GLOBALS['contexte'][$_id_type])
175
+            && ($id = $GLOBALS['contexte'][$_id_type])
176
+            && !is_array($id)
177
+            && ($id = (int) $id)
178
+            && ($desc = $trouver_table(table_objet_sql($type)))
179
+        ) {
180
+            $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . (int) $id);
181
+            if ($id) {
182
+                $env[$_id_type] = $id;
183
+                $env['objet'] = $type;
184
+                $env['id_objet'] = $id;
185
+                $env['voir_' . $obj] = str_replace('&', '&', (string) generer_objet_url($id, $obj, '', '', false));
186
+                if (
187
+                    isset($desc['field']['id_rubrique'])
188
+                    && $type != 'rubrique'
189
+                ) {
190
+                    unset($env['id_rubrique']);
191
+                    unset($env['voir_rubrique']);
192
+                    if (admin_preview($type, $id, $desc)) {
193
+                        $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
194
+                    }
195
+                }
196
+            }
197
+        }
198
+    }
199
+
200
+    return $env;
201 201
 }
202 202
 
203 203
 
@@ -215,30 +215,30 @@  discard block
 block discarded – undo
215 215
  *     - Tableau d'un élément sinon.
216 216
  **/
217 217
 function admin_preview($type, $id, $desc = null) {
218
-	if (defined('_VAR_PREVIEW') && _VAR_PREVIEW) {
219
-		return '';
220
-	}
221
-
222
-	if (!$desc) {
223
-		$trouver_table = charger_fonction('trouver_table', 'base');
224
-		$desc = $trouver_table(table_objet_sql($type));
225
-	}
226
-	if (!$desc || !isset($desc['field']['statut'])) {
227
-		return '';
228
-	}
229
-
230
-	include_spip('inc/autoriser');
231
-	if (!autoriser('previsualiser')) {
232
-		return '';
233
-	}
234
-
235
-	$notpub = sql_in('statut', ['prop', 'prive']);
236
-
237
-	if ($type == 'article' && $GLOBALS['meta']['post_dates'] != 'oui') {
238
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
239
-	}
240
-
241
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
218
+    if (defined('_VAR_PREVIEW') && _VAR_PREVIEW) {
219
+        return '';
220
+    }
221
+
222
+    if (!$desc) {
223
+        $trouver_table = charger_fonction('trouver_table', 'base');
224
+        $desc = $trouver_table(table_objet_sql($type));
225
+    }
226
+    if (!$desc || !isset($desc['field']['statut'])) {
227
+        return '';
228
+    }
229
+
230
+    include_spip('inc/autoriser');
231
+    if (!autoriser('previsualiser')) {
232
+        return '';
233
+    }
234
+
235
+    $notpub = sql_in('statut', ['prop', 'prive']);
236
+
237
+    if ($type == 'article' && $GLOBALS['meta']['post_dates'] != 'oui') {
238
+        $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
239
+    }
240
+
241
+    return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
242 242
 }
243 243
 
244 244
 
@@ -249,25 +249,25 @@  discard block
 block discarded – undo
249 249
  *     Code de langue
250 250
  **/
251 251
 function admin_lang() {
252
-	$alang = '';
253
-	if (!empty($_COOKIE['spip_admin'])) {
254
-		$email_or_login = preg_replace(',^@,', '', (string) $_COOKIE['spip_admin']);
255
-		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
256
-		if (!$alang) {
257
-			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
258
-		}
259
-	}
260
-	if (!$alang) {
261
-		return '';
262
-	}
263
-
264
-	$l = lang_select($alang);
265
-	$alang = $GLOBALS['spip_lang'];
266
-	if ($l) {
267
-		lang_select();
268
-	}
269
-
270
-	return $alang;
252
+    $alang = '';
253
+    if (!empty($_COOKIE['spip_admin'])) {
254
+        $email_or_login = preg_replace(',^@,', '', (string) $_COOKIE['spip_admin']);
255
+        $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
256
+        if (!$alang) {
257
+            $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
258
+        }
259
+    }
260
+    if (!$alang) {
261
+        return '';
262
+    }
263
+
264
+    $l = lang_select($alang);
265
+    $alang = $GLOBALS['spip_lang'];
266
+    if ($l) {
267
+        lang_select();
268
+    }
269
+
270
+    return $alang;
271 271
 }
272 272
 
273 273
 /**
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
  **/
278 278
 function admin_valider() {
279 279
 
280
-	return ((!isset($GLOBALS['xhtml']) || $GLOBALS['xhtml'] !== 'true') ?
281
-		(parametre_url(self(), 'var_mode', 'debug', '&')
282
-			. '&var_mode_affiche=validation') :
283
-		('http://validator.w3.org/check?uri='
284
-			. rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
280
+    return ((!isset($GLOBALS['xhtml']) || $GLOBALS['xhtml'] !== 'true') ?
281
+        (parametre_url(self(), 'var_mode', 'debug', '&')
282
+            . '&var_mode_affiche=validation') :
283
+        ('http://validator.w3.org/check?uri='
284
+            . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
285 285
 }
286 286
 
287 287
 /**
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
  * @return string
291 291
  **/
292 292
 function admin_debug() {
293
-	return (
294
-		(isset($GLOBALS['forcer_debug']) && $GLOBALS['forcer_debug']
295
-		|| isset($GLOBALS['bouton_admin_debug']) && $GLOBALS['bouton_admin_debug']
296
-		|| defined('_VAR_MODE') && _VAR_MODE == 'debug' && isset($_COOKIE['spip_debug']) && $_COOKIE['spip_debug']) && autoriser('debug')
297
-	)
298
-		? parametre_url(self(), 'var_mode', 'debug', '&') : '';
293
+    return (
294
+        (isset($GLOBALS['forcer_debug']) && $GLOBALS['forcer_debug']
295
+        || isset($GLOBALS['bouton_admin_debug']) && $GLOBALS['bouton_admin_debug']
296
+        || defined('_VAR_MODE') && _VAR_MODE == 'debug' && isset($_COOKIE['spip_debug']) && $_COOKIE['spip_debug']) && autoriser('debug')
297
+    )
298
+        ? parametre_url(self(), 'var_mode', 'debug', '&') : '';
299 299
 }
Please login to merge, or discard this patch.
ecrire/inc/csv.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -32,117 +32,117 @@  discard block
 block discarded – undo
32 32
  **/
33 33
 function analyse_csv($t) {
34 34
 
35
-	// Quel est le séparateur ?
36
-	$virg = substr_count($t, ',');
37
-	$pvirg = substr_count($t, ';');
38
-	$tab = substr_count($t, "\t");
39
-	if ($virg > $pvirg) {
40
-		$sep = ',';
41
-		$hs = ',';
42
-	} else {
43
-		$sep = ';';
44
-		$hs = '&#59;';
45
-		$virg = $pvirg;
46
-	}
47
-	// un certain nombre de tab => le séparateur est tab
48
-	if ($tab > $virg / 10) {
49
-		$sep = "\t";
50
-		$hs = "\t";
51
-	}
35
+    // Quel est le séparateur ?
36
+    $virg = substr_count($t, ',');
37
+    $pvirg = substr_count($t, ';');
38
+    $tab = substr_count($t, "\t");
39
+    if ($virg > $pvirg) {
40
+        $sep = ',';
41
+        $hs = ',';
42
+    } else {
43
+        $sep = ';';
44
+        $hs = '&#59;';
45
+        $virg = $pvirg;
46
+    }
47
+    // un certain nombre de tab => le séparateur est tab
48
+    if ($tab > $virg / 10) {
49
+        $sep = "\t";
50
+        $hs = "\t";
51
+    }
52 52
 
53
-	// un separateur suivi de 3 guillemets attention !
54
-	// attention au ; ou , suceptible d'etre confondu avec un separateur
55
-	// on substitue un # et on remplacera a la fin
56
-	$t = preg_replace("/([\n$sep])\"\"\"/", '\\1"&#34#', $t);
57
-	$t = str_replace('""', '&#34#', $t);
58
-	preg_match_all('/"[^"]*"/', $t, $r);
59
-	foreach ($r[0] as $cell) {
60
-		$t = str_replace(
61
-			$cell,
62
-			str_replace(
63
-				$sep,
64
-				$hs,
65
-				str_replace(
66
-					"\n",
67
-					'``**``', // échapper les saut de lignes, on les remettra après.
68
-					substr((string) $cell, 1, -1)
69
-				)
70
-			),
71
-			$t
72
-		);
73
-	}
53
+    // un separateur suivi de 3 guillemets attention !
54
+    // attention au ; ou , suceptible d'etre confondu avec un separateur
55
+    // on substitue un # et on remplacera a la fin
56
+    $t = preg_replace("/([\n$sep])\"\"\"/", '\\1"&#34#', $t);
57
+    $t = str_replace('""', '&#34#', $t);
58
+    preg_match_all('/"[^"]*"/', $t, $r);
59
+    foreach ($r[0] as $cell) {
60
+        $t = str_replace(
61
+            $cell,
62
+            str_replace(
63
+                $sep,
64
+                $hs,
65
+                str_replace(
66
+                    "\n",
67
+                    '``**``', // échapper les saut de lignes, on les remettra après.
68
+                    substr((string) $cell, 1, -1)
69
+                )
70
+            ),
71
+            $t
72
+        );
73
+    }
74 74
 
75
-	$t = preg_replace(
76
-		'/\r?\n/',
77
-		"\n",
78
-		preg_replace('/[\r\n]+/', "\n", $t)
79
-	);
75
+    $t = preg_replace(
76
+        '/\r?\n/',
77
+        "\n",
78
+        preg_replace('/[\r\n]+/', "\n", $t)
79
+    );
80 80
 
81
-	[$entete, $corps] = explode("\n", $t, 2);
82
-	$caption = '';
83
-	// sauter la ligne de tete formee seulement de separateurs
84
-	if (substr_count($entete, $sep) === strlen($entete)) {
85
-		[$entete, $corps] = explode("\n", $corps, 2);
86
-	}
87
-	// si une seule colonne, en faire le titre
88
-	if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) {
89
-		$caption = "\n||" . $l[1] . '|';
90
-		[$entete, $corps] = explode("\n", $corps, 2);
91
-	}
92
-	// si premiere colonne vide, le raccourci doit quand meme produire <th...
93
-	if ($entete[0] == $sep) {
94
-		$entete = ' ' . $entete;
95
-	}
81
+    [$entete, $corps] = explode("\n", $t, 2);
82
+    $caption = '';
83
+    // sauter la ligne de tete formee seulement de separateurs
84
+    if (substr_count($entete, $sep) === strlen($entete)) {
85
+        [$entete, $corps] = explode("\n", $corps, 2);
86
+    }
87
+    // si une seule colonne, en faire le titre
88
+    if (preg_match("/^([^$sep]+)$sep+\$/", $entete, $l)) {
89
+        $caption = "\n||" . $l[1] . '|';
90
+        [$entete, $corps] = explode("\n", $corps, 2);
91
+    }
92
+    // si premiere colonne vide, le raccourci doit quand meme produire <th...
93
+    if ($entete[0] == $sep) {
94
+        $entete = ' ' . $entete;
95
+    }
96 96
 
97
-	$lignes = explode("\n", $corps);
97
+    $lignes = explode("\n", $corps);
98 98
 
99
-	// retrait des lignes vides finales
100
-	while (
101
-		$lignes !== [] && preg_match("/^$sep*$/", $lignes[count($lignes) - 1])
102
-	) {
103
-		unset($lignes[count($lignes) - 1]);
104
-	}
105
-	//  calcul du  nombre de colonne a chaque ligne
106
-	$nbcols = [];
107
-	$max = $mil = substr_count($entete, $sep);
108
-	foreach ($lignes as $k => $v) {
109
-		if ($max !== ($nbcols[$k] = substr_count($v, $sep))) {
110
-			if ($max > $nbcols[$k]) {
111
-				$mil = $nbcols[$k];
112
-			} else {
113
-				$mil = $max;
114
-				$max = $nbcols[$k];
115
-			}
116
-		}
117
-	}
118
-	// Si pas le meme nombre, cadrer au nombre max
119
-	if ($mil !== $max) {
120
-		foreach ($nbcols as $k => $v) {
121
-			if ($v < $max) {
122
-				$lignes[$k] .= str_repeat($sep, $max - $v);
123
-			}
124
-		}
125
-	}
126
-	// et retirer les colonnes integralement vides
127
-	while (true) {
128
-		$nbcols = ($entete[strlen($entete) - 1] === $sep);
129
-		foreach ($lignes as $v) {
130
-			$nbcols &= ($v[strlen($v) - 1] === $sep);
131
-		}
132
-		if (!$nbcols) {
133
-			break;
134
-		}
135
-		$entete = substr($entete, 0, -1);
136
-		foreach ($lignes as $k => $v) {
137
-			$lignes[$k] = substr($v, 0, -1);
138
-		}
139
-	}
99
+    // retrait des lignes vides finales
100
+    while (
101
+        $lignes !== [] && preg_match("/^$sep*$/", $lignes[count($lignes) - 1])
102
+    ) {
103
+        unset($lignes[count($lignes) - 1]);
104
+    }
105
+    //  calcul du  nombre de colonne a chaque ligne
106
+    $nbcols = [];
107
+    $max = $mil = substr_count($entete, $sep);
108
+    foreach ($lignes as $k => $v) {
109
+        if ($max !== ($nbcols[$k] = substr_count($v, $sep))) {
110
+            if ($max > $nbcols[$k]) {
111
+                $mil = $nbcols[$k];
112
+            } else {
113
+                $mil = $max;
114
+                $max = $nbcols[$k];
115
+            }
116
+        }
117
+    }
118
+    // Si pas le meme nombre, cadrer au nombre max
119
+    if ($mil !== $max) {
120
+        foreach ($nbcols as $k => $v) {
121
+            if ($v < $max) {
122
+                $lignes[$k] .= str_repeat($sep, $max - $v);
123
+            }
124
+        }
125
+    }
126
+    // et retirer les colonnes integralement vides
127
+    while (true) {
128
+        $nbcols = ($entete[strlen($entete) - 1] === $sep);
129
+        foreach ($lignes as $v) {
130
+            $nbcols &= ($v[strlen($v) - 1] === $sep);
131
+        }
132
+        if (!$nbcols) {
133
+            break;
134
+        }
135
+        $entete = substr($entete, 0, -1);
136
+        foreach ($lignes as $k => $v) {
137
+            $lignes[$k] = substr($v, 0, -1);
138
+        }
139
+    }
140 140
 
141
-	foreach ($lignes as &$l) {
142
-		$l = str_replace('&#34#', '"', $l);
143
-		$l = str_replace('``**``', "\n", $l);
144
-		$l = explode($sep, $l);
145
-	}
141
+    foreach ($lignes as &$l) {
142
+        $l = str_replace('&#34#', '"', $l);
143
+        $l = str_replace('``**``', "\n", $l);
144
+        $l = explode($sep, $l);
145
+    }
146 146
 
147
-	return [explode($sep, $entete), $lignes, $caption];
147
+    return [explode($sep, $entete), $lignes, $caption];
148 148
 }
Please login to merge, or discard this patch.
ecrire/inc/drapeau_edition.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  * @package SPIP\Core\Drapeaux\Edition
30 30
  **/
31 31
 if (!defined('_ECRIRE_INC_VERSION')) {
32
-	return;
32
+    return;
33 33
 }
34 34
 
35 35
 
@@ -44,46 +44,46 @@  discard block
 block discarded – undo
44 44
  *     `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()`
45 45
  **/
46 46
 function lire_tableau_edition() {
47
-	$edition = @unserialize($GLOBALS['meta']['drapeau_edition']);
48
-	if (!$edition) {
49
-		return [];
50
-	}
51
-	$changed = false;
47
+    $edition = @unserialize($GLOBALS['meta']['drapeau_edition']);
48
+    if (!$edition) {
49
+        return [];
50
+    }
51
+    $changed = false;
52 52
 
53
-	$bon_pour_le_service = time() - 3600;
54
-	// parcourir le tableau et virer les vieux
55
-	foreach ($edition as $objet => $data) {
56
-		if (!is_array($data)) {
57
-			unset($edition[$objet]);
58
-		} // vieille version
59
-		else {
60
-			foreach ($data as $id => $tab) {
61
-				if (!is_array($tab)) {
62
-					unset($edition[$objet][$tab]);
63
-				} // vieille version
64
-				else {
65
-					foreach ($tab as $n => $duo) {
66
-						if (current($duo) < $bon_pour_le_service) {
67
-							unset($edition[$objet][$id][$n]);
68
-							$changed = true;
69
-						}
70
-					}
71
-				}
72
-				if (!$edition[$objet][$id]) {
73
-					unset($edition[$objet][$id]);
74
-				}
75
-			}
76
-		}
77
-		if (!$edition[$objet]) {
78
-			unset($edition[$objet]);
79
-		}
80
-	}
53
+    $bon_pour_le_service = time() - 3600;
54
+    // parcourir le tableau et virer les vieux
55
+    foreach ($edition as $objet => $data) {
56
+        if (!is_array($data)) {
57
+            unset($edition[$objet]);
58
+        } // vieille version
59
+        else {
60
+            foreach ($data as $id => $tab) {
61
+                if (!is_array($tab)) {
62
+                    unset($edition[$objet][$tab]);
63
+                } // vieille version
64
+                else {
65
+                    foreach ($tab as $n => $duo) {
66
+                        if (current($duo) < $bon_pour_le_service) {
67
+                            unset($edition[$objet][$id][$n]);
68
+                            $changed = true;
69
+                        }
70
+                    }
71
+                }
72
+                if (!$edition[$objet][$id]) {
73
+                    unset($edition[$objet][$id]);
74
+                }
75
+            }
76
+        }
77
+        if (!$edition[$objet]) {
78
+            unset($edition[$objet]);
79
+        }
80
+    }
81 81
 
82
-	if ($changed) {
83
-		ecrire_tableau_edition($edition);
84
-	}
82
+    if ($changed) {
83
+        ecrire_tableau_edition($edition);
84
+    }
85 85
 
86
-	return $edition;
86
+    return $edition;
87 87
 }
88 88
 
89 89
 /**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
  *     `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()`
97 97
  **/
98 98
 function ecrire_tableau_edition($edition) {
99
-	ecrire_meta('drapeau_edition', serialize($edition));
99
+    ecrire_meta('drapeau_edition', serialize($edition));
100 100
 }
101 101
 
102 102
 /**
@@ -116,22 +116,22 @@  discard block
 block discarded – undo
116 116
  *     Type d'objet édité
117 117
  */
118 118
 function signale_edition($id, $auteur, $type = 'article') {
119
-	include_spip('base/objets');
120
-	include_spip('inc/filtres');
121
-	if (objet_info($type, 'editable') !== 'oui') {
122
-		return;
123
-	}
119
+    include_spip('base/objets');
120
+    include_spip('inc/filtres');
121
+    if (objet_info($type, 'editable') !== 'oui') {
122
+        return;
123
+    }
124 124
 
125
-	$edition = lire_tableau_edition();
125
+    $edition = lire_tableau_edition();
126 126
 
127
-	$nom = $auteur['nom'] ?? $GLOBALS['ip'];
128
-	$id_a = $auteur['id_auteur'] ?? $GLOBALS['ip'];
127
+    $nom = $auteur['nom'] ?? $GLOBALS['ip'];
128
+    $id_a = $auteur['id_auteur'] ?? $GLOBALS['ip'];
129 129
 
130
-	if (!isset($edition[$type][$id]) || !is_array($edition[$type][$id])) {
131
-		$edition[$type][$id] = [];
132
-	}
133
-	$edition[$type][$id][$id_a][$nom] = time();
134
-	ecrire_tableau_edition($edition);
130
+    if (!isset($edition[$type][$id]) || !is_array($edition[$type][$id])) {
131
+        $edition[$type][$id] = [];
132
+    }
133
+    $edition[$type][$id][$id_a][$nom] = time();
134
+    ecrire_tableau_edition($edition);
135 135
 }
136 136
 
137 137
 /**
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function qui_edite($id, $type = 'article') {
150 150
 
151
-	$edition = lire_tableau_edition();
151
+    $edition = lire_tableau_edition();
152 152
 
153
-	return empty($edition[$type][$id]) ? [] : $edition[$type][$id];
153
+    return empty($edition[$type][$id]) ? [] : $edition[$type][$id];
154 154
 }
155 155
 
156 156
 /**
@@ -164,23 +164,23 @@  discard block
 block discarded – undo
164 164
  *     Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]`
165 165
  */
166 166
 function mention_qui_edite($id, $type = 'article'): array {
167
-	$modif = qui_edite($id, $type);
168
-	unset($modif[$GLOBALS['visiteur_session']['id_auteur']]);
167
+    $modif = qui_edite($id, $type);
168
+    unset($modif[$GLOBALS['visiteur_session']['id_auteur']]);
169 169
 
170
-	if ($modif) {
171
-		$quand = 0;
172
-		foreach ($modif as $duo) {
173
-			$auteurs[] = typo(key($duo));
174
-			$quand = max($quand, current($duo));
175
-		}
170
+    if ($modif) {
171
+        $quand = 0;
172
+        foreach ($modif as $duo) {
173
+            $auteurs[] = typo(key($duo));
174
+            $quand = max($quand, current($duo));
175
+        }
176 176
 
177
-		// format lie a la chaine de langue 'avis_article_modifie'
178
-		return [
179
-			'nom_auteur_modif' => implode(' | ', $auteurs),
180
-			'date_diff' => ceil((time() - $quand) / 60)
181
-		];
182
-	}
183
-	return [];
177
+        // format lie a la chaine de langue 'avis_article_modifie'
178
+        return [
179
+            'nom_auteur_modif' => implode(' | ', $auteurs),
180
+            'date_diff' => ceil((time() - $quand) / 60)
181
+        ];
182
+    }
183
+    return [];
184 184
 }
185 185
 
186 186
 /**
@@ -194,25 +194,25 @@  discard block
 block discarded – undo
194 194
  *     Liste de tableaux `['objet' => x, 'id_objet' => n]`
195 195
  */
196 196
 function liste_drapeau_edition($id_auteur) {
197
-	$edition = lire_tableau_edition();
198
-	$objets_ouverts = [];
197
+    $edition = lire_tableau_edition();
198
+    $objets_ouverts = [];
199 199
 
200
-	foreach ($edition as $objet => $data) {
201
-		foreach ($data as $id => $auteurs) {
202
-			if (
203
-				isset($auteurs[$id_auteur])
204
-				&& is_array($auteurs[$id_auteur])
205
-				&& array_pop($auteurs[$id_auteur]) > time() - 3600
206
-			) {
207
-				$objets_ouverts[] = [
208
-					'objet' => $objet,
209
-					'id_objet' => $id,
210
-				];
211
-			}
212
-		}
213
-	}
200
+    foreach ($edition as $objet => $data) {
201
+        foreach ($data as $id => $auteurs) {
202
+            if (
203
+                isset($auteurs[$id_auteur])
204
+                && is_array($auteurs[$id_auteur])
205
+                && array_pop($auteurs[$id_auteur]) > time() - 3600
206
+            ) {
207
+                $objets_ouverts[] = [
208
+                    'objet' => $objet,
209
+                    'id_objet' => $id,
210
+                ];
211
+            }
212
+        }
213
+    }
214 214
 
215
-	return $objets_ouverts;
215
+    return $objets_ouverts;
216 216
 }
217 217
 
218 218
 /**
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
  * @return void
226 226
  */
227 227
 function debloquer_tous($id_auteur) {
228
-	$edition = lire_tableau_edition();
229
-	foreach ($edition as $objet => $data) {
230
-		foreach ($data as $id => $auteurs) {
231
-			if (isset($auteurs[$id_auteur])) {
232
-				unset($edition[$objet][$id][$id_auteur]);
233
-				ecrire_tableau_edition($edition);
234
-			}
235
-		}
236
-	}
228
+    $edition = lire_tableau_edition();
229
+    foreach ($edition as $objet => $data) {
230
+        foreach ($data as $id => $auteurs) {
231
+            if (isset($auteurs[$id_auteur])) {
232
+                unset($edition[$objet][$id][$id_auteur]);
233
+                ecrire_tableau_edition($edition);
234
+            }
235
+        }
236
+    }
237 237
 }
238 238
 
239 239
 /**
@@ -251,19 +251,19 @@  discard block
 block discarded – undo
251 251
  * @return void
252 252
  */
253 253
 function debloquer_edition($id_auteur, $id_objet, $type = 'article') {
254
-	$edition = lire_tableau_edition();
254
+    $edition = lire_tableau_edition();
255 255
 
256
-	foreach ($edition as $objet => $data) {
257
-		if ($objet == $type) {
258
-			foreach ($data as $id => $auteurs) {
259
-				if (
260
-					$id == $id_objet
261
-					&& isset($auteurs[$id_auteur])
262
-				) {
263
-					unset($edition[$objet][$id][$id_auteur]);
264
-					ecrire_tableau_edition($edition);
265
-				}
266
-			}
267
-		}
268
-	}
256
+    foreach ($edition as $objet => $data) {
257
+        if ($objet == $type) {
258
+            foreach ($data as $id => $auteurs) {
259
+                if (
260
+                    $id == $id_objet
261
+                    && isset($auteurs[$id_auteur])
262
+                ) {
263
+                    unset($edition[$objet][$id][$id_auteur]);
264
+                    ecrire_tableau_edition($edition);
265
+                }
266
+            }
267
+        }
268
+    }
269 269
 }
Please login to merge, or discard this patch.
ecrire/inc/definir_menus_favoris.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@
 block discarded – undo
19 19
  * Retourne la liste des menus favoris par défaut ainsi que leur rang
20 20
  */
21 21
 function inc_definir_menus_favoris_dist() {
22
-	return [
22
+    return [
23 23
 
24
-		// Menu Édition,
25
-		'auteurs' => 1,
26
-		'rubriques' => 2,
27
-		'articles' => 3,
24
+        // Menu Édition,
25
+        'auteurs' => 1,
26
+        'rubriques' => 2,
27
+        'articles' => 3,
28 28
 
29
-		// Menu Maintenance
30
-		'admin_vider' => 1,
29
+        // Menu Maintenance
30
+        'admin_vider' => 1,
31 31
 
32
-		// Menu Configurations
33
-		'configurer_identite' => 1,
34
-		'admin_plugin' => 2,
32
+        // Menu Configurations
33
+        'configurer_identite' => 1,
34
+        'admin_plugin' => 2,
35 35
 
36
-	];
36
+    ];
37 37
 }
Please login to merge, or discard this patch.
ecrire/inc/precharger_objet.php 1 patch
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/autoriser'); // necessaire si appel de l'espace public
@@ -44,66 +44,66 @@  discard block
 block discarded – undo
44 44
  **/
45 45
 function precharger_objet($type, $id_objet, $id_rubrique = 0, $lier_trad = 0, $champ_titre = 'titre') {
46 46
 
47
-	$row = [];
48
-	$table = table_objet_sql($type);
49
-	$_id_objet = id_table_objet($table);
50
-
51
-	// si l'objet existe deja, on retourne simplement ses valeurs
52
-	if (is_numeric($id_objet)) {
53
-		return sql_fetsel('*', $table, "$_id_objet=" . (int) $id_objet);
54
-	}
55
-
56
-	// ici, on demande une creation.
57
-	// on prerempli certains elements : les champs si traduction,
58
-	// les id_rubrique et id_secteur si l'objet a ces champs
59
-	$desc = lister_tables_objets_sql($table);
60
-	# il faudrait calculer $champ_titre ici
61
-	$is_rubrique = isset($desc['field']['id_rubrique']);
62
-	$is_secteur = isset($desc['field']['id_secteur']);
63
-
64
-	// si demande de traduction
65
-	// on recupere les valeurs de la traduction
66
-	if ($lier_trad) {
67
-		if ($select = charger_fonction('precharger_traduction_' . $type, 'inc', true)) {
68
-			$row = $select($id_objet, $id_rubrique, $lier_trad);
69
-		} else {
70
-			$row = precharger_traduction_objet($type, $id_objet, $id_rubrique, $lier_trad, $champ_titre);
71
-		}
72
-	} else {
73
-		$row[$champ_titre] = '';
74
-		if ($is_rubrique) {
75
-			$row['id_rubrique'] = $id_rubrique;
76
-		}
77
-	}
78
-
79
-	// calcul de la rubrique
80
-	# note : comment faire pour des traductions sur l'objet rubriques ?
81
-	// appel du script a la racine, faut choisir
82
-	// admin restreint ==> sa premiere rubrique
83
-	// autre ==> la derniere rubrique cree
84
-	if ($is_rubrique && !$row['id_rubrique']) {
85
-		if ($GLOBALS['connect_id_rubrique']) {
86
-			$row['id_rubrique'] = $id_rubrique = current($GLOBALS['connect_id_rubrique']);
87
-		} else {
88
-			$row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', 1);
89
-			$row['id_rubrique'] = $id_rubrique = $row_rub['id_rubrique'];
90
-		}
91
-		if (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique'])) {
92
-			// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
93
-			$res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
94
-			while (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique']) && $row_rub = sql_fetch($res)) {
95
-				$row['id_rubrique'] = $row_rub['id_rubrique'];
96
-			}
97
-		}
98
-	}
99
-
100
-	// recuperer le secteur, pour affecter les bons champs extras
101
-	if ($id_rubrique && $is_secteur && !$row['id_secteur']) {
102
-		$row_rub = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . sql_quote($id_rubrique));
103
-		$row['id_secteur'] = $row_rub;
104
-	}
105
-
106
-	return $row;
47
+    $row = [];
48
+    $table = table_objet_sql($type);
49
+    $_id_objet = id_table_objet($table);
50
+
51
+    // si l'objet existe deja, on retourne simplement ses valeurs
52
+    if (is_numeric($id_objet)) {
53
+        return sql_fetsel('*', $table, "$_id_objet=" . (int) $id_objet);
54
+    }
55
+
56
+    // ici, on demande une creation.
57
+    // on prerempli certains elements : les champs si traduction,
58
+    // les id_rubrique et id_secteur si l'objet a ces champs
59
+    $desc = lister_tables_objets_sql($table);
60
+    # il faudrait calculer $champ_titre ici
61
+    $is_rubrique = isset($desc['field']['id_rubrique']);
62
+    $is_secteur = isset($desc['field']['id_secteur']);
63
+
64
+    // si demande de traduction
65
+    // on recupere les valeurs de la traduction
66
+    if ($lier_trad) {
67
+        if ($select = charger_fonction('precharger_traduction_' . $type, 'inc', true)) {
68
+            $row = $select($id_objet, $id_rubrique, $lier_trad);
69
+        } else {
70
+            $row = precharger_traduction_objet($type, $id_objet, $id_rubrique, $lier_trad, $champ_titre);
71
+        }
72
+    } else {
73
+        $row[$champ_titre] = '';
74
+        if ($is_rubrique) {
75
+            $row['id_rubrique'] = $id_rubrique;
76
+        }
77
+    }
78
+
79
+    // calcul de la rubrique
80
+    # note : comment faire pour des traductions sur l'objet rubriques ?
81
+    // appel du script a la racine, faut choisir
82
+    // admin restreint ==> sa premiere rubrique
83
+    // autre ==> la derniere rubrique cree
84
+    if ($is_rubrique && !$row['id_rubrique']) {
85
+        if ($GLOBALS['connect_id_rubrique']) {
86
+            $row['id_rubrique'] = $id_rubrique = current($GLOBALS['connect_id_rubrique']);
87
+        } else {
88
+            $row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', 1);
89
+            $row['id_rubrique'] = $id_rubrique = $row_rub['id_rubrique'];
90
+        }
91
+        if (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique'])) {
92
+            // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
93
+            $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
94
+            while (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique']) && $row_rub = sql_fetch($res)) {
95
+                $row['id_rubrique'] = $row_rub['id_rubrique'];
96
+            }
97
+        }
98
+    }
99
+
100
+    // recuperer le secteur, pour affecter les bons champs extras
101
+    if ($id_rubrique && $is_secteur && !$row['id_secteur']) {
102
+        $row_rub = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . sql_quote($id_rubrique));
103
+        $row['id_secteur'] = $row_rub;
104
+    }
105
+
106
+    return $row;
107 107
 }
108 108
 
109 109
 
@@ -125,78 +125,78 @@  discard block
 block discarded – undo
125 125
  *     Couples clés / valeurs des champs du formulaire à charger
126 126
  **/
127 127
 function precharger_traduction_objet($type, $id_objet, $id_rubrique = 0, $lier_trad = 0, $champ_titre = 'titre') {
128
-	$table = table_objet_sql($type);
129
-	$_id_objet = id_table_objet($table);
130
-
131
-	// Recuperer les donnees de l'objet original
132
-	$row = sql_fetsel('*', $table, "$_id_objet=" . (int) $lier_trad);
133
-	if ($row) {
134
-		include_spip('inc/filtres');
135
-		$row[$champ_titre] = filtrer_entites(objet_T($type, 'info_nouvelle_traduction')) . ' ' . $row[$champ_titre];
136
-	} else {
137
-		$row = [];
138
-	}
139
-
140
-	// on met l'objet dans une rubrique si l'objet le peut
141
-	$desc = lister_tables_objets_sql($table);
142
-	$is_rubrique = isset($desc['field']['id_rubrique']);
143
-
144
-	if ($is_rubrique) {
145
-		$langues_dispo = explode(',', (string) $GLOBALS['meta']['langues_multilingue']);
146
-		// si le redacteur utilise une autre langue que celle de la source, on suppose que c'est pour traduire dans sa langue
147
-		if (in_array($GLOBALS['spip_lang'], $langues_dispo) && $GLOBALS['spip_lang'] !== $row['lang']) {
148
-			$row['lang'] = $GLOBALS['spip_lang'];
149
-		}
150
-		// sinon si il y a seulement 2 langues dispos, on bascule sur l'"autre"
151
-		elseif (count($langues_dispo) == 2) {
152
-			$autre_langue = array_diff($langues_dispo, [$row['lang']]);
153
-			if (count($autre_langue) == 1) {
154
-				$row['lang'] = reset($autre_langue);
155
-			}
156
-		}
157
-		else {
158
-			$row['lang'] = 'en';
159
-		}
160
-
161
-		if ($id_rubrique) {
162
-			$row['id_rubrique'] = $id_rubrique;
163
-
164
-			return $row;
165
-		}
166
-		$id_rubrique = $row['id_rubrique'];
167
-
168
-
169
-		// Regler la langue, si possible, sur celle du redacteur
170
-		// Cela implique souvent de choisir une rubrique ou un secteur
171
-		if (in_array($GLOBALS['spip_lang'], $langues_dispo)) {
172
-			// Si le menu de langues est autorise sur l'objet,
173
-			// on peut changer la langue quelle que soit la rubrique
174
-			// donc on reste dans la meme rubrique
175
-			if (in_array($table, explode(',', (string) $GLOBALS['meta']['multi_objets']))) {
176
-				$row['id_rubrique'] = $row['id_rubrique']; # explicite :-)
177
-
178
-				// Sinon, chercher la rubrique la plus adaptee pour
179
-				// accueillir l'objet dans la langue du traducteur
180
-			} elseif ($is_rubrique && $GLOBALS['meta']['multi_rubriques'] == 'oui') {
181
-				if ($GLOBALS['meta']['multi_secteurs'] == 'oui') {
182
-					$id_parent = 0;
183
-				} else {
184
-					// on cherche une rubrique soeur dans la bonne langue
185
-					$row_rub = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
186
-					$id_parent = $row_rub['id_parent'];
187
-				}
188
-
189
-				$row_rub = sql_fetsel(
190
-					'id_rubrique',
191
-					'spip_rubriques',
192
-					"lang='" . $GLOBALS['spip_lang'] . "' AND id_parent=" . (int) $id_parent
193
-				);
194
-				if ($row_rub) {
195
-					$row['id_rubrique'] = $row_rub['id_rubrique'];
196
-				}
197
-			}
198
-		}
199
-	}
200
-
201
-	return $row;
128
+    $table = table_objet_sql($type);
129
+    $_id_objet = id_table_objet($table);
130
+
131
+    // Recuperer les donnees de l'objet original
132
+    $row = sql_fetsel('*', $table, "$_id_objet=" . (int) $lier_trad);
133
+    if ($row) {
134
+        include_spip('inc/filtres');
135
+        $row[$champ_titre] = filtrer_entites(objet_T($type, 'info_nouvelle_traduction')) . ' ' . $row[$champ_titre];
136
+    } else {
137
+        $row = [];
138
+    }
139
+
140
+    // on met l'objet dans une rubrique si l'objet le peut
141
+    $desc = lister_tables_objets_sql($table);
142
+    $is_rubrique = isset($desc['field']['id_rubrique']);
143
+
144
+    if ($is_rubrique) {
145
+        $langues_dispo = explode(',', (string) $GLOBALS['meta']['langues_multilingue']);
146
+        // si le redacteur utilise une autre langue que celle de la source, on suppose que c'est pour traduire dans sa langue
147
+        if (in_array($GLOBALS['spip_lang'], $langues_dispo) && $GLOBALS['spip_lang'] !== $row['lang']) {
148
+            $row['lang'] = $GLOBALS['spip_lang'];
149
+        }
150
+        // sinon si il y a seulement 2 langues dispos, on bascule sur l'"autre"
151
+        elseif (count($langues_dispo) == 2) {
152
+            $autre_langue = array_diff($langues_dispo, [$row['lang']]);
153
+            if (count($autre_langue) == 1) {
154
+                $row['lang'] = reset($autre_langue);
155
+            }
156
+        }
157
+        else {
158
+            $row['lang'] = 'en';
159
+        }
160
+
161
+        if ($id_rubrique) {
162
+            $row['id_rubrique'] = $id_rubrique;
163
+
164
+            return $row;
165
+        }
166
+        $id_rubrique = $row['id_rubrique'];
167
+
168
+
169
+        // Regler la langue, si possible, sur celle du redacteur
170
+        // Cela implique souvent de choisir une rubrique ou un secteur
171
+        if (in_array($GLOBALS['spip_lang'], $langues_dispo)) {
172
+            // Si le menu de langues est autorise sur l'objet,
173
+            // on peut changer la langue quelle que soit la rubrique
174
+            // donc on reste dans la meme rubrique
175
+            if (in_array($table, explode(',', (string) $GLOBALS['meta']['multi_objets']))) {
176
+                $row['id_rubrique'] = $row['id_rubrique']; # explicite :-)
177
+
178
+                // Sinon, chercher la rubrique la plus adaptee pour
179
+                // accueillir l'objet dans la langue du traducteur
180
+            } elseif ($is_rubrique && $GLOBALS['meta']['multi_rubriques'] == 'oui') {
181
+                if ($GLOBALS['meta']['multi_secteurs'] == 'oui') {
182
+                    $id_parent = 0;
183
+                } else {
184
+                    // on cherche une rubrique soeur dans la bonne langue
185
+                    $row_rub = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
186
+                    $id_parent = $row_rub['id_parent'];
187
+                }
188
+
189
+                $row_rub = sql_fetsel(
190
+                    'id_rubrique',
191
+                    'spip_rubriques',
192
+                    "lang='" . $GLOBALS['spip_lang'] . "' AND id_parent=" . (int) $id_parent
193
+                );
194
+                if ($row_rub) {
195
+                    $row['id_rubrique'] = $row_rub['id_rubrique'];
196
+                }
197
+            }
198
+        }
199
+    }
200
+
201
+    return $row;
202 202
 }
Please login to merge, or discard this patch.
ecrire/inc/xml.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
  *     - false si l'arbre xml ne peut être créé ou est vide
47 47
  **/
48 48
 function spip_xml_load($fichier, $strict = true, $clean = true, $taille_max = 1_048_576, $datas = '', $profondeur = -1) {
49
-	$contenu = '';
50
-	if (tester_url_absolue($fichier)) {
51
-		include_spip('inc/distant');
52
-		$contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]);
53
-		$contenu = $contenu['page'] ?? '';
54
-	} else {
55
-		lire_fichier($fichier, $contenu);
56
-	}
57
-	$arbre = [];
58
-	if ($contenu) {
59
-		$arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur);
60
-	}
49
+    $contenu = '';
50
+    if (tester_url_absolue($fichier)) {
51
+        include_spip('inc/distant');
52
+        $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]);
53
+        $contenu = $contenu['page'] ?? '';
54
+    } else {
55
+        lire_fichier($fichier, $contenu);
56
+    }
57
+    $arbre = [];
58
+    if ($contenu) {
59
+        $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur);
60
+    }
61 61
 
62
-	return count($arbre) ? $arbre : false;
62
+    return count($arbre) ? $arbre : false;
63 63
 }
64 64
 
65 65
 if (!defined('_SPIP_XML_TAG_SPLIT')) {
66
-	define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS');
66
+    define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS');
67 67
 }
68 68
 
69 69
 /**
@@ -82,150 +82,150 @@  discard block
 block discarded – undo
82 82
  *     - false si l'arbre xml ne peut être créé ou est vide
83 83
  **/
84 84
 function spip_xml_parse(&$texte, $strict = true, $clean = true, $profondeur = -1) {
85
-	$out = [];
86
-	// enlever les commentaires
87
-	$charset = 'AUTO';
88
-	if ($clean) {
89
-		if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) {
90
-			$charset = $regs[2];
91
-		}
92
-		$texte = preg_replace(',<!--(.*?)-->,is', '', $texte);
93
-		$texte = preg_replace(',<\?(.*?)\?>,is', '', $texte);
94
-		include_spip('inc/charsets');
95
-		$clean = $charset;
96
-		//$texte = importer_charset($texte,$charset);
97
-	}
98
-	if (is_string($clean)) {
99
-		$charset = $clean;
100
-	}
101
-	$txt = $texte;
85
+    $out = [];
86
+    // enlever les commentaires
87
+    $charset = 'AUTO';
88
+    if ($clean) {
89
+        if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) {
90
+            $charset = $regs[2];
91
+        }
92
+        $texte = preg_replace(',<!--(.*?)-->,is', '', $texte);
93
+        $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte);
94
+        include_spip('inc/charsets');
95
+        $clean = $charset;
96
+        //$texte = importer_charset($texte,$charset);
97
+    }
98
+    if (is_string($clean)) {
99
+        $charset = $clean;
100
+    }
101
+    $txt = $texte;
102 102
 
103
-	// tant qu'il y a des tags
104
-	$chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
105
-	while ((is_countable($chars) ? count($chars) : 0) >= 2) {
106
-		// tag ouvrant
107
-		//$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE);
103
+    // tant qu'il y a des tags
104
+    $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
105
+    while ((is_countable($chars) ? count($chars) : 0) >= 2) {
106
+        // tag ouvrant
107
+        //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE);
108 108
 
109
-		// $before doit etre vide ou des espaces uniquements!
110
-		$before = trim($chars[0]);
109
+        // $before doit etre vide ou des espaces uniquements!
110
+        $before = trim($chars[0]);
111 111
 
112
-		if (strlen($before) > 0) {
113
-			return importer_charset($texte, $charset);
114
-		}//$texte; // before non vide, donc on est dans du texte
112
+        if (strlen($before) > 0) {
113
+            return importer_charset($texte, $charset);
114
+        }//$texte; // before non vide, donc on est dans du texte
115 115
 
116
-		$tag = rtrim($chars[1]);
117
-		$txt = $chars[2];
116
+        $tag = rtrim($chars[1]);
117
+        $txt = $chars[2];
118 118
 
119
-		if (str_starts_with($tag, '![CDATA[')) {
120
-			return importer_charset($texte, $charset);
121
-		}//$texte;
122
-		if (str_ends_with($tag, '/')) { // self closing tag
123
-			$tag = rtrim(substr($tag, 0, strlen($tag) - 1));
124
-			$out[$tag][] = '';
125
-		} else {
126
-			$closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag));
127
-			$closing_tag = reset($closing_tag);
128
-			// tag fermant
129
-			$ncclos = strlen("</$closing_tag>");
130
-			$p = strpos($txt, (string) "</$closing_tag>");
131
-			if ($p !== false && strpos($txt, '<') < $p) {
132
-				$nclose = 0;
133
-				$nopen = 0;
134
-				$d = 0;
135
-				while (
136
-					$p !== false
137
-					&& ($morceau = substr($txt, $d, $p - $d))
138
-					&& ($nopen += preg_match_all(
139
-						'{<' . preg_quote((string) $closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is',
140
-						$morceau,
141
-						$matches,
142
-						PREG_SET_ORDER
143
-					)) > $nclose
144
-				) {
145
-					$nclose++;
146
-					$d = $p + $ncclos;
147
-					$p = strpos($txt, (string) "</$closing_tag>", $d);
148
-				}
149
-			}
150
-			if ($p === false) {
151
-				if ($strict) {
152
-					$out[$tag][] = "erreur : tag fermant $tag manquant::$txt";
119
+        if (str_starts_with($tag, '![CDATA[')) {
120
+            return importer_charset($texte, $charset);
121
+        }//$texte;
122
+        if (str_ends_with($tag, '/')) { // self closing tag
123
+            $tag = rtrim(substr($tag, 0, strlen($tag) - 1));
124
+            $out[$tag][] = '';
125
+        } else {
126
+            $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag));
127
+            $closing_tag = reset($closing_tag);
128
+            // tag fermant
129
+            $ncclos = strlen("</$closing_tag>");
130
+            $p = strpos($txt, (string) "</$closing_tag>");
131
+            if ($p !== false && strpos($txt, '<') < $p) {
132
+                $nclose = 0;
133
+                $nopen = 0;
134
+                $d = 0;
135
+                while (
136
+                    $p !== false
137
+                    && ($morceau = substr($txt, $d, $p - $d))
138
+                    && ($nopen += preg_match_all(
139
+                        '{<' . preg_quote((string) $closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is',
140
+                        $morceau,
141
+                        $matches,
142
+                        PREG_SET_ORDER
143
+                    )) > $nclose
144
+                ) {
145
+                    $nclose++;
146
+                    $d = $p + $ncclos;
147
+                    $p = strpos($txt, (string) "</$closing_tag>", $d);
148
+                }
149
+            }
150
+            if ($p === false) {
151
+                if ($strict) {
152
+                    $out[$tag][] = "erreur : tag fermant $tag manquant::$txt";
153 153
 
154
-					return $out;
155
-				} else {
156
-					return importer_charset($texte, $charset);
157
-				}//$texte // un tag qui constitue du texte a reporter dans $before
158
-			}
159
-			$content = substr($txt, 0, $p);
160
-			$txt = substr($txt, $p + $ncclos);
161
-			if ($profondeur == 0 || !str_contains($content, '<')) { // eviter une recursion si pas utile
162
-			$out[$tag][] = importer_charset($content, $charset);
163
-			}//$content;
164
-			else {
165
-				$out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1);
166
-			}
167
-		}
168
-		$chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
169
-	}
170
-	if (count($out) && (strlen(trim($txt)) == 0)) {
171
-		return $out;
172
-	} else {
173
-		return importer_charset($texte, $charset);
174
-	}//$texte;
154
+                    return $out;
155
+                } else {
156
+                    return importer_charset($texte, $charset);
157
+                }//$texte // un tag qui constitue du texte a reporter dans $before
158
+            }
159
+            $content = substr($txt, 0, $p);
160
+            $txt = substr($txt, $p + $ncclos);
161
+            if ($profondeur == 0 || !str_contains($content, '<')) { // eviter une recursion si pas utile
162
+            $out[$tag][] = importer_charset($content, $charset);
163
+            }//$content;
164
+            else {
165
+                $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1);
166
+            }
167
+        }
168
+        $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
169
+    }
170
+    if (count($out) && (strlen(trim($txt)) == 0)) {
171
+        return $out;
172
+    } else {
173
+        return importer_charset($texte, $charset);
174
+    }//$texte;
175 175
 }
176 176
 
177 177
 function spip_xml_aplatit($arbre, $separateur = ' ') {
178
-	$s = '';
179
-	if (is_array($arbre)) {
180
-		foreach ($arbre as $tag => $feuille) {
181
-			if (is_array($feuille)) {
182
-				if ($tag !== (int) $tag) {
183
-					$f = spip_xml_aplatit($feuille, $separateur);
184
-					if (strlen((string) $f)) {
185
-						$tagf = explode(' ', $tag);
186
-						$tagf = $tagf[0];
187
-						$s .= "<$tag>$f</$tagf>";
188
-					} else {
189
-						$s .= "<$tag />";
190
-					}
191
-				} else {
192
-					$s .= spip_xml_aplatit($feuille);
193
-				}
194
-				$s .= $separateur;
195
-			} else {
196
-				$s .= "$feuille$separateur";
197
-			}
198
-		}
199
-	}
178
+    $s = '';
179
+    if (is_array($arbre)) {
180
+        foreach ($arbre as $tag => $feuille) {
181
+            if (is_array($feuille)) {
182
+                if ($tag !== (int) $tag) {
183
+                    $f = spip_xml_aplatit($feuille, $separateur);
184
+                    if (strlen((string) $f)) {
185
+                        $tagf = explode(' ', $tag);
186
+                        $tagf = $tagf[0];
187
+                        $s .= "<$tag>$f</$tagf>";
188
+                    } else {
189
+                        $s .= "<$tag />";
190
+                    }
191
+                } else {
192
+                    $s .= spip_xml_aplatit($feuille);
193
+                }
194
+                $s .= $separateur;
195
+            } else {
196
+                $s .= "$feuille$separateur";
197
+            }
198
+        }
199
+    }
200 200
 
201
-	return strlen((string) $separateur) ? substr($s, 0, -strlen((string) $separateur)) : $s;
201
+    return strlen((string) $separateur) ? substr($s, 0, -strlen((string) $separateur)) : $s;
202 202
 }
203 203
 
204 204
 function spip_xml_tagname($tag) {
205
-	if (preg_match(',^([a-z][\w:]*),i', (string) $tag, $reg)) {
206
-		return $reg[1];
207
-	}
205
+    if (preg_match(',^([a-z][\w:]*),i', (string) $tag, $reg)) {
206
+        return $reg[1];
207
+    }
208 208
 
209
-	return '';
209
+    return '';
210 210
 }
211 211
 
212 212
 function spip_xml_decompose_tag($tag) {
213
-	$tagname = spip_xml_tagname($tag);
214
-	$liste = [];
215
-	$tag = ltrim(strpbrk((string) $tag, " \n\t"));
216
-	$p = strpos($tag, '=');
217
-	while ($p !== false) {
218
-		$attr = trim(substr($tag, 0, $p));
219
-		$tag = ltrim(substr($tag, $p + 1));
220
-		$quote = $tag[0];
221
-		$p = strpos($tag, $quote, 1);
222
-		$cont = substr($tag, 1, $p - 1);
223
-		$liste[$attr] = $cont;
224
-		$tag = substr($tag, $p + 1);
225
-		$p = strpos($tag, '=');
226
-	}
213
+    $tagname = spip_xml_tagname($tag);
214
+    $liste = [];
215
+    $tag = ltrim(strpbrk((string) $tag, " \n\t"));
216
+    $p = strpos($tag, '=');
217
+    while ($p !== false) {
218
+        $attr = trim(substr($tag, 0, $p));
219
+        $tag = ltrim(substr($tag, $p + 1));
220
+        $quote = $tag[0];
221
+        $p = strpos($tag, $quote, 1);
222
+        $cont = substr($tag, 1, $p - 1);
223
+        $liste[$attr] = $cont;
224
+        $tag = substr($tag, $p + 1);
225
+        $p = strpos($tag, '=');
226
+    }
227 227
 
228
-	return [$tagname, $liste];
228
+    return [$tagname, $liste];
229 229
 }
230 230
 
231 231
 /**
@@ -248,21 +248,21 @@  discard block
 block discarded – undo
248 248
  *     false si aucun élément ne valide l'expression régulière, true sinon.
249 249
  **/
250 250
 function spip_xml_match_nodes($regexp, &$arbre, &$matches, $init = true) {
251
-	if ($init) {
252
-		$matches = [];
253
-	}
254
-	if (is_array($arbre) && count($arbre)) {
255
-		foreach (array_keys($arbre) as $tag) {
256
-			if (preg_match($regexp, $tag)) {
257
-				$matches[$tag] = &$arbre[$tag];
258
-			}
259
-			if (is_array($arbre[$tag])) {
260
-				foreach (array_keys($arbre[$tag]) as $occurences) {
261
-					spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false);
262
-				}
263
-			}
264
-		}
265
-	}
251
+    if ($init) {
252
+        $matches = [];
253
+    }
254
+    if (is_array($arbre) && count($arbre)) {
255
+        foreach (array_keys($arbre) as $tag) {
256
+            if (preg_match($regexp, $tag)) {
257
+                $matches[$tag] = &$arbre[$tag];
258
+            }
259
+            if (is_array($arbre[$tag])) {
260
+                foreach (array_keys($arbre[$tag]) as $occurences) {
261
+                    spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false);
262
+                }
263
+            }
264
+        }
265
+    }
266 266
 
267
-	return (is_countable($matches) ? count($matches) : 0);
267
+    return (is_countable($matches) ? count($matches) : 0);
268 268
 }
Please login to merge, or discard this patch.