Completed
Push — master ( 6c9939...4ccfda )
by cam
01:06
created
ecrire/inc/filtres_ecrire.php 1 patch
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  */
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/filtres_boites');
@@ -41,25 +41,25 @@  discard block
 block discarded – undo
41 41
  */
42 42
 function parametres_css_prive() {
43 43
 
44
-	$args = [];
45
-	$args['v'] = $GLOBALS['spip_version_code'];
46
-	$args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4);
47
-	$args['themes'] = implode(',', lister_themes_prives());
48
-	$args['ltr'] = $GLOBALS['spip_lang_left'];
49
-	// un md5 des menus : si un menu change il faut maj la css
50
-	$args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : '');
44
+    $args = [];
45
+    $args['v'] = $GLOBALS['spip_version_code'];
46
+    $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4);
47
+    $args['themes'] = implode(',', lister_themes_prives());
48
+    $args['ltr'] = $GLOBALS['spip_lang_left'];
49
+    // un md5 des menus : si un menu change il faut maj la css
50
+    $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : '');
51 51
 
52
-	$c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2;
52
+    $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2;
53 53
 
54
-	$couleurs = charger_fonction('couleurs', 'inc');
55
-	parse_str($couleurs($c), $c);
56
-	$args = array_merge($args, $c);
54
+    $couleurs = charger_fonction('couleurs', 'inc');
55
+    parse_str($couleurs($c), $c);
56
+    $args = array_merge($args, $c);
57 57
 
58
-	if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) {
59
-		$args['var_mode'] = 'recalcul';
60
-	}
58
+    if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) {
59
+        $args['var_mode'] = 'recalcul';
60
+    }
61 61
 
62
-	return http_build_query($args);
62
+    return http_build_query($args);
63 63
 }
64 64
 
65 65
 
@@ -82,91 +82,91 @@  discard block
 block discarded – undo
82 82
  * @return string
83 83
  */
84 84
 function chercher_rubrique(
85
-	$titre,
86
-	$id_objet,
87
-	$id_parent,
88
-	$objet,
89
-	$id_secteur,
90
-	$restreint,
91
-	$actionable = false,
92
-	$retour_sans_cadre = false
85
+    $titre,
86
+    $id_objet,
87
+    $id_parent,
88
+    $objet,
89
+    $id_secteur,
90
+    $restreint,
91
+    $actionable = false,
92
+    $retour_sans_cadre = false
93 93
 ) {
94 94
 
95
-	include_spip('inc/autoriser');
96
-	if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) {
97
-		return '';
98
-	}
99
-	if (!sql_countsel('spip_rubriques')) {
100
-		return '';
101
-	}
102
-	$chercher_rubrique = charger_fonction('chercher_rubrique', 'inc');
103
-	$form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0);
104
-
105
-	if ($id_parent == 0) {
106
-		$logo = 'racine-24.png';
107
-	} elseif ($id_secteur == $id_parent) {
108
-		$logo = 'secteur-24.png';
109
-	} else {
110
-		$logo = 'rubrique-24.png';
111
-	}
112
-
113
-	$confirm = '';
114
-	if ($objet == 'rubrique') {
115
-		// si c'est une rubrique-secteur contenant des breves, demander la
116
-		// confirmation du deplacement
117
-		$contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet));
118
-
119
-		if ($contient_breves > 0) {
120
-			$scb = ($contient_breves > 1 ? 's' : '');
121
-			$scb = _T(
122
-				'avis_deplacement_rubrique',
123
-				[
124
-					'contient_breves' => $contient_breves,
125
-					'scb' => $scb
126
-				]
127
-			);
128
-			$confirm .= "\n<div class='confirmer_deplacement verdana2'>"
129
-				. "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
130
-				. $scb .
131
-				"</label></div></div>\n";
132
-		} else {
133
-			$confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
134
-		}
135
-	}
136
-	$form .= $confirm;
137
-	if ($actionable) {
138
-		if (strpos($form, '<select') !== false) {
139
-			$form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
140
-				. '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>'
141
-				. '</div>';
142
-		}
143
-		$form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
144
-		if ($action = charger_fonction("editer_$objet", 'action', true)) {
145
-			$form = generer_action_auteur(
146
-				"editer_$objet",
147
-				$id_objet,
148
-				self(),
149
-				$form,
150
-				" method='post' class='submit_plongeur'"
151
-			);
152
-		} else {
153
-			$form = generer_action_auteur(
154
-				'editer_objet',
155
-				"$objet/$id_objet",
156
-				self(),
157
-				$form,
158
-				" method='post' class='submit_plongeur'"
159
-			);
160
-		}
161
-	}
162
-
163
-	if ($retour_sans_cadre) {
164
-		return $form;
165
-	}
166
-
167
-	include_spip('inc/presentation');
168
-
169
-	return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur();
95
+    include_spip('inc/autoriser');
96
+    if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) {
97
+        return '';
98
+    }
99
+    if (!sql_countsel('spip_rubriques')) {
100
+        return '';
101
+    }
102
+    $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc');
103
+    $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0);
104
+
105
+    if ($id_parent == 0) {
106
+        $logo = 'racine-24.png';
107
+    } elseif ($id_secteur == $id_parent) {
108
+        $logo = 'secteur-24.png';
109
+    } else {
110
+        $logo = 'rubrique-24.png';
111
+    }
112
+
113
+    $confirm = '';
114
+    if ($objet == 'rubrique') {
115
+        // si c'est une rubrique-secteur contenant des breves, demander la
116
+        // confirmation du deplacement
117
+        $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet));
118
+
119
+        if ($contient_breves > 0) {
120
+            $scb = ($contient_breves > 1 ? 's' : '');
121
+            $scb = _T(
122
+                'avis_deplacement_rubrique',
123
+                [
124
+                    'contient_breves' => $contient_breves,
125
+                    'scb' => $scb
126
+                ]
127
+            );
128
+            $confirm .= "\n<div class='confirmer_deplacement verdana2'>"
129
+                . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
130
+                . $scb .
131
+                "</label></div></div>\n";
132
+        } else {
133
+            $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
134
+        }
135
+    }
136
+    $form .= $confirm;
137
+    if ($actionable) {
138
+        if (strpos($form, '<select') !== false) {
139
+            $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
140
+                . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>'
141
+                . '</div>';
142
+        }
143
+        $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
144
+        if ($action = charger_fonction("editer_$objet", 'action', true)) {
145
+            $form = generer_action_auteur(
146
+                "editer_$objet",
147
+                $id_objet,
148
+                self(),
149
+                $form,
150
+                " method='post' class='submit_plongeur'"
151
+            );
152
+        } else {
153
+            $form = generer_action_auteur(
154
+                'editer_objet',
155
+                "$objet/$id_objet",
156
+                self(),
157
+                $form,
158
+                " method='post' class='submit_plongeur'"
159
+            );
160
+        }
161
+    }
162
+
163
+    if ($retour_sans_cadre) {
164
+        return $form;
165
+    }
166
+
167
+    include_spip('inc/presentation');
168
+
169
+    return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur();
170 170
 }
171 171
 
172 172
 
@@ -180,24 +180,24 @@  discard block
 block discarded – undo
180 180
  * @return bool
181 181
  */
182 182
 function avoir_visiteurs($past = false, $accepter = true) {
183
-	if ($GLOBALS['meta']['forums_publics'] == 'abo') {
184
-		return true;
185
-	}
186
-	if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') {
187
-		return true;
188
-	}
189
-	if (sql_countsel('spip_articles', "accepter_forum='abo'")) {
190
-		return true;
191
-	}
192
-	if (!$past) {
193
-		return false;
194
-	}
195
-
196
-	return sql_countsel(
197
-		'spip_auteurs',
198
-		"statut NOT IN ('0minirezo','1comite', '5poubelle')
183
+    if ($GLOBALS['meta']['forums_publics'] == 'abo') {
184
+        return true;
185
+    }
186
+    if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') {
187
+        return true;
188
+    }
189
+    if (sql_countsel('spip_articles', "accepter_forum='abo'")) {
190
+        return true;
191
+    }
192
+    if (!$past) {
193
+        return false;
194
+    }
195
+
196
+    return sql_countsel(
197
+        'spip_auteurs',
198
+        "statut NOT IN ('0minirezo','1comite', '5poubelle')
199 199
 	                    AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))"
200
-	);
200
+    );
201 201
 }
202 202
 
203 203
 /**
@@ -213,18 +213,18 @@  discard block
 block discarded – undo
213 213
  * @return array
214 214
  */
215 215
 function statuts_articles_visibles($statut_auteur) {
216
-	static $auth = [];
217
-	if (!isset($auth[$statut_auteur])) {
218
-		$auth[$statut_auteur] = [];
219
-		$statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut');
220
-		foreach ($statuts as $s) {
221
-			if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) {
222
-				$auth[$statut_auteur][] = $s;
223
-			}
224
-		}
225
-	}
226
-
227
-	return $auth[$statut_auteur];
216
+    static $auth = [];
217
+    if (!isset($auth[$statut_auteur])) {
218
+        $auth[$statut_auteur] = [];
219
+        $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut');
220
+        foreach ($statuts as $s) {
221
+            if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) {
222
+                $auth[$statut_auteur][] = $s;
223
+            }
224
+        }
225
+    }
226
+
227
+    return $auth[$statut_auteur];
228 228
 }
229 229
 
230 230
 /**
@@ -238,38 +238,38 @@  discard block
 block discarded – undo
238 238
  * @return string
239 239
  */
240 240
 function traduire_statut_auteur($statut, $attente = '') {
241
-	$plus = '';
242
-	if ($statut == 'nouveau') {
243
-		if ($attente) {
244
-			$statut = $attente;
245
-			$plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')';
246
-		} else {
247
-			return _T('info_statut_auteur_a_confirmer');
248
-		}
249
-	}
250
-
251
-	$recom = [
252
-		'info_administrateurs' => _T('item_administrateur_2'),
253
-		'info_redacteurs' => _T('intem_redacteur'),
254
-		'info_visiteurs' => _T('item_visiteur'),
255
-		'5poubelle' => _T('texte_statut_poubelle'), // bouh
256
-	];
257
-	if (isset($recom[$statut])) {
258
-		return $recom[$statut] . $plus;
259
-	}
260
-
261
-	// retrouver directement par le statut sinon
262
-	if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
263
-		if (isset($recom[$t])) {
264
-			return $recom[$t] . $plus;
265
-		}
266
-
267
-		return _T($t) . $plus;
268
-	}
269
-
270
-	// si on a pas reussi a le traduire, retournons la chaine telle quelle
271
-	// c'est toujours plus informatif que rien du tout
272
-	return $statut;
241
+    $plus = '';
242
+    if ($statut == 'nouveau') {
243
+        if ($attente) {
244
+            $statut = $attente;
245
+            $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')';
246
+        } else {
247
+            return _T('info_statut_auteur_a_confirmer');
248
+        }
249
+    }
250
+
251
+    $recom = [
252
+        'info_administrateurs' => _T('item_administrateur_2'),
253
+        'info_redacteurs' => _T('intem_redacteur'),
254
+        'info_visiteurs' => _T('item_visiteur'),
255
+        '5poubelle' => _T('texte_statut_poubelle'), // bouh
256
+    ];
257
+    if (isset($recom[$statut])) {
258
+        return $recom[$statut] . $plus;
259
+    }
260
+
261
+    // retrouver directement par le statut sinon
262
+    if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
263
+        if (isset($recom[$t])) {
264
+            return $recom[$t] . $plus;
265
+        }
266
+
267
+        return _T($t) . $plus;
268
+    }
269
+
270
+    // si on a pas reussi a le traduire, retournons la chaine telle quelle
271
+    // c'est toujours plus informatif que rien du tout
272
+    return $statut;
273 273
 }
274 274
 
275 275
 /**
@@ -280,28 +280,28 @@  discard block
 block discarded – undo
280 280
  * @return string
281 281
  */
282 282
 function afficher_qui_edite($id_objet, $objet) {
283
-	static $qui = [];
284
-	if (isset($qui[$objet][$id_objet])) {
285
-		return $qui[$objet][$id_objet];
286
-	}
287
-
288
-	if ($GLOBALS['meta']['articles_modif'] == 'non') {
289
-		return $qui[$objet][$id_objet] = '';
290
-	}
291
-
292
-	include_spip('inc/drapeau_edition');
293
-	$modif = mention_qui_edite($id_objet, $objet);
294
-	if (!$modif) {
295
-		return $qui[$objet][$id_objet] = '';
296
-	}
297
-
298
-	include_spip('base/objets');
299
-	$infos = lister_tables_objets_sql(table_objet_sql($objet));
300
-	if (isset($infos['texte_signale_edition'])) {
301
-		return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif);
302
-	}
303
-
304
-	return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif);
283
+    static $qui = [];
284
+    if (isset($qui[$objet][$id_objet])) {
285
+        return $qui[$objet][$id_objet];
286
+    }
287
+
288
+    if ($GLOBALS['meta']['articles_modif'] == 'non') {
289
+        return $qui[$objet][$id_objet] = '';
290
+    }
291
+
292
+    include_spip('inc/drapeau_edition');
293
+    $modif = mention_qui_edite($id_objet, $objet);
294
+    if (!$modif) {
295
+        return $qui[$objet][$id_objet] = '';
296
+    }
297
+
298
+    include_spip('base/objets');
299
+    $infos = lister_tables_objets_sql(table_objet_sql($objet));
300
+    if (isset($infos['texte_signale_edition'])) {
301
+        return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif);
302
+    }
303
+
304
+    return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif);
305 305
 }
306 306
 
307 307
 /**
@@ -319,57 +319,57 @@  discard block
 block discarded – undo
319 319
  * @return array
320 320
  */
321 321
 function auteurs_lister_statuts($quoi = 'tous', $en_base = true) {
322
-	if (!defined('AUTEURS_MIN_REDAC')) {
323
-		define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle');
324
-	}
325
-
326
-	switch ($quoi) {
327
-		case 'redacteurs':
328
-			$statut = AUTEURS_MIN_REDAC;
329
-			$statut = explode(',', $statut);
330
-			if ($en_base) {
331
-				$check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
332
-				$retire = array_diff($statut, $check);
333
-				$statut = array_diff($statut, $retire);
334
-			}
335
-
336
-			return array_unique($statut);
337
-			break;
338
-		case 'visiteurs':
339
-			$statut = [];
340
-			$exclus = AUTEURS_MIN_REDAC;
341
-			$exclus = explode(',', $exclus);
342
-			if (!$en_base) {
343
-				// prendre aussi les statuts de la table des status qui ne sont pas dans le define
344
-				$statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus);
345
-			}
346
-			$s_complement = array_column(
347
-				sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')),
348
-				'statut'
349
-			);
350
-
351
-			return array_unique(array_merge($statut, $s_complement));
352
-			break;
353
-		default:
354
-		case 'tous':
355
-			$statut = array_values($GLOBALS['liste_des_statuts']);
356
-			$s_complement = array_column(
357
-				sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')),
358
-				'statut'
359
-			);
360
-			$statut = array_merge($statut, $s_complement);
361
-			if ($en_base) {
362
-				$check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
363
-				$retire = array_diff($statut, $check);
364
-				$statut = array_diff($statut, $retire);
365
-			}
366
-
367
-			return array_unique($statut);
368
-			break;
369
-	}
370
-
371
-	// on arrive jamais ici
372
-	return array_values($GLOBALS['liste_des_statuts']);
322
+    if (!defined('AUTEURS_MIN_REDAC')) {
323
+        define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle');
324
+    }
325
+
326
+    switch ($quoi) {
327
+        case 'redacteurs':
328
+            $statut = AUTEURS_MIN_REDAC;
329
+            $statut = explode(',', $statut);
330
+            if ($en_base) {
331
+                $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
332
+                $retire = array_diff($statut, $check);
333
+                $statut = array_diff($statut, $retire);
334
+            }
335
+
336
+            return array_unique($statut);
337
+            break;
338
+        case 'visiteurs':
339
+            $statut = [];
340
+            $exclus = AUTEURS_MIN_REDAC;
341
+            $exclus = explode(',', $exclus);
342
+            if (!$en_base) {
343
+                // prendre aussi les statuts de la table des status qui ne sont pas dans le define
344
+                $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus);
345
+            }
346
+            $s_complement = array_column(
347
+                sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')),
348
+                'statut'
349
+            );
350
+
351
+            return array_unique(array_merge($statut, $s_complement));
352
+            break;
353
+        default:
354
+        case 'tous':
355
+            $statut = array_values($GLOBALS['liste_des_statuts']);
356
+            $s_complement = array_column(
357
+                sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')),
358
+                'statut'
359
+            );
360
+            $statut = array_merge($statut, $s_complement);
361
+            if ($en_base) {
362
+                $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
363
+                $retire = array_diff($statut, $check);
364
+                $statut = array_diff($statut, $retire);
365
+            }
366
+
367
+            return array_unique($statut);
368
+            break;
369
+    }
370
+
371
+    // on arrive jamais ici
372
+    return array_values($GLOBALS['liste_des_statuts']);
373 373
 }
374 374
 
375 375
 /**
@@ -385,28 +385,28 @@  discard block
 block discarded – undo
385 385
  */
386 386
 function trouver_rubrique_creer_objet($id_rubrique, $objet) {
387 387
 
388
-	if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) {
389
-		$in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0)
390
-			? ''
391
-			: (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']));
392
-
393
-		// on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
394
-		if ($objet == 'rubrique') {
395
-			$id_rubrique = 0;
396
-		} else {
397
-			$id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1);
398
-		}
399
-
400
-		if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) {
401
-			// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
402
-			$res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
403
-			while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) {
404
-				$id_rubrique = $row_rub['id_rubrique'];
405
-			}
406
-		}
407
-	}
408
-
409
-	return $id_rubrique;
388
+    if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) {
389
+        $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0)
390
+            ? ''
391
+            : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']));
392
+
393
+        // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
394
+        if ($objet == 'rubrique') {
395
+            $id_rubrique = 0;
396
+        } else {
397
+            $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1);
398
+        }
399
+
400
+        if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) {
401
+            // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
402
+            $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
403
+            while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) {
404
+                $id_rubrique = $row_rub['id_rubrique'];
405
+            }
406
+        }
407
+    }
408
+
409
+    return $id_rubrique;
410 410
 }
411 411
 
412 412
 /**
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
  * @return string
418 418
  */
419 419
 function lien_article_virtuel($virtuel) {
420
-	include_spip('inc/lien');
421
-	if (!$virtuel = virtuel_redirige($virtuel)) {
422
-		return '';
423
-	}
420
+    include_spip('inc/lien');
421
+    if (!$virtuel = virtuel_redirige($virtuel)) {
422
+        return '';
423
+    }
424 424
 
425
-	return propre('[->' . $virtuel . ']');
425
+    return propre('[->' . $virtuel . ']');
426 426
 }
427 427
 
428 428
 
@@ -445,12 +445,12 @@  discard block
 block discarded – undo
445 445
  *     Code HTML du lien
446 446
  */
447 447
 function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') {
448
-	include_spip('inc/acces');
449
-	$clic = http_img_pack('rss-16.png', 'RSS', '', $title);
450
-	$args = param_low_sec($op, $args, $lang, 'rss');
451
-	$url = generer_url_public('rss', $args);
448
+    include_spip('inc/acces');
449
+    $clic = http_img_pack('rss-16.png', 'RSS', '', $title);
450
+    $args = param_low_sec($op, $args, $lang, 'rss');
451
+    $url = generer_url_public('rss', $args);
452 452
 
453
-	return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
453
+    return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
454 454
 }
455 455
 
456 456
 
@@ -462,74 +462,74 @@  discard block
 block discarded – undo
462 462
  */
463 463
 function alertes_auteur($id_auteur) {
464 464
 
465
-	$alertes = [];
466
-
467
-	if (
468
-		isset($GLOBALS['meta']['message_crash_tables'])
469
-		and autoriser('detruire', null, null, $id_auteur)
470
-	) {
471
-		include_spip('genie/maintenance');
472
-		if ($msg = message_crash_tables()) {
473
-			$alertes[] = $msg;
474
-		}
475
-	}
476
-
477
-	if (
478
-		isset($GLOBALS['meta']['message_crash_plugins'])
479
-		and $GLOBALS['meta']['message_crash_plugins']
480
-		and autoriser('configurer', '_plugins', null, $id_auteur)
481
-		and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))
482
-	) {
483
-		$msg = implode(', ', array_map('joli_repertoire', array_keys($msg)));
484
-		$alertes[] = _T('plugins_erreur', ['plugins' => $msg]);
485
-	}
486
-
487
-	$a = $GLOBALS['meta']['message_alertes_auteurs'] ?? '';
488
-	if (
489
-		$a
490
-		and is_array($a = unserialize($a))
491
-		and count($a)
492
-	) {
493
-		$update = false;
494
-		if (isset($a[$GLOBALS['visiteur_session']['statut']])) {
495
-			$alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]);
496
-			unset($a[$GLOBALS['visiteur_session']['statut']]);
497
-			$update = true;
498
-		}
499
-		if (isset($a[''])) {
500
-			$alertes = array_merge($alertes, $a['']);
501
-			unset($a['']);
502
-			$update = true;
503
-		}
504
-		if ($update) {
505
-			ecrire_meta('message_alertes_auteurs', serialize($a));
506
-		}
507
-	}
508
-
509
-	if (
510
-		isset($GLOBALS['meta']['plugin_erreur_activation'])
511
-		and autoriser('configurer', '_plugins', null, $id_auteur)
512
-	) {
513
-		include_spip('inc/plugin');
514
-		$alertes[] = plugin_donne_erreurs();
515
-	}
516
-
517
-	$alertes = pipeline(
518
-		'alertes_auteur',
519
-		[
520
-			'args' => [
521
-				'id_auteur' => $id_auteur,
522
-				'exec' => _request('exec'),
523
-			],
524
-			'data' => $alertes
525
-		]
526
-	);
527
-
528
-	if ($alertes = array_filter($alertes)) {
529
-		return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
530
-		join(' | ', $alertes)
531
-		. '</div></div>';
532
-	}
465
+    $alertes = [];
466
+
467
+    if (
468
+        isset($GLOBALS['meta']['message_crash_tables'])
469
+        and autoriser('detruire', null, null, $id_auteur)
470
+    ) {
471
+        include_spip('genie/maintenance');
472
+        if ($msg = message_crash_tables()) {
473
+            $alertes[] = $msg;
474
+        }
475
+    }
476
+
477
+    if (
478
+        isset($GLOBALS['meta']['message_crash_plugins'])
479
+        and $GLOBALS['meta']['message_crash_plugins']
480
+        and autoriser('configurer', '_plugins', null, $id_auteur)
481
+        and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))
482
+    ) {
483
+        $msg = implode(', ', array_map('joli_repertoire', array_keys($msg)));
484
+        $alertes[] = _T('plugins_erreur', ['plugins' => $msg]);
485
+    }
486
+
487
+    $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? '';
488
+    if (
489
+        $a
490
+        and is_array($a = unserialize($a))
491
+        and count($a)
492
+    ) {
493
+        $update = false;
494
+        if (isset($a[$GLOBALS['visiteur_session']['statut']])) {
495
+            $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]);
496
+            unset($a[$GLOBALS['visiteur_session']['statut']]);
497
+            $update = true;
498
+        }
499
+        if (isset($a[''])) {
500
+            $alertes = array_merge($alertes, $a['']);
501
+            unset($a['']);
502
+            $update = true;
503
+        }
504
+        if ($update) {
505
+            ecrire_meta('message_alertes_auteurs', serialize($a));
506
+        }
507
+    }
508
+
509
+    if (
510
+        isset($GLOBALS['meta']['plugin_erreur_activation'])
511
+        and autoriser('configurer', '_plugins', null, $id_auteur)
512
+    ) {
513
+        include_spip('inc/plugin');
514
+        $alertes[] = plugin_donne_erreurs();
515
+    }
516
+
517
+    $alertes = pipeline(
518
+        'alertes_auteur',
519
+        [
520
+            'args' => [
521
+                'id_auteur' => $id_auteur,
522
+                'exec' => _request('exec'),
523
+            ],
524
+            'data' => $alertes
525
+        ]
526
+    );
527
+
528
+    if ($alertes = array_filter($alertes)) {
529
+        return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
530
+        join(' | ', $alertes)
531
+        . '</div></div>';
532
+    }
533 533
 }
534 534
 
535 535
 /**
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
  * @return string
540 540
  */
541 541
 function filtre_afficher_enfant_rub_dist($id_rubrique) {
542
-	include_spip('inc/presenter_enfants');
542
+    include_spip('inc/presenter_enfants');
543 543
 
544
-	return afficher_enfant_rub(intval($id_rubrique));
544
+    return afficher_enfant_rub(intval($id_rubrique));
545 545
 }
546 546
 
547 547
 /**
@@ -559,15 +559,15 @@  discard block
 block discarded – undo
559 559
  * @return string
560 560
  */
561 561
 function afficher_plus_info($lien, $titre = '+', $titre_lien = '') {
562
-	$titre = attribut_html($titre);
563
-	$icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
564
-		http_img_pack('information-16.png', $titre) . '</a>';
565
-
566
-	if (!$titre_lien) {
567
-		return $icone;
568
-	} else {
569
-		return $icone . "\n<a href='$lien'>$titre_lien</a>";
570
-	}
562
+    $titre = attribut_html($titre);
563
+    $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
564
+        http_img_pack('information-16.png', $titre) . '</a>';
565
+
566
+    if (!$titre_lien) {
567
+        return $icone;
568
+    } else {
569
+        return $icone . "\n<a href='$lien'>$titre_lien</a>";
570
+    }
571 571
 }
572 572
 
573 573
 
@@ -586,17 +586,17 @@  discard block
 block discarded – undo
586 586
  * @return array
587 587
  */
588 588
 function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) {
589
-	$res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien);
590
-	if (!(is_countable($res) ? count($res) : 0)) {
591
-		return [];
592
-	}
593
-	$r = reset($res);
594
-	if (isset($r['rang_lien'])) {
595
-		$l = array_column($res, 'rang_lien', $objet_source);
596
-		asort($l);
597
-		$l = array_keys($l);
598
-	} else {
599
-		$l = array_column($res, $objet_source);
600
-	}
601
-	return $l;
589
+    $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien);
590
+    if (!(is_countable($res) ? count($res) : 0)) {
591
+        return [];
592
+    }
593
+    $r = reset($res);
594
+    if (isset($r['rang_lien'])) {
595
+        $l = array_column($res, 'rang_lien', $objet_source);
596
+        asort($l);
597
+        $l = array_keys($l);
598
+    } else {
599
+        $l = array_column($res, $objet_source);
600
+    }
601
+    return $l;
602 602
 }
Please login to merge, or discard this patch.
ecrire/inc/plugin.php 1 patch
Indentation   +976 added lines, -976 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  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
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
24 24
 if (!defined('_DIR_PLUGINS_AUTO')) {
25
-	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
25
+    define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
26 26
 }
27 27
 
28 28
 #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins.
@@ -47,27 +47,27 @@  discard block
 block discarded – undo
47 47
  * @return array
48 48
 **/
49 49
 function liste_plugin_files($dir_plugins = null) {
50
-	static $plugin_files = [];
51
-	if (is_null($dir_plugins)) {
52
-		$dir_plugins = _DIR_PLUGINS;
53
-	}
54
-	if (
55
-		!isset($plugin_files[$dir_plugins])
56
-		or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0
57
-	) {
58
-		$plugin_files[$dir_plugins] = [];
59
-		foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
60
-			$plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
61
-		}
62
-
63
-		sort($plugin_files[$dir_plugins]);
64
-		// et on lit le XML de tous les plugins pour le mettre en cache
65
-		// et en profiter pour nettoyer ceux qui n'existent plus du cache
66
-		$get_infos = charger_fonction('get_infos', 'plugins');
67
-		$get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
68
-	}
69
-
70
-	return $plugin_files[$dir_plugins];
50
+    static $plugin_files = [];
51
+    if (is_null($dir_plugins)) {
52
+        $dir_plugins = _DIR_PLUGINS;
53
+    }
54
+    if (
55
+        !isset($plugin_files[$dir_plugins])
56
+        or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0
57
+    ) {
58
+        $plugin_files[$dir_plugins] = [];
59
+        foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
60
+            $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
61
+        }
62
+
63
+        sort($plugin_files[$dir_plugins]);
64
+        // et on lit le XML de tous les plugins pour le mettre en cache
65
+        // et en profiter pour nettoyer ceux qui n'existent plus du cache
66
+        $get_infos = charger_fonction('get_infos', 'plugins');
67
+        $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
68
+    }
69
+
70
+    return $plugin_files[$dir_plugins];
71 71
 }
72 72
 
73 73
 /**
@@ -83,45 +83,45 @@  discard block
 block discarded – undo
83 83
  *     Liste complète des répeertoires
84 84
 **/
85 85
 function fast_find_plugin_dirs($dir, $max_prof = 100) {
86
-	$fichiers = [];
87
-	// revenir au repertoire racine si on a recu dossier/truc
88
-	// pour regarder dossier/truc/ ne pas oublier le / final
89
-	$dir = preg_replace(',/[^/]*$,', '', $dir);
90
-	if ($dir == '') {
91
-		$dir = '.';
92
-	}
93
-
94
-	if (!is_dir($dir)) {
95
-		return $fichiers;
96
-	}
97
-	if (is_plugin_dir($dir, '')) {
98
-		$fichiers[] = $dir;
99
-
100
-		return $fichiers;
101
-	}
102
-	if ($max_prof <= 0) {
103
-		return $fichiers;
104
-	}
105
-
106
-	$subdirs = [];
107
-	if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
108
-		while (($f = readdir($d)) !== false) {
109
-			if (
110
-				$f[0] != '.' # ignorer . .. .svn etc
111
-				and $f != 'CVS'
112
-				and is_dir($f = "$dir/$f")
113
-			) {
114
-				$subdirs[] = $f;
115
-			}
116
-		}
117
-		closedir($d);
118
-	}
119
-
120
-	foreach ($subdirs as $d) {
121
-		$fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
122
-	}
123
-
124
-	return $fichiers;
86
+    $fichiers = [];
87
+    // revenir au repertoire racine si on a recu dossier/truc
88
+    // pour regarder dossier/truc/ ne pas oublier le / final
89
+    $dir = preg_replace(',/[^/]*$,', '', $dir);
90
+    if ($dir == '') {
91
+        $dir = '.';
92
+    }
93
+
94
+    if (!is_dir($dir)) {
95
+        return $fichiers;
96
+    }
97
+    if (is_plugin_dir($dir, '')) {
98
+        $fichiers[] = $dir;
99
+
100
+        return $fichiers;
101
+    }
102
+    if ($max_prof <= 0) {
103
+        return $fichiers;
104
+    }
105
+
106
+    $subdirs = [];
107
+    if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
108
+        while (($f = readdir($d)) !== false) {
109
+            if (
110
+                $f[0] != '.' # ignorer . .. .svn etc
111
+                and $f != 'CVS'
112
+                and is_dir($f = "$dir/$f")
113
+            ) {
114
+                $subdirs[] = $f;
115
+            }
116
+        }
117
+        closedir($d);
118
+    }
119
+
120
+    foreach ($subdirs as $d) {
121
+        $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
122
+    }
123
+
124
+    return $fichiers;
125 125
 }
126 126
 
127 127
 /**
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 **/
143 143
 function is_plugin_dir($dir, $dir_plugins = null) {
144 144
 
145
-	if (is_array($dir)) {
146
-		foreach ($dir as $k => $d) {
147
-			if (!is_plugin_dir($d, $dir_plugins)) {
148
-				unset($dir[$k]);
149
-			}
150
-		}
151
-
152
-		return $dir;
153
-	}
154
-	if (is_null($dir_plugins)) {
155
-		$dir_plugins = _DIR_PLUGINS;
156
-	}
157
-	$search = ["$dir_plugins$dir/paquet.xml"];
158
-
159
-	foreach ($search as $s) {
160
-		if (file_exists($s)) {
161
-			return $dir;
162
-		}
163
-	}
164
-
165
-	return '';
145
+    if (is_array($dir)) {
146
+        foreach ($dir as $k => $d) {
147
+            if (!is_plugin_dir($d, $dir_plugins)) {
148
+                unset($dir[$k]);
149
+            }
150
+        }
151
+
152
+        return $dir;
153
+    }
154
+    if (is_null($dir_plugins)) {
155
+        $dir_plugins = _DIR_PLUGINS;
156
+    }
157
+    $search = ["$dir_plugins$dir/paquet.xml"];
158
+
159
+    foreach ($search as $s) {
160
+        if (file_exists($s)) {
161
+            return $dir;
162
+        }
163
+    }
164
+
165
+    return '';
166 166
 }
167 167
 
168 168
 /** Regexp d'extraction des informations d'un intervalle de compatibilité */
@@ -189,51 +189,51 @@  discard block
 block discarded – undo
189 189
  **/
190 190
 function plugin_version_compatible($intervalle, $version, $avec_quoi = '') {
191 191
 
192
-	if (!strlen($intervalle)) {
193
-		return true;
194
-	}
195
-	if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
196
-		return false;
197
-	}
198
-	// Extraction des bornes et traitement de * pour la borne sup :
199
-	// -- on autorise uniquement les ecritures 3.0.*, 3.*
200
-	$minimum = $regs[1];
201
-	$maximum = $regs[2];
202
-
203
-	//  si une version SPIP de compatibilité a été définie (dans
204
-	//  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
205
-	//  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
206
-	//  avec la version de SPIP (ne nuit donc pas aux tests de necessite
207
-	//  entre plugins)
208
-	if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
209
-		if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
210
-			return true;
211
-		}
212
-		// si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
213
-		// cas du plugin qui n'est compatible qu'avec cette nouvelle version
214
-	}
215
-
216
-	$minimum_inc = $intervalle[0] == '[';
217
-	$maximum_inc = substr($intervalle, -1) == ']';
218
-
219
-	if (strlen($minimum)) {
220
-		if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
221
-			return false;
222
-		}
223
-		if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
224
-			return false;
225
-		}
226
-	}
227
-	if (strlen($maximum)) {
228
-		if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
229
-			return false;
230
-		}
231
-		if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
232
-			return false;
233
-		}
234
-	}
235
-
236
-	return true;
192
+    if (!strlen($intervalle)) {
193
+        return true;
194
+    }
195
+    if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
196
+        return false;
197
+    }
198
+    // Extraction des bornes et traitement de * pour la borne sup :
199
+    // -- on autorise uniquement les ecritures 3.0.*, 3.*
200
+    $minimum = $regs[1];
201
+    $maximum = $regs[2];
202
+
203
+    //  si une version SPIP de compatibilité a été définie (dans
204
+    //  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
205
+    //  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
206
+    //  avec la version de SPIP (ne nuit donc pas aux tests de necessite
207
+    //  entre plugins)
208
+    if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
209
+        if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
210
+            return true;
211
+        }
212
+        // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
213
+        // cas du plugin qui n'est compatible qu'avec cette nouvelle version
214
+    }
215
+
216
+    $minimum_inc = $intervalle[0] == '[';
217
+    $maximum_inc = substr($intervalle, -1) == ']';
218
+
219
+    if (strlen($minimum)) {
220
+        if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
221
+            return false;
222
+        }
223
+        if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
224
+            return false;
225
+        }
226
+    }
227
+    if (strlen($maximum)) {
228
+        if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
229
+            return false;
230
+        }
231
+        if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
232
+            return false;
233
+        }
234
+    }
235
+
236
+    return true;
237 237
 }
238 238
 
239 239
 /**
@@ -250,62 +250,62 @@  discard block
 block discarded – undo
250 250
  * @return array
251 251
  */
252 252
 function liste_plugin_valides($liste_plug, $force = false) {
253
-	$liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
254
-	$get_infos = charger_fonction('get_infos', 'plugins');
255
-	$infos = [
256
-		// lister les extensions qui sont automatiquement actives
257
-		'_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
258
-		'_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
259
-	];
260
-
261
-	// creer une premiere liste non ordonnee mais qui ne retient
262
-	// que les plugins valides, et dans leur derniere version en cas de doublon
263
-	$infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
264
-	$infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
265
-	$infos['_DIR_RESTREINT']['SPIP']['chemin'] = [];
266
-	$liste_non_classee = [
267
-		'SPIP' => [
268
-			'nom' => 'SPIP',
269
-			'etat' => 'stable',
270
-			'version' => $GLOBALS['spip_version_branche'],
271
-			'dir_type' => '_DIR_RESTREINT',
272
-			'dir' => '',
273
-		]
274
-	];
275
-
276
-	$invalides = [];
277
-	foreach ($liste_ext as $plug) {
278
-		if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
279
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
280
-		}
281
-	}
282
-	foreach ($liste_plug as $plug) {
283
-		if (isset($infos['_DIR_PLUGINS'][$plug])) {
284
-			$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
285
-			if (is_array($r)) {
286
-				$invalides = array_merge($invalides, $r);
287
-			}
288
-		}
289
-	}
290
-
291
-	if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
292
-		$infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
293
-		foreach ($liste_plug as $plug) {
294
-			if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
295
-				$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
296
-				if (is_array($r)) {
297
-					$invalides = array_merge($invalides, $r);
298
-				}
299
-			}
300
-		}
301
-	}
302
-
303
-	plugin_fixer_procure($liste_non_classee, $infos);
304
-
305
-	// les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
306
-	$invalides = array_diff_key($invalides, $liste_non_classee);
307
-
308
-	return [$infos, $liste_non_classee, $invalides];
253
+    $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
254
+    $get_infos = charger_fonction('get_infos', 'plugins');
255
+    $infos = [
256
+        // lister les extensions qui sont automatiquement actives
257
+        '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
258
+        '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
259
+    ];
260
+
261
+    // creer une premiere liste non ordonnee mais qui ne retient
262
+    // que les plugins valides, et dans leur derniere version en cas de doublon
263
+    $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
264
+    $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
265
+    $infos['_DIR_RESTREINT']['SPIP']['chemin'] = [];
266
+    $liste_non_classee = [
267
+        'SPIP' => [
268
+            'nom' => 'SPIP',
269
+            'etat' => 'stable',
270
+            'version' => $GLOBALS['spip_version_branche'],
271
+            'dir_type' => '_DIR_RESTREINT',
272
+            'dir' => '',
273
+        ]
274
+    ];
275
+
276
+    $invalides = [];
277
+    foreach ($liste_ext as $plug) {
278
+        if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
279
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
280
+        }
281
+    }
282
+    foreach ($liste_plug as $plug) {
283
+        if (isset($infos['_DIR_PLUGINS'][$plug])) {
284
+            $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
285
+            if (is_array($r)) {
286
+                $invalides = array_merge($invalides, $r);
287
+            }
288
+        }
289
+    }
290
+
291
+    if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
292
+        $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
293
+        foreach ($liste_plug as $plug) {
294
+            if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
295
+                $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
296
+                if (is_array($r)) {
297
+                    $invalides = array_merge($invalides, $r);
298
+                }
299
+            }
300
+        }
301
+    }
302
+
303
+    plugin_fixer_procure($liste_non_classee, $infos);
304
+
305
+    // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
306
+    $invalides = array_diff_key($invalides, $liste_non_classee);
307
+
308
+    return [$infos, $liste_non_classee, $invalides];
309 309
 }
310 310
 
311 311
 /**
@@ -325,30 +325,30 @@  discard block
 block discarded – undo
325 325
  *   array description short si on ne le retient pas (pour memorisation dans une table des erreurs)
326 326
  */
327 327
 function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) {
328
-	$i = $infos[$dir_type][$plug];
329
-	$p = strtoupper($i['prefix']);
330
-	$short_desc = [
331
-		'nom' => $i['nom'],
332
-		'etat' => $i['etat'],
333
-		'version' => $i['version'],
334
-		'dir' => $plug,
335
-		'dir_type' => $dir_type
336
-	];
337
-	if (isset($i['erreur']) and $i['erreur']) {
338
-		$short_desc['erreur'] = $i['erreur'];
339
-		return [$p => $short_desc];
340
-	}
341
-	if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
342
-		return [$p => $short_desc];
343
-	}
344
-	if (
345
-		!isset($liste[$p])
346
-		or spip_version_compare($i['version'], $liste[$p]['version'], '>')
347
-	) {
348
-		$liste[$p] = $short_desc;
349
-	}
350
-	// ok le plugin etait deja dans la liste ou on a choisi une version plus recente
351
-	return $p;
328
+    $i = $infos[$dir_type][$plug];
329
+    $p = strtoupper($i['prefix']);
330
+    $short_desc = [
331
+        'nom' => $i['nom'],
332
+        'etat' => $i['etat'],
333
+        'version' => $i['version'],
334
+        'dir' => $plug,
335
+        'dir_type' => $dir_type
336
+    ];
337
+    if (isset($i['erreur']) and $i['erreur']) {
338
+        $short_desc['erreur'] = $i['erreur'];
339
+        return [$p => $short_desc];
340
+    }
341
+    if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
342
+        return [$p => $short_desc];
343
+    }
344
+    if (
345
+        !isset($liste[$p])
346
+        or spip_version_compare($i['version'], $liste[$p]['version'], '>')
347
+    ) {
348
+        $liste[$p] = $short_desc;
349
+    }
350
+    // ok le plugin etait deja dans la liste ou on a choisi une version plus recente
351
+    return $p;
352 352
 }
353 353
 
354 354
 /**
@@ -364,47 +364,47 @@  discard block
 block discarded – undo
364 364
  * @param array $infos
365 365
  */
366 366
 function plugin_fixer_procure(&$liste, &$infos) {
367
-	foreach ($liste as $p => $resume) {
368
-		$i = $infos[$resume['dir_type']][$resume['dir']];
369
-		if (isset($i['procure']) and $i['procure']) {
370
-			foreach ($i['procure'] as $procure) {
371
-				$p = strtoupper($procure['nom']);
372
-				$dir = $resume['dir'];
373
-				if ($dir) {
374
-					$dir .= '/';
375
-				}
376
-				$dir .= 'procure:' . $procure['nom'];
377
-
378
-				$procure['etat'] = '?';
379
-				$procure['dir_type'] = $resume['dir_type'];
380
-				$procure['dir'] = $dir;
381
-
382
-				// si ce plugin n'est pas deja procure, ou dans une version plus ancienne
383
-				// on ajoute cette version a la liste
384
-				if (
385
-					!isset($liste[$p])
386
-					or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
387
-				) {
388
-					$liste[$p] = $procure;
389
-
390
-					// on fournit une information minimale pour ne pas perturber la compilation
391
-					$infos[$resume['dir_type']][$dir] = [
392
-						'prefix' => $procure['nom'],
393
-						'nom' => $procure['nom'],
394
-						'etat' => $procure['etat'],
395
-						'version' => $procure['version'],
396
-						'chemin' => [],
397
-						'necessite' => [],
398
-						'utilise' => [],
399
-						'lib' => [],
400
-						'menu' => [],
401
-						'onglet' => [],
402
-						'procure' => [],
403
-					];
404
-				}
405
-			}
406
-		}
407
-	}
367
+    foreach ($liste as $p => $resume) {
368
+        $i = $infos[$resume['dir_type']][$resume['dir']];
369
+        if (isset($i['procure']) and $i['procure']) {
370
+            foreach ($i['procure'] as $procure) {
371
+                $p = strtoupper($procure['nom']);
372
+                $dir = $resume['dir'];
373
+                if ($dir) {
374
+                    $dir .= '/';
375
+                }
376
+                $dir .= 'procure:' . $procure['nom'];
377
+
378
+                $procure['etat'] = '?';
379
+                $procure['dir_type'] = $resume['dir_type'];
380
+                $procure['dir'] = $dir;
381
+
382
+                // si ce plugin n'est pas deja procure, ou dans une version plus ancienne
383
+                // on ajoute cette version a la liste
384
+                if (
385
+                    !isset($liste[$p])
386
+                    or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
387
+                ) {
388
+                    $liste[$p] = $procure;
389
+
390
+                    // on fournit une information minimale pour ne pas perturber la compilation
391
+                    $infos[$resume['dir_type']][$dir] = [
392
+                        'prefix' => $procure['nom'],
393
+                        'nom' => $procure['nom'],
394
+                        'etat' => $procure['etat'],
395
+                        'version' => $procure['version'],
396
+                        'chemin' => [],
397
+                        'necessite' => [],
398
+                        'utilise' => [],
399
+                        'lib' => [],
400
+                        'menu' => [],
401
+                        'onglet' => [],
402
+                        'procure' => [],
403
+                    ];
404
+                }
405
+            }
406
+        }
407
+    }
408 408
 }
409 409
 
410 410
 /**
@@ -418,20 +418,20 @@  discard block
 block discarded – undo
418 418
  * @return array
419 419
  */
420 420
 function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) {
421
-	foreach ($liste as $prefix => $infos) {
422
-		if (
423
-			!$dir_plugins
424
-			or (
425
-				defined($infos['dir_type'])
426
-				and constant($infos['dir_type']) == $dir_plugins)
427
-		) {
428
-			$liste[$prefix] = $infos['dir'];
429
-		} else {
430
-			unset($liste[$prefix]);
431
-		}
432
-	}
433
-
434
-	return $liste;
421
+    foreach ($liste as $prefix => $infos) {
422
+        if (
423
+            !$dir_plugins
424
+            or (
425
+                defined($infos['dir_type'])
426
+                and constant($infos['dir_type']) == $dir_plugins)
427
+        ) {
428
+            $liste[$prefix] = $infos['dir'];
429
+        } else {
430
+            unset($liste[$prefix]);
431
+        }
432
+    }
433
+
434
+    return $liste;
435 435
 }
436 436
 
437 437
 /**
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
  * @return array
447 447
  */
448 448
 function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) {
449
-	include_spip('plugins/installer');
449
+    include_spip('plugins/installer');
450 450
 
451
-	return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
451
+    return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
452 452
 }
453 453
 
454 454
 /**
@@ -479,54 +479,54 @@  discard block
 block discarded – undo
479 479
  *                qui n'ont pas satisfait leurs dépendances
480 480
 **/
481 481
 function plugin_trier($infos, $liste_non_classee) {
482
-	$toute_la_liste = $liste_non_classee;
483
-	$liste = $ordre = [];
484
-	$count = 0;
485
-
486
-	while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
487
-		#echo "tour::";var_dump($liste_non_classee);
488
-		$count = $c;
489
-		foreach ($liste_non_classee as $p => $resume) {
490
-			$plug = $resume['dir'];
491
-			$dir_type = $resume['dir_type'];
492
-			$info1 = $infos[$dir_type][$plug];
493
-			// si des plugins sont necessaires,
494
-			// on ne peut inserer qu'apres eux
495
-			foreach ($info1['necessite'] as $need) {
496
-				$nom = strtoupper($need['nom']);
497
-				$compat = $need['compatibilite'] ?? '';
498
-				if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
499
-					$info1 = false;
500
-					break;
501
-				}
502
-			}
503
-			if (!$info1) {
504
-				continue;
505
-			}
506
-			// idem si des plugins sont utiles,
507
-			// sauf si ils sont de toute facon absents de la liste
508
-			foreach ($info1['utilise'] as $need) {
509
-				$nom = strtoupper($need['nom']);
510
-				$compat = $need['compatibilite'] ?? '';
511
-				if (isset($toute_la_liste[$nom])) {
512
-					if (
513
-						!isset($liste[$nom]) or
514
-						!plugin_version_compatible($compat, $liste[$nom]['version'])
515
-					) {
516
-						$info1 = false;
517
-						break;
518
-					}
519
-				}
520
-			}
521
-			if ($info1) {
522
-				$ordre[$p] = $info1;
523
-				$liste[$p] = $liste_non_classee[$p];
524
-				unset($liste_non_classee[$p]);
525
-			}
526
-		}
527
-	}
528
-
529
-	return [$liste, $ordre, $liste_non_classee];
482
+    $toute_la_liste = $liste_non_classee;
483
+    $liste = $ordre = [];
484
+    $count = 0;
485
+
486
+    while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
487
+        #echo "tour::";var_dump($liste_non_classee);
488
+        $count = $c;
489
+        foreach ($liste_non_classee as $p => $resume) {
490
+            $plug = $resume['dir'];
491
+            $dir_type = $resume['dir_type'];
492
+            $info1 = $infos[$dir_type][$plug];
493
+            // si des plugins sont necessaires,
494
+            // on ne peut inserer qu'apres eux
495
+            foreach ($info1['necessite'] as $need) {
496
+                $nom = strtoupper($need['nom']);
497
+                $compat = $need['compatibilite'] ?? '';
498
+                if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
499
+                    $info1 = false;
500
+                    break;
501
+                }
502
+            }
503
+            if (!$info1) {
504
+                continue;
505
+            }
506
+            // idem si des plugins sont utiles,
507
+            // sauf si ils sont de toute facon absents de la liste
508
+            foreach ($info1['utilise'] as $need) {
509
+                $nom = strtoupper($need['nom']);
510
+                $compat = $need['compatibilite'] ?? '';
511
+                if (isset($toute_la_liste[$nom])) {
512
+                    if (
513
+                        !isset($liste[$nom]) or
514
+                        !plugin_version_compatible($compat, $liste[$nom]['version'])
515
+                    ) {
516
+                        $info1 = false;
517
+                        break;
518
+                    }
519
+                }
520
+            }
521
+            if ($info1) {
522
+                $ordre[$p] = $info1;
523
+                $liste[$p] = $liste_non_classee[$p];
524
+                unset($liste_non_classee[$p]);
525
+            }
526
+        }
527
+    }
528
+
529
+    return [$liste, $ordre, $liste_non_classee];
530 530
 }
531 531
 
532 532
 /**
@@ -543,40 +543,40 @@  discard block
 block discarded – undo
543 543
  *     Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent
544 544
 **/
545 545
 function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = []) {
546
-	static $erreurs = [];
547
-
548
-	if (!is_array($liste)) {
549
-		$liste = [];
550
-	}
551
-
552
-	// les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
553
-	$liste = array_diff_key($liste, $liste_non_classee);
554
-
555
-	foreach ($liste_non_classee as $p => $resume) {
556
-		$dir_type = $resume['dir_type'];
557
-		$plug = $resume['dir'];
558
-		$k = $infos[$dir_type][$plug];
559
-
560
-		$plug = constant($dir_type) . $plug;
561
-		if (!isset($msg[$p])) {
562
-			if (isset($resume['erreur']) and $resume['erreur']) {
563
-				$msg[$p] = [$resume['erreur']];
564
-			}
565
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
566
-				$msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')];
567
-			}
568
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
569
-				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
570
-			}
571
-		} else {
572
-			foreach ($msg[$p] as $c => $l) {
573
-				$msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
574
-			}
575
-		}
576
-		$erreurs[$plug] = $msg[$p];
577
-	}
578
-
579
-	ecrire_meta('plugin_erreur_activation', serialize($erreurs));
546
+    static $erreurs = [];
547
+
548
+    if (!is_array($liste)) {
549
+        $liste = [];
550
+    }
551
+
552
+    // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
553
+    $liste = array_diff_key($liste, $liste_non_classee);
554
+
555
+    foreach ($liste_non_classee as $p => $resume) {
556
+        $dir_type = $resume['dir_type'];
557
+        $plug = $resume['dir'];
558
+        $k = $infos[$dir_type][$plug];
559
+
560
+        $plug = constant($dir_type) . $plug;
561
+        if (!isset($msg[$p])) {
562
+            if (isset($resume['erreur']) and $resume['erreur']) {
563
+                $msg[$p] = [$resume['erreur']];
564
+            }
565
+            elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
566
+                $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')];
567
+            }
568
+            elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
569
+                $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
570
+            }
571
+        } else {
572
+            foreach ($msg[$p] as $c => $l) {
573
+                $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
574
+            }
575
+        }
576
+        $erreurs[$plug] = $msg[$p];
577
+    }
578
+
579
+    ecrire_meta('plugin_erreur_activation', serialize($erreurs));
580 580
 }
581 581
 
582 582
 /**
@@ -591,25 +591,25 @@  discard block
 block discarded – undo
591 591
  *     - Liste des erreurs ou code HTML des erreurs
592 592
 **/
593 593
 function plugin_donne_erreurs($raw = false, $raz = true) {
594
-	if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
595
-		return $raw ? [] : '';
596
-	}
597
-	$list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
598
-	// Compat ancienne version
599
-	if (!$list) {
600
-		$list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation'];
601
-	} elseif (!$raw) {
602
-		foreach ($list as $plug => $msg) {
603
-			$list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug])
604
-				. '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>';
605
-		}
606
-		$list = '<ul>' . join("\n", $list) . '</ul>';
607
-	}
608
-	if ($raz) {
609
-		effacer_meta('plugin_erreur_activation');
610
-	}
611
-
612
-	return $list;
594
+    if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
595
+        return $raw ? [] : '';
596
+    }
597
+    $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
598
+    // Compat ancienne version
599
+    if (!$list) {
600
+        $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation'];
601
+    } elseif (!$raw) {
602
+        foreach ($list as $plug => $msg) {
603
+            $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug])
604
+                . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>';
605
+        }
606
+        $list = '<ul>' . join("\n", $list) . '</ul>';
607
+    }
608
+    if ($raz) {
609
+        effacer_meta('plugin_erreur_activation');
610
+    }
611
+
612
+    return $list;
613 613
 }
614 614
 
615 615
 /**
@@ -629,21 +629,21 @@  discard block
 block discarded – undo
629 629
  *
630 630
  **/
631 631
 function plugin_necessite($n, $liste, $balise = 'necessite') {
632
-	$msg = [];
633
-	foreach ($n as $need) {
634
-		$id = strtoupper($need['nom']);
635
-		$r = plugin_controler_necessite(
636
-			$liste,
637
-			$id,
638
-			$need['compatibilite'] ?? '',
639
-			$balise
640
-		);
641
-		if ($r) {
642
-			$msg[] = $r;
643
-		}
644
-	}
645
-
646
-	return $msg;
632
+    $msg = [];
633
+    foreach ($n as $need) {
634
+        $id = strtoupper($need['nom']);
635
+        $r = plugin_controler_necessite(
636
+            $liste,
637
+            $id,
638
+            $need['compatibilite'] ?? '',
639
+            $balise
640
+        );
641
+        if ($r) {
642
+            $msg[] = $r;
643
+        }
644
+    }
645
+
646
+    return $msg;
647 647
 }
648 648
 
649 649
 /**
@@ -665,19 +665,19 @@  discard block
 block discarded – undo
665 665
  *    Message d'erreur lorsque la dépendance est absente.
666 666
  **/
667 667
 function plugin_controler_necessite($liste, $nom, $intervalle, $balise) {
668
-	if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
669
-		return '';
670
-	}
671
-	// Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur
672
-	if ($balise === 'utilise' and !isset($liste[$nom])) {
673
-		return '';
674
-	}
675
-	return plugin_message_incompatibilite(
676
-		$intervalle,
677
-		(isset($liste[$nom]) ? $liste[$nom]['version'] : ''),
678
-		$nom,
679
-		$balise
680
-	);
668
+    if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
669
+        return '';
670
+    }
671
+    // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur
672
+    if ($balise === 'utilise' and !isset($liste[$nom])) {
673
+        return '';
674
+    }
675
+    return plugin_message_incompatibilite(
676
+        $intervalle,
677
+        (isset($liste[$nom]) ? $liste[$nom]['version'] : ''),
678
+        $nom,
679
+        $balise
680
+    );
681 681
 }
682 682
 
683 683
 /**
@@ -694,70 +694,70 @@  discard block
 block discarded – undo
694 694
  */
695 695
 function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) {
696 696
 
697
-	// prendre en compte les erreurs de dépendances à PHP
698
-	// ou à une extension PHP avec des messages d'erreurs dédiés.
699
-	$type = 'plugin';
700
-	if ($nom === 'SPIP') {
701
-		$type = 'spip';
702
-	} elseif ($nom === 'PHP') {
703
-		$type = 'php';
704
-	} elseif (strncmp($nom, 'PHP:', 4) === 0) {
705
-		$type = 'extension_php';
706
-		[, $nom] = explode(':', $nom, 2);
707
-	}
708
-
709
-	if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
710
-		$minimum = $regs[1];
711
-		$maximum = $regs[2];
712
-
713
-		$minimum_inclus = $intervalle[0] == '[';
714
-		$maximum_inclus = substr($intervalle, -1) == ']';
715
-
716
-		if (strlen($minimum)) {
717
-			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
718
-				return _T("plugin_${balise}_${type}", [
719
-					'plugin' => $nom,
720
-					'version' => ' &ge; ' . $minimum
721
-				]);
722
-			}
723
-			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
724
-				return _T("plugin_${balise}_${type}", [
725
-					'plugin' => $nom,
726
-					'version' => ' &gt; ' . $minimum
727
-				]);
728
-			}
729
-		}
730
-
731
-		if (strlen($maximum)) {
732
-			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
733
-				return _T("plugin_${balise}_${type}", [
734
-					'plugin' => $nom,
735
-					'version' => ' &le; ' . $maximum
736
-				]);
737
-			}
738
-			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
739
-				return _T("plugin_${balise}_plugin", [
740
-					'plugin' => $nom,
741
-					'version' => ' &lt; ' . $maximum
742
-				]);
743
-			}
744
-		}
745
-	}
746
-
747
-	// note : il ne peut pas y avoir d'erreur sur
748
-	// - un 'utilise' sans version.
749
-	// - un 'php' sans version.
750
-	return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]);
697
+    // prendre en compte les erreurs de dépendances à PHP
698
+    // ou à une extension PHP avec des messages d'erreurs dédiés.
699
+    $type = 'plugin';
700
+    if ($nom === 'SPIP') {
701
+        $type = 'spip';
702
+    } elseif ($nom === 'PHP') {
703
+        $type = 'php';
704
+    } elseif (strncmp($nom, 'PHP:', 4) === 0) {
705
+        $type = 'extension_php';
706
+        [, $nom] = explode(':', $nom, 2);
707
+    }
708
+
709
+    if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
710
+        $minimum = $regs[1];
711
+        $maximum = $regs[2];
712
+
713
+        $minimum_inclus = $intervalle[0] == '[';
714
+        $maximum_inclus = substr($intervalle, -1) == ']';
715
+
716
+        if (strlen($minimum)) {
717
+            if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
718
+                return _T("plugin_${balise}_${type}", [
719
+                    'plugin' => $nom,
720
+                    'version' => ' &ge; ' . $minimum
721
+                ]);
722
+            }
723
+            if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
724
+                return _T("plugin_${balise}_${type}", [
725
+                    'plugin' => $nom,
726
+                    'version' => ' &gt; ' . $minimum
727
+                ]);
728
+            }
729
+        }
730
+
731
+        if (strlen($maximum)) {
732
+            if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
733
+                return _T("plugin_${balise}_${type}", [
734
+                    'plugin' => $nom,
735
+                    'version' => ' &le; ' . $maximum
736
+                ]);
737
+            }
738
+            if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
739
+                return _T("plugin_${balise}_plugin", [
740
+                    'plugin' => $nom,
741
+                    'version' => ' &lt; ' . $maximum
742
+                ]);
743
+            }
744
+        }
745
+    }
746
+
747
+    // note : il ne peut pas y avoir d'erreur sur
748
+    // - un 'utilise' sans version.
749
+    // - un 'php' sans version.
750
+    return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]);
751 751
 }
752 752
 
753 753
 
754 754
 function plugin_controler_lib($lib, $url) {
755
-	/* Feature sortie du core, voir STP
755
+    /* Feature sortie du core, voir STP
756 756
 	 * if ($url) {
757 757
 		include_spip('inc/charger_plugin');
758 758
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
759 759
 	}*/
760
-	return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>";
760
+    return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>";
761 761
 }
762 762
 
763 763
 
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
  *     true si il y a eu des modifications sur la liste des plugins actifs, false sinon
773 773
  **/
774 774
 function actualise_plugins_actifs($pipe_recherche = false) {
775
-	return ecrire_plugin_actifs('', $pipe_recherche, 'force');
775
+    return ecrire_plugin_actifs('', $pipe_recherche, 'force');
776 776
 }
777 777
 
778 778
 
@@ -799,116 +799,116 @@  discard block
 block discarded – undo
799 799
  **/
800 800
 function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') {
801 801
 
802
-	// creer le repertoire cache/ si necessaire ! (installation notamment)
803
-	$cache = sous_repertoire(_DIR_CACHE, '', false, true);
804
-
805
-	// Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
806
-	if (!$cache and !spip_connect()) {
807
-		return false;
808
-	}
809
-
810
-	if ($operation != 'raz') {
811
-		$plugin_valides = liste_chemin_plugin_actifs();
812
-		$plugin_valides = is_plugin_dir($plugin_valides);
813
-		if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
814
-			$plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
815
-			$plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
816
-			$plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
817
-		}
818
-		// si des plugins sont en attentes (coches mais impossible a activer)
819
-		// on les reinjecte ici
820
-		if (
821
-			isset($GLOBALS['meta']['plugin_attente'])
822
-			and $a = unserialize($GLOBALS['meta']['plugin_attente'])
823
-		) {
824
-			$plugin_valides = $plugin_valides + liste_chemin_plugin($a);
825
-		}
826
-
827
-		if ($operation == 'ajoute') {
828
-			$plugin = array_merge($plugin_valides, $plugin);
829
-		} elseif ($operation == 'enleve') {
830
-			$plugin = array_diff($plugin_valides, $plugin);
831
-		} else {
832
-			$plugin = $plugin_valides;
833
-		}
834
-	}
835
-	$actifs_avant = $GLOBALS['meta']['plugin'] ?? '';
836
-
837
-	// si une fonction de gestion de dependances existe, l'appeler ici
838
-	if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) {
839
-		$plugin = $ajouter_dependances($plugin);
840
-	}
841
-
842
-	// recharger le xml des plugins a activer
843
-	// on force le reload ici, meme si le fichier xml n'a pas change
844
-	// pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
845
-	// pourra etre evite quand on ne supportera plus les plugin.xml
846
-	// en deplacant la detection de ces fichiers dans la compilation ci dessous
847
-	[$infos, $liste, $invalides] = liste_plugin_valides($plugin, true);
848
-	// trouver l'ordre d'activation
849
-	[$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste);
850
-	if ($invalides or $reste) {
851
-		plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
852
-	}
853
-
854
-	// Ignorer les plugins necessitant une lib absente
855
-	// et preparer la meta d'entete Http
856
-	$err = $msg = $header = [];
857
-	foreach ($plugin_valides as $p => $resume) {
858
-		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
859
-		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
860
-			$header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : '');
861
-		}
862
-		if ($resume['dir']) {
863
-			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
864
-				if (!find_in_path($l['nom'], 'lib/')) {
865
-					$err[$p] = $resume;
866
-					$msg[$p][] = $l;
867
-					unset($plugin_valides[$p]);
868
-				}
869
-			}
870
-		}
871
-	}
872
-	if ($err) {
873
-		plugins_erreurs($err, '', $infos, $msg);
874
-	}
875
-
876
-	if (isset($GLOBALS['meta']['message_crash_plugins'])) {
877
-		effacer_meta('message_crash_plugins');
878
-	}
879
-	ecrire_meta('plugin', serialize($plugin_valides));
880
-	$liste = array_diff_key($liste, $plugin_valides);
881
-	ecrire_meta('plugin_attente', serialize($liste));
882
-	$header = strtolower(implode(',', $header));
883
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
884
-		ecrire_fichier(
885
-			_DIR_VAR . 'config.txt',
886
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header
887
-		);
888
-	} else {
889
-		@unlink(_DIR_VAR . 'config.txt');
890
-	}
891
-	// generer charger_plugins_chemin.php
892
-	plugins_precompile_chemin($plugin_valides, $ordre);
893
-	// generer les fichiers
894
-	// - charger_plugins_options.php
895
-	// - charger_plugins_fonctions.php
896
-	plugins_precompile_xxxtions($plugin_valides, $ordre);
897
-	// charger les chemins des plugins et les fichiers d'options
898
-	// (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
899
-	plugins_amorcer_plugins_actifs();
900
-	// mise a jour de la matrice des pipelines
901
-	$prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
902
-	// generer le fichier _CACHE_PIPELINE
903
-	pipeline_precompile($prepend_code);
904
-
905
-	if (spip_connect()) {
906
-		// lancer et initialiser les nouveaux crons !
907
-		include_spip('inc/genie');
908
-		genie_queue_watch_dist();
909
-	}
910
-
911
-	return ($GLOBALS['meta']['plugin'] != $actifs_avant);
802
+    // creer le repertoire cache/ si necessaire ! (installation notamment)
803
+    $cache = sous_repertoire(_DIR_CACHE, '', false, true);
804
+
805
+    // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
806
+    if (!$cache and !spip_connect()) {
807
+        return false;
808
+    }
809
+
810
+    if ($operation != 'raz') {
811
+        $plugin_valides = liste_chemin_plugin_actifs();
812
+        $plugin_valides = is_plugin_dir($plugin_valides);
813
+        if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
814
+            $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
815
+            $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
816
+            $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
817
+        }
818
+        // si des plugins sont en attentes (coches mais impossible a activer)
819
+        // on les reinjecte ici
820
+        if (
821
+            isset($GLOBALS['meta']['plugin_attente'])
822
+            and $a = unserialize($GLOBALS['meta']['plugin_attente'])
823
+        ) {
824
+            $plugin_valides = $plugin_valides + liste_chemin_plugin($a);
825
+        }
826
+
827
+        if ($operation == 'ajoute') {
828
+            $plugin = array_merge($plugin_valides, $plugin);
829
+        } elseif ($operation == 'enleve') {
830
+            $plugin = array_diff($plugin_valides, $plugin);
831
+        } else {
832
+            $plugin = $plugin_valides;
833
+        }
834
+    }
835
+    $actifs_avant = $GLOBALS['meta']['plugin'] ?? '';
836
+
837
+    // si une fonction de gestion de dependances existe, l'appeler ici
838
+    if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) {
839
+        $plugin = $ajouter_dependances($plugin);
840
+    }
841
+
842
+    // recharger le xml des plugins a activer
843
+    // on force le reload ici, meme si le fichier xml n'a pas change
844
+    // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
845
+    // pourra etre evite quand on ne supportera plus les plugin.xml
846
+    // en deplacant la detection de ces fichiers dans la compilation ci dessous
847
+    [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true);
848
+    // trouver l'ordre d'activation
849
+    [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste);
850
+    if ($invalides or $reste) {
851
+        plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
852
+    }
853
+
854
+    // Ignorer les plugins necessitant une lib absente
855
+    // et preparer la meta d'entete Http
856
+    $err = $msg = $header = [];
857
+    foreach ($plugin_valides as $p => $resume) {
858
+        // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
859
+        if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
860
+            $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : '');
861
+        }
862
+        if ($resume['dir']) {
863
+            foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
864
+                if (!find_in_path($l['nom'], 'lib/')) {
865
+                    $err[$p] = $resume;
866
+                    $msg[$p][] = $l;
867
+                    unset($plugin_valides[$p]);
868
+                }
869
+            }
870
+        }
871
+    }
872
+    if ($err) {
873
+        plugins_erreurs($err, '', $infos, $msg);
874
+    }
875
+
876
+    if (isset($GLOBALS['meta']['message_crash_plugins'])) {
877
+        effacer_meta('message_crash_plugins');
878
+    }
879
+    ecrire_meta('plugin', serialize($plugin_valides));
880
+    $liste = array_diff_key($liste, $plugin_valides);
881
+    ecrire_meta('plugin_attente', serialize($liste));
882
+    $header = strtolower(implode(',', $header));
883
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
884
+        ecrire_fichier(
885
+            _DIR_VAR . 'config.txt',
886
+            (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header
887
+        );
888
+    } else {
889
+        @unlink(_DIR_VAR . 'config.txt');
890
+    }
891
+    // generer charger_plugins_chemin.php
892
+    plugins_precompile_chemin($plugin_valides, $ordre);
893
+    // generer les fichiers
894
+    // - charger_plugins_options.php
895
+    // - charger_plugins_fonctions.php
896
+    plugins_precompile_xxxtions($plugin_valides, $ordre);
897
+    // charger les chemins des plugins et les fichiers d'options
898
+    // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
899
+    plugins_amorcer_plugins_actifs();
900
+    // mise a jour de la matrice des pipelines
901
+    $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
902
+    // generer le fichier _CACHE_PIPELINE
903
+    pipeline_precompile($prepend_code);
904
+
905
+    if (spip_connect()) {
906
+        // lancer et initialiser les nouveaux crons !
907
+        include_spip('inc/genie');
908
+        genie_queue_watch_dist();
909
+    }
910
+
911
+    return ($GLOBALS['meta']['plugin'] != $actifs_avant);
912 912
 }
913 913
 
914 914
 /**
@@ -927,74 +927,74 @@  discard block
 block discarded – undo
927 927
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
928 928
 **/
929 929
 function plugins_precompile_chemin($plugin_valides, $ordre) {
930
-	$chemins = [
931
-		'public' => [],
932
-		'prive' => []
933
-	];
934
-	$contenu = '';
935
-	foreach ($ordre as $p => $info) {
936
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
937
-		if (isset($plugin_valides[$p])) {
938
-			$dir_type = $plugin_valides[$p]['dir_type'];
939
-			$plug = $plugin_valides[$p]['dir'];
940
-			// definir le plugin, donc le path avant l'include du fichier options
941
-			// permet de faire des include_spip pour attraper un inc_ du plugin
942
-
943
-			$dir = $dir_type . ".'" . $plug . "/'";
944
-
945
-			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
946
-			if (
947
-				$prefix !== 'SPIP'
948
-				and strpos($dir, ':') === false // exclure le cas des procure:
949
-			) {
950
-				$contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
951
-				if (!$info['chemin']) {
952
-					$chemins['public'][] = "_DIR_PLUGIN_$prefix";
953
-					$chemins['prive'][] = "_DIR_PLUGIN_$prefix";
954
-					if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
955
-						$chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
956
-					}
957
-				}
958
-				else {
959
-					foreach ($info['chemin'] as $chemin) {
960
-						if (
961
-							!isset($chemin['version']) or plugin_version_compatible(
962
-								$chemin['version'],
963
-								$GLOBALS['spip_version_branche'],
964
-								'spip'
965
-							)
966
-						) {
967
-							$dir = $chemin['path'];
968
-							if (strlen($dir) and $dir[0] == '/') {
969
-								$dir = substr($dir, 1);
970
-							}
971
-							if (strlen($dir) and $dir == './') {
972
-								$dir = '';
973
-							}
974
-							if (strlen($dir)) {
975
-								$dir = rtrim($dir, '/') . '/';
976
-							}
977
-							if (!isset($chemin['type']) or $chemin['type'] == 'public') {
978
-								$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
979
-							}
980
-							if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
981
-								$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
982
-							}
983
-						}
984
-					}
985
-				}
986
-			}
987
-		}
988
-	}
989
-	if (count($chemins['public']) or count($chemins['prive'])) {
990
-		$contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode(
991
-			',',
992
-			array_reverse($chemins['public'])
993
-		) . "]);\n"
994
-			. 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n";
995
-	}
996
-
997
-	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
930
+    $chemins = [
931
+        'public' => [],
932
+        'prive' => []
933
+    ];
934
+    $contenu = '';
935
+    foreach ($ordre as $p => $info) {
936
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
937
+        if (isset($plugin_valides[$p])) {
938
+            $dir_type = $plugin_valides[$p]['dir_type'];
939
+            $plug = $plugin_valides[$p]['dir'];
940
+            // definir le plugin, donc le path avant l'include du fichier options
941
+            // permet de faire des include_spip pour attraper un inc_ du plugin
942
+
943
+            $dir = $dir_type . ".'" . $plug . "/'";
944
+
945
+            $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
946
+            if (
947
+                $prefix !== 'SPIP'
948
+                and strpos($dir, ':') === false // exclure le cas des procure:
949
+            ) {
950
+                $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
951
+                if (!$info['chemin']) {
952
+                    $chemins['public'][] = "_DIR_PLUGIN_$prefix";
953
+                    $chemins['prive'][] = "_DIR_PLUGIN_$prefix";
954
+                    if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
955
+                        $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
956
+                    }
957
+                }
958
+                else {
959
+                    foreach ($info['chemin'] as $chemin) {
960
+                        if (
961
+                            !isset($chemin['version']) or plugin_version_compatible(
962
+                                $chemin['version'],
963
+                                $GLOBALS['spip_version_branche'],
964
+                                'spip'
965
+                            )
966
+                        ) {
967
+                            $dir = $chemin['path'];
968
+                            if (strlen($dir) and $dir[0] == '/') {
969
+                                $dir = substr($dir, 1);
970
+                            }
971
+                            if (strlen($dir) and $dir == './') {
972
+                                $dir = '';
973
+                            }
974
+                            if (strlen($dir)) {
975
+                                $dir = rtrim($dir, '/') . '/';
976
+                            }
977
+                            if (!isset($chemin['type']) or $chemin['type'] == 'public') {
978
+                                $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
979
+                            }
980
+                            if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
981
+                                $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
982
+                            }
983
+                        }
984
+                    }
985
+                }
986
+            }
987
+        }
988
+    }
989
+    if (count($chemins['public']) or count($chemins['prive'])) {
990
+        $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode(
991
+            ',',
992
+            array_reverse($chemins['public'])
993
+        ) . "]);\n"
994
+            . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n";
995
+    }
996
+
997
+    ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
998 998
 }
999 999
 
1000 1000
 /**
@@ -1012,67 +1012,67 @@  discard block
 block discarded – undo
1012 1012
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
1013 1013
 **/
1014 1014
 function plugins_precompile_xxxtions($plugin_valides, $ordre) {
1015
-	$contenu = ['options' => '', 'fonctions' => ''];
1016
-	$boutons = [];
1017
-	$onglets = [];
1018
-	$sign = '';
1019
-
1020
-	foreach ($ordre as $p => $info) {
1021
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1022
-		if (isset($plugin_valides[$p])) {
1023
-			$dir_type = $plugin_valides[$p]['dir_type'];
1024
-			$plug = $plugin_valides[$p]['dir'];
1025
-			$dir = constant($dir_type);
1026
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1027
-			if ($info['menu']) {
1028
-				$boutons = array_merge($boutons, $info['menu']);
1029
-			}
1030
-			if ($info['onglet']) {
1031
-				$onglets = array_merge($onglets, $info['onglet']);
1032
-			}
1033
-			foreach ($contenu as $charge => $v) {
1034
-				// si pas declare/detecte a la lecture du paquet.xml,
1035
-				// detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1036
-				// donc ni sa relecture, ni sa detection
1037
-				if (
1038
-					!isset($info[$charge])
1039
-					and $dir // exclure le cas du plugin "SPIP"
1040
-					and strpos($dir, ':') === false // exclure le cas des procure:
1041
-					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1042
-				) {
1043
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) {
1044
-						$info[$charge] = [$file];
1045
-					}
1046
-				}
1047
-				if (isset($info[$charge])) {
1048
-					$files = $info[$charge];
1049
-					foreach ($files as $k => $file) {
1050
-						// on genere un if file_exists devant chaque include
1051
-						// pour pouvoir garder le meme niveau d'erreur general
1052
-						$file = trim($file);
1053
-						if (
1054
-							!is_readable("$dir$plug/$file")
1055
-							// uniquement pour les paquet.xml
1056
-							and file_exists("$dir$plug/paquet.xml")
1057
-						) {
1058
-							unset($info[$charge][$k]);
1059
-						} else {
1060
-							$_file = $root_dir_type . ".'$plug/$file'";
1061
-							$contenu[$charge] .= "include_once_check($_file);\n";
1062
-						}
1063
-					}
1064
-				}
1065
-			}
1066
-			$sign .= md5(serialize($info));
1067
-		}
1068
-	}
1069
-
1070
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1071
-	$contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons)
1072
-		. plugin_ongletbouton('onglets_plugins', $onglets);
1073
-
1074
-	ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1075
-	ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1015
+    $contenu = ['options' => '', 'fonctions' => ''];
1016
+    $boutons = [];
1017
+    $onglets = [];
1018
+    $sign = '';
1019
+
1020
+    foreach ($ordre as $p => $info) {
1021
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1022
+        if (isset($plugin_valides[$p])) {
1023
+            $dir_type = $plugin_valides[$p]['dir_type'];
1024
+            $plug = $plugin_valides[$p]['dir'];
1025
+            $dir = constant($dir_type);
1026
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1027
+            if ($info['menu']) {
1028
+                $boutons = array_merge($boutons, $info['menu']);
1029
+            }
1030
+            if ($info['onglet']) {
1031
+                $onglets = array_merge($onglets, $info['onglet']);
1032
+            }
1033
+            foreach ($contenu as $charge => $v) {
1034
+                // si pas declare/detecte a la lecture du paquet.xml,
1035
+                // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1036
+                // donc ni sa relecture, ni sa detection
1037
+                if (
1038
+                    !isset($info[$charge])
1039
+                    and $dir // exclure le cas du plugin "SPIP"
1040
+                    and strpos($dir, ':') === false // exclure le cas des procure:
1041
+                    and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1042
+                ) {
1043
+                    if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) {
1044
+                        $info[$charge] = [$file];
1045
+                    }
1046
+                }
1047
+                if (isset($info[$charge])) {
1048
+                    $files = $info[$charge];
1049
+                    foreach ($files as $k => $file) {
1050
+                        // on genere un if file_exists devant chaque include
1051
+                        // pour pouvoir garder le meme niveau d'erreur general
1052
+                        $file = trim($file);
1053
+                        if (
1054
+                            !is_readable("$dir$plug/$file")
1055
+                            // uniquement pour les paquet.xml
1056
+                            and file_exists("$dir$plug/paquet.xml")
1057
+                        ) {
1058
+                            unset($info[$charge][$k]);
1059
+                        } else {
1060
+                            $_file = $root_dir_type . ".'$plug/$file'";
1061
+                            $contenu[$charge] .= "include_once_check($_file);\n";
1062
+                        }
1063
+                    }
1064
+                }
1065
+            }
1066
+            $sign .= md5(serialize($info));
1067
+        }
1068
+    }
1069
+
1070
+    $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1071
+    $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons)
1072
+        . plugin_ongletbouton('onglets_plugins', $onglets);
1073
+
1074
+    ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1075
+    ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1076 1076
 }
1077 1077
 
1078 1078
 /**
@@ -1091,24 +1091,24 @@  discard block
 block discarded – undo
1091 1091
  * @return string Code php
1092 1092
  */
1093 1093
 function plugin_ongletbouton($nom, $val) {
1094
-	if (!$val) {
1095
-		$val = [];
1096
-	}
1097
-
1098
-	$val = serialize($val);
1099
-	$md5 = md5($val);
1100
-
1101
-	if (!defined("_UPDATED_$nom")) {
1102
-		define("_UPDATED_$nom", $val);
1103
-		define("_UPDATED_md5_$nom", $md5);
1104
-	}
1105
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1106
-
1107
-	return
1108
-		"if (!function_exists('$nom')) {\n"
1109
-		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1110
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1111
-		. "}\n";
1094
+    if (!$val) {
1095
+        $val = [];
1096
+    }
1097
+
1098
+    $val = serialize($val);
1099
+    $md5 = md5($val);
1100
+
1101
+    if (!defined("_UPDATED_$nom")) {
1102
+        define("_UPDATED_$nom", $val);
1103
+        define("_UPDATED_md5_$nom", $md5);
1104
+    }
1105
+    $val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1106
+
1107
+    return
1108
+        "if (!function_exists('$nom')) {\n"
1109
+        . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1110
+        . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1111
+        . "}\n";
1112 1112
 }
1113 1113
 
1114 1114
 /**
@@ -1123,15 +1123,15 @@  discard block
 block discarded – undo
1123 1123
 **/
1124 1124
 function plugins_amorcer_plugins_actifs() {
1125 1125
 
1126
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1127
-		include_once(_CACHE_PLUGINS_PATH);
1128
-	}
1126
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1127
+        include_once(_CACHE_PLUGINS_PATH);
1128
+    }
1129 1129
 
1130
-	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1131
-		include_once(_CACHE_PLUGINS_OPT);
1132
-	} else {
1133
-		spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT);
1134
-	}
1130
+    if (@is_readable(_CACHE_PLUGINS_OPT)) {
1131
+        include_once(_CACHE_PLUGINS_OPT);
1132
+    } else {
1133
+        spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT);
1134
+    }
1135 1135
 }
1136 1136
 
1137 1137
 /**
@@ -1154,140 +1154,140 @@  discard block
 block discarded – undo
1154 1154
  *     Couples (nom du pipeline => Code PHP à insérer au début du pipeline)
1155 1155
 **/
1156 1156
 function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) {
1157
-	static $liste_pipe_manquants = [];
1158
-	if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1159
-		$liste_pipe_manquants[] = $pipe_recherche;
1160
-	}
1161
-
1162
-	$prepend_code = [];
1163
-
1164
-	foreach ($ordre as $p => $info) {
1165
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1166
-		if (isset($plugin_valides[$p])) {
1167
-			$dir_type = $plugin_valides[$p]['dir_type'];
1168
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1169
-			$plug = $plugin_valides[$p]['dir'];
1170
-			$prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_');
1171
-			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1172
-				foreach ($info['pipeline'] as $pipe) {
1173
-					$nom = $pipe['nom'];
1174
-					if (isset($pipe['action'])) {
1175
-						$action = $pipe['action'];
1176
-					} else {
1177
-						$action = $nom;
1178
-					}
1179
-					$nomlower = strtolower($nom);
1180
-					if (
1181
-						$nomlower != $nom
1182
-						and isset($GLOBALS['spip_pipeline'][$nom])
1183
-						and !isset($GLOBALS['spip_pipeline'][$nomlower])
1184
-					) {
1185
-						$GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1186
-						unset($GLOBALS['spip_pipeline'][$nom]);
1187
-					}
1188
-					$nom = $nomlower;
1189
-					// une action vide est une declaration qui ne doit pas etre compilee !
1190
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel
1191
-					$GLOBALS['spip_pipeline'][$nom] = '';
1192
-					}
1193
-					if ($action) {
1194
-						if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) {
1195
-							$GLOBALS['spip_pipeline'][$nom] = preg_replace(
1196
-								',(\|\||$),',
1197
-								"|$prefix$action\\1",
1198
-								$GLOBALS['spip_pipeline'][$nom],
1199
-								1
1200
-							);
1201
-						}
1202
-						if (isset($pipe['inclure'])) {
1203
-							$GLOBALS['spip_matrice']["$prefix$action"] =
1204
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1205
-						}
1206
-					}
1207
-				}
1208
-			}
1209
-			if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) {
1210
-				if (!isset($prepend_code['taches_generales_cron'])) {
1211
-					$prepend_code['taches_generales_cron'] = '';
1212
-				}
1213
-				foreach ($info['genie'] as $genie) {
1214
-					$nom = $prefix . $genie['nom'];
1215
-					$periode = max(60, intval($genie['periode']));
1216
-					if (charger_fonction($nom, 'genie', true)) {
1217
-						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1218
-					} else {
1219
-						spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1220
-					}
1221
-				}
1222
-			}
1223
-			if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) {
1224
-				if (!isset($prepend_code['insert_head_css'])) {
1225
-					$prepend_code['insert_head_css'] = '';
1226
-				}
1227
-				if (!isset($prepend_code['header_prive_css'])) {
1228
-					$prepend_code['header_prive_css'] = '';
1229
-				}
1230
-				foreach ($info['style'] as $style) {
1231
-					if (isset($style['path']) and $style['path']) {
1232
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1233
-					} else {
1234
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1235
-					}
1236
-					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1237
-					if (isset($style['media']) and strlen($style['media'])) {
1238
-						$code .= ' media="' . addslashes($style['media']) . '"';
1239
-					}
1240
-					$code .= "/>';\n";
1241
-					if ($style['type'] != 'prive') {
1242
-						$prepend_code['insert_head_css'] .= $code;
1243
-					}
1244
-					if ($style['type'] != 'public') {
1245
-						$prepend_code['header_prive_css'] .= $code;
1246
-					}
1247
-				}
1248
-			}
1249
-			if (!isset($prepend_code['insert_head'])) {
1250
-				$prepend_code['insert_head'] = '';
1251
-			}
1252
-			if (!isset($prepend_code['header_prive'])) {
1253
-				$prepend_code['header_prive'] = '';
1254
-			}
1255
-			if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) {
1256
-				foreach ($info['script'] as $script) {
1257
-					if (isset($script['path']) and $script['path']) {
1258
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1259
-					} else {
1260
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1261
-					}
1262
-					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1263
-					if ($script['type'] != 'prive') {
1264
-						$prepend_code['insert_head'] .= $code;
1265
-					}
1266
-					if ($script['type'] != 'public') {
1267
-						$prepend_code['header_prive'] .= $code;
1268
-					}
1269
-				}
1270
-			}
1271
-		}
1272
-	}
1273
-
1274
-	$prepend_code['insert_head'] =
1275
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1276
-		. "\$val = minipipe('f_jQuery', \$val);\n"
1277
-		. $prepend_code['insert_head'];
1278
-	$prepend_code['header_prive'] =
1279
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1280
-		. "\$val = minipipe('f_jQuery_prive', \$val);\n"
1281
-		. $prepend_code['header_prive'];
1282
-
1283
-	// on ajoute les pipe qui ont ete recenses manquants
1284
-	foreach ($liste_pipe_manquants as $add_pipe) {
1285
-		if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1286
-			$GLOBALS['spip_pipeline'][$add_pipe] = '';
1287
-		}
1288
-	}
1289
-
1290
-	return $prepend_code;
1157
+    static $liste_pipe_manquants = [];
1158
+    if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1159
+        $liste_pipe_manquants[] = $pipe_recherche;
1160
+    }
1161
+
1162
+    $prepend_code = [];
1163
+
1164
+    foreach ($ordre as $p => $info) {
1165
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1166
+        if (isset($plugin_valides[$p])) {
1167
+            $dir_type = $plugin_valides[$p]['dir_type'];
1168
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1169
+            $plug = $plugin_valides[$p]['dir'];
1170
+            $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_');
1171
+            if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1172
+                foreach ($info['pipeline'] as $pipe) {
1173
+                    $nom = $pipe['nom'];
1174
+                    if (isset($pipe['action'])) {
1175
+                        $action = $pipe['action'];
1176
+                    } else {
1177
+                        $action = $nom;
1178
+                    }
1179
+                    $nomlower = strtolower($nom);
1180
+                    if (
1181
+                        $nomlower != $nom
1182
+                        and isset($GLOBALS['spip_pipeline'][$nom])
1183
+                        and !isset($GLOBALS['spip_pipeline'][$nomlower])
1184
+                    ) {
1185
+                        $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1186
+                        unset($GLOBALS['spip_pipeline'][$nom]);
1187
+                    }
1188
+                    $nom = $nomlower;
1189
+                    // une action vide est une declaration qui ne doit pas etre compilee !
1190
+                    if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel
1191
+                    $GLOBALS['spip_pipeline'][$nom] = '';
1192
+                    }
1193
+                    if ($action) {
1194
+                        if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) {
1195
+                            $GLOBALS['spip_pipeline'][$nom] = preg_replace(
1196
+                                ',(\|\||$),',
1197
+                                "|$prefix$action\\1",
1198
+                                $GLOBALS['spip_pipeline'][$nom],
1199
+                                1
1200
+                            );
1201
+                        }
1202
+                        if (isset($pipe['inclure'])) {
1203
+                            $GLOBALS['spip_matrice']["$prefix$action"] =
1204
+                                "$root_dir_type:$plug/" . $pipe['inclure'];
1205
+                        }
1206
+                    }
1207
+                }
1208
+            }
1209
+            if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) {
1210
+                if (!isset($prepend_code['taches_generales_cron'])) {
1211
+                    $prepend_code['taches_generales_cron'] = '';
1212
+                }
1213
+                foreach ($info['genie'] as $genie) {
1214
+                    $nom = $prefix . $genie['nom'];
1215
+                    $periode = max(60, intval($genie['periode']));
1216
+                    if (charger_fonction($nom, 'genie', true)) {
1217
+                        $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1218
+                    } else {
1219
+                        spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1220
+                    }
1221
+                }
1222
+            }
1223
+            if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) {
1224
+                if (!isset($prepend_code['insert_head_css'])) {
1225
+                    $prepend_code['insert_head_css'] = '';
1226
+                }
1227
+                if (!isset($prepend_code['header_prive_css'])) {
1228
+                    $prepend_code['header_prive_css'] = '';
1229
+                }
1230
+                foreach ($info['style'] as $style) {
1231
+                    if (isset($style['path']) and $style['path']) {
1232
+                        $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1233
+                    } else {
1234
+                        $code = "if (\$f='" . addslashes($style['url']) . "') ";
1235
+                    }
1236
+                    $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1237
+                    if (isset($style['media']) and strlen($style['media'])) {
1238
+                        $code .= ' media="' . addslashes($style['media']) . '"';
1239
+                    }
1240
+                    $code .= "/>';\n";
1241
+                    if ($style['type'] != 'prive') {
1242
+                        $prepend_code['insert_head_css'] .= $code;
1243
+                    }
1244
+                    if ($style['type'] != 'public') {
1245
+                        $prepend_code['header_prive_css'] .= $code;
1246
+                    }
1247
+                }
1248
+            }
1249
+            if (!isset($prepend_code['insert_head'])) {
1250
+                $prepend_code['insert_head'] = '';
1251
+            }
1252
+            if (!isset($prepend_code['header_prive'])) {
1253
+                $prepend_code['header_prive'] = '';
1254
+            }
1255
+            if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) {
1256
+                foreach ($info['script'] as $script) {
1257
+                    if (isset($script['path']) and $script['path']) {
1258
+                        $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1259
+                    } else {
1260
+                        $code = "if (\$f='" . addslashes($script['url']) . "') ";
1261
+                    }
1262
+                    $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1263
+                    if ($script['type'] != 'prive') {
1264
+                        $prepend_code['insert_head'] .= $code;
1265
+                    }
1266
+                    if ($script['type'] != 'public') {
1267
+                        $prepend_code['header_prive'] .= $code;
1268
+                    }
1269
+                }
1270
+            }
1271
+        }
1272
+    }
1273
+
1274
+    $prepend_code['insert_head'] =
1275
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1276
+        . "\$val = minipipe('f_jQuery', \$val);\n"
1277
+        . $prepend_code['insert_head'];
1278
+    $prepend_code['header_prive'] =
1279
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1280
+        . "\$val = minipipe('f_jQuery_prive', \$val);\n"
1281
+        . $prepend_code['header_prive'];
1282
+
1283
+    // on ajoute les pipe qui ont ete recenses manquants
1284
+    foreach ($liste_pipe_manquants as $add_pipe) {
1285
+        if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1286
+            $GLOBALS['spip_pipeline'][$add_pipe] = '';
1287
+        }
1288
+    }
1289
+
1290
+    return $prepend_code;
1291 1291
 }
1292 1292
 
1293 1293
 /**
@@ -1314,62 +1314,62 @@  discard block
 block discarded – undo
1314 1314
 **/
1315 1315
 function pipeline_precompile($prepend_code = []) {
1316 1316
 
1317
-	$all_pipes = $all_pipes_end = '';
1318
-	if (!empty($GLOBALS['spip_pipeline']['all'])) {
1319
-		$a = explode('||', $GLOBALS['spip_pipeline']['all'], 2);
1320
-		unset($GLOBALS['spip_pipeline']['all']);
1321
-		$all_pipes = trim(array_shift($a));
1322
-		if ($all_pipes) {
1323
-			$all_pipes = '|' . ltrim($all_pipes, '|');
1324
-		}
1325
-		if (count($a)) {
1326
-			$all_pipes_end = '||' . array_shift($a);
1327
-		}
1328
-	}
1329
-	$content = '';
1330
-	foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1331
-		$s_inc = '';
1332
-		$s_call = '';
1333
-		if ($all_pipes) {
1334
-			$pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1);
1335
-		}
1336
-		if ($all_pipes_end) {
1337
-			$pipeline .= $all_pipes_end;
1338
-		}
1339
-		$pipe = array_filter(explode('|', $pipeline));
1340
-		// Eclater le pipeline en filtres et appliquer chaque filtre
1341
-		foreach ($pipe as $fonc) {
1342
-			$fonc = trim($fonc);
1343
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1344
-			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1345
-				$file = $GLOBALS['spip_matrice'][$fonc];
1346
-				$file = "'$file'";
1347
-				// si un _DIR_XXX: est dans la chaine, on extrait la constante
1348
-				if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) {
1349
-					$dir = $regs[1];
1350
-					$root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1351
-					if (defined($root_dir)) {
1352
-						$dir = $root_dir;
1353
-					}
1354
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1355
-					$file = str_replace("''.", '', $file);
1356
-					$file = str_replace(constant($dir), '', $file);
1357
-				}
1358
-				$s_inc .= "include_once_check($file);\n";
1359
-			}
1360
-		}
1361
-		if (strlen($s_inc)) {
1362
-			$s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1363
-		}
1364
-		$content .= "// Pipeline $action \n"
1365
-			. "function execute_pipeline_$action(&\$val){\n"
1366
-			. $s_inc
1367
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1368
-			. $s_call
1369
-			. "return \$val;\n}\n";
1370
-	}
1371
-	ecrire_fichier_php(_CACHE_PIPELINES, $content);
1372
-	clear_path_cache();
1317
+    $all_pipes = $all_pipes_end = '';
1318
+    if (!empty($GLOBALS['spip_pipeline']['all'])) {
1319
+        $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2);
1320
+        unset($GLOBALS['spip_pipeline']['all']);
1321
+        $all_pipes = trim(array_shift($a));
1322
+        if ($all_pipes) {
1323
+            $all_pipes = '|' . ltrim($all_pipes, '|');
1324
+        }
1325
+        if (count($a)) {
1326
+            $all_pipes_end = '||' . array_shift($a);
1327
+        }
1328
+    }
1329
+    $content = '';
1330
+    foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1331
+        $s_inc = '';
1332
+        $s_call = '';
1333
+        if ($all_pipes) {
1334
+            $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1);
1335
+        }
1336
+        if ($all_pipes_end) {
1337
+            $pipeline .= $all_pipes_end;
1338
+        }
1339
+        $pipe = array_filter(explode('|', $pipeline));
1340
+        // Eclater le pipeline en filtres et appliquer chaque filtre
1341
+        foreach ($pipe as $fonc) {
1342
+            $fonc = trim($fonc);
1343
+            $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1344
+            if (isset($GLOBALS['spip_matrice'][$fonc])) {
1345
+                $file = $GLOBALS['spip_matrice'][$fonc];
1346
+                $file = "'$file'";
1347
+                // si un _DIR_XXX: est dans la chaine, on extrait la constante
1348
+                if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) {
1349
+                    $dir = $regs[1];
1350
+                    $root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1351
+                    if (defined($root_dir)) {
1352
+                        $dir = $root_dir;
1353
+                    }
1354
+                    $file = str_replace($regs[0], "'." . $dir . ".'", $file);
1355
+                    $file = str_replace("''.", '', $file);
1356
+                    $file = str_replace(constant($dir), '', $file);
1357
+                }
1358
+                $s_inc .= "include_once_check($file);\n";
1359
+            }
1360
+        }
1361
+        if (strlen($s_inc)) {
1362
+            $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1363
+        }
1364
+        $content .= "// Pipeline $action \n"
1365
+            . "function execute_pipeline_$action(&\$val){\n"
1366
+            . $s_inc
1367
+            . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1368
+            . $s_call
1369
+            . "return \$val;\n}\n";
1370
+    }
1371
+    ecrire_fichier_php(_CACHE_PIPELINES, $content);
1372
+    clear_path_cache();
1373 1373
 }
1374 1374
 
1375 1375
 
@@ -1382,12 +1382,12 @@  discard block
 block discarded – undo
1382 1382
  *     true si le plugin est actif, false sinon
1383 1383
 **/
1384 1384
 function plugin_est_installe($plug_path) {
1385
-	$plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : [];
1386
-	if (!$plugin_installes) {
1387
-		return false;
1388
-	}
1385
+    $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : [];
1386
+    if (!$plugin_installes) {
1387
+        return false;
1388
+    }
1389 1389
 
1390
-	return in_array($plug_path, $plugin_installes);
1390
+    return in_array($plug_path, $plugin_installes);
1391 1391
 }
1392 1392
 
1393 1393
 
@@ -1400,46 +1400,46 @@  discard block
 block discarded – undo
1400 1400
  * @uses plugins_installer_dist()
1401 1401
  **/
1402 1402
 function plugin_installes_meta() {
1403
-	if (isset($GLOBALS['fichier_php_compile_recent'])) {
1404
-		// attendre eventuellement l'invalidation du cache opcode
1405
-		spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1406
-	}
1407
-
1408
-	$installer_plugins = charger_fonction('installer', 'plugins');
1409
-	$meta_plug_installes = [];
1410
-	foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1411
-		if ($plug = $resume['dir']) {
1412
-			$infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1413
-			if ($infos) {
1414
-				if (!is_array($infos) or $infos['install_test'][0]) {
1415
-					$meta_plug_installes[] = $plug;
1416
-				}
1417
-				if (is_array($infos)) {
1418
-					[$ok, $trace] = $infos['install_test'];
1419
-					$titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]);
1420
-					$result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec'));
1421
-					if (_IS_CLI) {
1422
-						include_spip('inc/filtres');
1423
-						$trace = ltrim(textebrut($trace) . "\n" . $result);
1424
-						$trace = '    ' . str_replace("\n", "\n    ", $trace);
1425
-						echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1426
-						  $trace,
1427
-						  "\n";
1428
-					}
1429
-					else {
1430
-						include_spip('inc/filtres_boites');
1431
-						echo "<div class='install-plugins svp_retour'>"
1432
-							. boite_ouvrir($titre, ($ok ? 'success' : 'error'))
1433
-							. $trace
1434
-							. "<div class='result'>$result</div>"
1435
-							. boite_fermer()
1436
-							. '</div>';
1437
-					}
1438
-				}
1439
-			}
1440
-		}
1441
-	}
1442
-	ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1403
+    if (isset($GLOBALS['fichier_php_compile_recent'])) {
1404
+        // attendre eventuellement l'invalidation du cache opcode
1405
+        spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1406
+    }
1407
+
1408
+    $installer_plugins = charger_fonction('installer', 'plugins');
1409
+    $meta_plug_installes = [];
1410
+    foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1411
+        if ($plug = $resume['dir']) {
1412
+            $infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1413
+            if ($infos) {
1414
+                if (!is_array($infos) or $infos['install_test'][0]) {
1415
+                    $meta_plug_installes[] = $plug;
1416
+                }
1417
+                if (is_array($infos)) {
1418
+                    [$ok, $trace] = $infos['install_test'];
1419
+                    $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]);
1420
+                    $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec'));
1421
+                    if (_IS_CLI) {
1422
+                        include_spip('inc/filtres');
1423
+                        $trace = ltrim(textebrut($trace) . "\n" . $result);
1424
+                        $trace = '    ' . str_replace("\n", "\n    ", $trace);
1425
+                        echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1426
+                            $trace,
1427
+                            "\n";
1428
+                    }
1429
+                    else {
1430
+                        include_spip('inc/filtres_boites');
1431
+                        echo "<div class='install-plugins svp_retour'>"
1432
+                            . boite_ouvrir($titre, ($ok ? 'success' : 'error'))
1433
+                            . $trace
1434
+                            . "<div class='result'>$result</div>"
1435
+                            . boite_fermer()
1436
+                            . '</div>';
1437
+                    }
1438
+                }
1439
+            }
1440
+        }
1441
+    }
1442
+    ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1443 1443
 }
1444 1444
 
1445 1445
 /**
@@ -1453,29 +1453,29 @@  discard block
 block discarded – undo
1453 1453
  *     Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante
1454 1454
 **/
1455 1455
 function ecrire_fichier_php($nom, $contenu, $comment = '') {
1456
-	if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1457
-		$GLOBALS['fichier_php_compile_recent'] = 0;
1458
-	}
1459
-
1460
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1461
-	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1462
-	// si pas de modif on ne touche pas au fichier initial
1463
-	if (file_exists($nom)) {
1464
-		if (substr($nom, -4) == '.php') {
1465
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1466
-		}
1467
-		else {
1468
-			$fichier_tmp = $nom . '.tmp';
1469
-		}
1470
-		file_put_contents($fichier_tmp, $contenu);
1471
-		if (md5_file($nom) == md5_file($fichier_tmp)) {
1472
-			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1473
-			@unlink($fichier_tmp);
1474
-			return;
1475
-		}
1476
-		@unlink($fichier_tmp);
1477
-	}
1478
-	ecrire_fichier($nom, $contenu);
1479
-	$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1480
-	spip_clear_opcode_cache(realpath($nom));
1456
+    if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1457
+        $GLOBALS['fichier_php_compile_recent'] = 0;
1458
+    }
1459
+
1460
+    $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1461
+    // si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1462
+    // si pas de modif on ne touche pas au fichier initial
1463
+    if (file_exists($nom)) {
1464
+        if (substr($nom, -4) == '.php') {
1465
+            $fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1466
+        }
1467
+        else {
1468
+            $fichier_tmp = $nom . '.tmp';
1469
+        }
1470
+        file_put_contents($fichier_tmp, $contenu);
1471
+        if (md5_file($nom) == md5_file($fichier_tmp)) {
1472
+            $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1473
+            @unlink($fichier_tmp);
1474
+            return;
1475
+        }
1476
+        @unlink($fichier_tmp);
1477
+    }
1478
+    ecrire_fichier($nom, $contenu);
1479
+    $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1480
+    spip_clear_opcode_cache(realpath($nom));
1481 1481
 }
Please login to merge, or discard this patch.
ecrire/inc/chercher_logo.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
  * @package SPIP\Core\Logos
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
  **/
38 38
 function inc_chercher_logo_dist($id, $_id_objet, $mode = 'on', $compat_old_logos = true) {
39 39
 
40
-	$mode = preg_replace(',\W,', '', $mode);
41
-	if ($mode) {
42
-		// chercher dans la base
43
-		$mode_document = 'logo' . $mode;
44
-		$objet = objet_type($_id_objet);
45
-		$doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id));
46
-		if ($doc) {
47
-			include_spip('inc/documents');
48
-			$d = get_spip_doc($doc['fichier']);
49
-			return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc];
50
-		}
40
+    $mode = preg_replace(',\W,', '', $mode);
41
+    if ($mode) {
42
+        // chercher dans la base
43
+        $mode_document = 'logo' . $mode;
44
+        $objet = objet_type($_id_objet);
45
+        $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id));
46
+        if ($doc) {
47
+            include_spip('inc/documents');
48
+            $d = get_spip_doc($doc['fichier']);
49
+            return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc];
50
+        }
51 51
 
52
-		# deprecated TODO remove
53
-		if ($compat_old_logos) {
54
-			# attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval()
55
-			$type = type_du_logo($_id_objet);
56
-			$nom = $type . $mode . intval($id);
52
+        # deprecated TODO remove
53
+        if ($compat_old_logos) {
54
+            # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval()
55
+            $type = type_du_logo($_id_objet);
56
+            $nom = $type . $mode . intval($id);
57 57
 
58
-			foreach ($GLOBALS['formats_logos'] as $format) {
59
-				if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) {
60
-					return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)];
61
-				}
62
-			}
63
-		}
64
-	}
58
+            foreach ($GLOBALS['formats_logos'] as $format) {
59
+                if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) {
60
+                    return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)];
61
+                }
62
+            }
63
+        }
64
+    }
65 65
 
66
-	# coherence de type pour servir comme filtre (formulaire_login)
67
-	return [];
66
+    # coherence de type pour servir comme filtre (formulaire_login)
67
+    return [];
68 68
 }
69 69
 
70 70
 /**
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
  * @deprecated 4.0 MAIS NE PAS SUPPRIMER CAR SERT POUR L'UPGRADE des logos et leur mise en base
84 84
  **/
85 85
 function type_du_logo($_id_objet) {
86
-	return $GLOBALS['table_logos'][$_id_objet] ?? objet_type(preg_replace(',^id_,', '', $_id_objet));
86
+    return $GLOBALS['table_logos'][$_id_objet] ?? objet_type(preg_replace(',^id_,', '', $_id_objet));
87 87
 }
88 88
 
89 89
 // Exceptions standards (historique)
90 90
 $GLOBALS['table_logos'] = [
91
-	'id_article' => 'art',
92
-	'id_auteur' => 'aut',
93
-	'id_rubrique' => 'rub',
94
-	'id_groupe' => 'groupe',
91
+    'id_article' => 'art',
92
+    'id_auteur' => 'aut',
93
+    'id_rubrique' => 'rub',
94
+    'id_groupe' => 'groupe',
95 95
 ];
Please login to merge, or discard this patch.
ecrire/inc/traduire.php 1 patch
Indentation   +195 added lines, -195 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
 /**
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
  *     Liste des fichiers de langue trouvés, dans l'ordre des chemins
39 39
  */
40 40
 function find_langs_in_path($file, $dirname = 'lang') {
41
-	static $dirs = [];
42
-	$liste = [];
43
-	foreach (creer_chemin() as $dir) {
44
-		if (!isset($dirs[$a = $dir . $dirname])) {
45
-			$dirs[$a] = (is_dir($a) || !$a);
46
-		}
47
-		if ($dirs[$a]) {
48
-			if (is_readable($a .= $file)) {
49
-				$liste[] = $a;
50
-			}
51
-		}
52
-	}
41
+    static $dirs = [];
42
+    $liste = [];
43
+    foreach (creer_chemin() as $dir) {
44
+        if (!isset($dirs[$a = $dir . $dirname])) {
45
+            $dirs[$a] = (is_dir($a) || !$a);
46
+        }
47
+        if ($dirs[$a]) {
48
+            if (is_readable($a .= $file)) {
49
+                $liste[] = $a;
50
+            }
51
+        }
52
+    }
53 53
 
54
-	return array_reverse($liste);
54
+    return array_reverse($liste);
55 55
 }
56 56
 
57 57
 /**
@@ -66,23 +66,23 @@  discard block
 block discarded – undo
66 66
  *     Liste des fichiers touvés pour ce module et cette langue.
67 67
  **/
68 68
 function chercher_module_lang($module, $lang = '') {
69
-	if ($lang) {
70
-		$lang = '_' . $lang;
71
-	}
69
+    if ($lang) {
70
+        $lang = '_' . $lang;
71
+    }
72 72
 
73
-	// 1) dans un repertoire nomme lang/ se trouvant sur le chemin
74
-	if (
75
-		$f = ($module == 'local'
76
-		? find_in_path($module . $lang . '.php', 'lang/')
77
-		: find_langs_in_path($module . $lang . '.php', 'lang/'))
78
-	) {
79
-		return is_array($f) ? $f : [$f];
80
-	}
73
+    // 1) dans un repertoire nomme lang/ se trouvant sur le chemin
74
+    if (
75
+        $f = ($module == 'local'
76
+        ? find_in_path($module . $lang . '.php', 'lang/')
77
+        : find_langs_in_path($module . $lang . '.php', 'lang/'))
78
+    ) {
79
+        return is_array($f) ? $f : [$f];
80
+    }
81 81
 
82
-	// 2) directement dans le chemin (old style, uniquement pour local)
83
-	return (($module == 'local') or strpos($module, '/'))
84
-		? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false)
85
-		: false;
82
+    // 2) directement dans le chemin (old style, uniquement pour local)
83
+    return (($module == 'local') or strpos($module, '/'))
84
+        ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false)
85
+        : false;
86 86
 }
87 87
 
88 88
 /**
@@ -104,33 +104,33 @@  discard block
 block discarded – undo
104 104
  * @return string Langue du module chargé, sinon chaîne vide.
105 105
  **/
106 106
 function charger_langue($lang, $module = 'spip') {
107
-	static $langs = [];
108
-	$var = 'i18n_' . $module . '_' . $lang;
109
-	if (!isset($langs[$lang])) {
110
-		$langs[$lang] = [];
111
-		if ($lang) {
112
-			$langs[$lang][] = $lang;
113
-			if (strpos($lang, '_') !== false) {
114
-				$l = explode('_', $lang);
115
-				$langs[$lang][] = reset($l);
116
-			}
117
-		}
118
-		$langs[$lang][] = $GLOBALS['meta']['langue_site'];
119
-		$langs[$lang][] = _LANGUE_PAR_DEFAUT;
120
-	}
121
-	foreach ($langs[$lang] as $l) {
122
-		if ($fichiers_lang = chercher_module_lang($module, $l)) {
123
-			$GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l;
124
-			include(array_shift($fichiers_lang));
125
-			surcharger_langue($fichiers_lang);
126
-			if ($l !== $lang) {
127
-				$GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l];
128
-			}
129
-			$GLOBALS['lang_' . $var] = $l;
130
-			#spip_log("module de langue : ${module}_$l.php", 'traduire');
131
-			break;
132
-		}
133
-	}
107
+    static $langs = [];
108
+    $var = 'i18n_' . $module . '_' . $lang;
109
+    if (!isset($langs[$lang])) {
110
+        $langs[$lang] = [];
111
+        if ($lang) {
112
+            $langs[$lang][] = $lang;
113
+            if (strpos($lang, '_') !== false) {
114
+                $l = explode('_', $lang);
115
+                $langs[$lang][] = reset($l);
116
+            }
117
+        }
118
+        $langs[$lang][] = $GLOBALS['meta']['langue_site'];
119
+        $langs[$lang][] = _LANGUE_PAR_DEFAUT;
120
+    }
121
+    foreach ($langs[$lang] as $l) {
122
+        if ($fichiers_lang = chercher_module_lang($module, $l)) {
123
+            $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l;
124
+            include(array_shift($fichiers_lang));
125
+            surcharger_langue($fichiers_lang);
126
+            if ($l !== $lang) {
127
+                $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l];
128
+            }
129
+            $GLOBALS['lang_' . $var] = $l;
130
+            #spip_log("module de langue : ${module}_$l.php", 'traduire');
131
+            break;
132
+        }
133
+    }
134 134
 }
135 135
 
136 136
 /**
@@ -150,50 +150,50 @@  discard block
 block discarded – undo
150 150
  *    Liste des chemins de fichiers de langue à surcharger.
151 151
  **/
152 152
 function surcharger_langue($fichiers) {
153
-	static $surcharges = [];
154
-	if (!isset($GLOBALS['idx_lang'])) {
155
-		return;
156
-	}
153
+    static $surcharges = [];
154
+    if (!isset($GLOBALS['idx_lang'])) {
155
+        return;
156
+    }
157 157
 
158
-	if (!is_array($fichiers)) {
159
-		$fichiers = [$fichiers];
160
-	}
161
-	if (!count($fichiers)) {
162
-		return;
163
-	}
164
-	foreach ($fichiers as $fichier) {
165
-		if (!isset($surcharges[$fichier])) {
166
-			$idx_lang_normal = $GLOBALS['idx_lang'];
167
-			$GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire';
168
-			include($fichier);
169
-			$surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']];
170
-			unset($GLOBALS[$GLOBALS['idx_lang']]);
171
-			$GLOBALS['idx_lang'] = $idx_lang_normal;
172
-		}
173
-		if (is_array($surcharges[$fichier])) {
174
-			$GLOBALS[$GLOBALS['idx_lang']] = array_merge(
175
-				(isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []),
176
-				$surcharges[$fichier]
177
-			);
178
-		}
179
-	}
158
+    if (!is_array($fichiers)) {
159
+        $fichiers = [$fichiers];
160
+    }
161
+    if (!count($fichiers)) {
162
+        return;
163
+    }
164
+    foreach ($fichiers as $fichier) {
165
+        if (!isset($surcharges[$fichier])) {
166
+            $idx_lang_normal = $GLOBALS['idx_lang'];
167
+            $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire';
168
+            include($fichier);
169
+            $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']];
170
+            unset($GLOBALS[$GLOBALS['idx_lang']]);
171
+            $GLOBALS['idx_lang'] = $idx_lang_normal;
172
+        }
173
+        if (is_array($surcharges[$fichier])) {
174
+            $GLOBALS[$GLOBALS['idx_lang']] = array_merge(
175
+                (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []),
176
+                $surcharges[$fichier]
177
+            );
178
+        }
179
+    }
180 180
 }
181 181
 
182 182
 
183 183
 
184 184
 class SPIP_Traductions_Description {
185
-	/** @var string code de langue (hors module) */
186
-	public $code;
187
-	/** @var string nom du module de langue */
188
-	public $module;
189
-	/** @var string langue de la traduction */
190
-	public $langue;
191
-	/** @var string traduction */
192
-	public $texte;
193
-	/** @var string var mode particulier appliqué ? */
194
-	public $mode;
195
-	/** @var bool Corrections des textes appliqué ? */
196
-	public $corrections = false;
185
+    /** @var string code de langue (hors module) */
186
+    public $code;
187
+    /** @var string nom du module de langue */
188
+    public $module;
189
+    /** @var string langue de la traduction */
190
+    public $langue;
191
+    /** @var string traduction */
192
+    public $texte;
193
+    /** @var string var mode particulier appliqué ? */
194
+    public $mode;
195
+    /** @var bool Corrections des textes appliqué ? */
196
+    public $corrections = false;
197 197
 }
198 198
 
199 199
 
@@ -235,99 +235,99 @@  discard block
 block discarded – undo
235 235
  *     - SPIP_Traductions_Description : traduction et description (texte, module, langue)
236 236
  **/
237 237
 function inc_traduire_dist($ori, $lang, $raw = false) {
238
-	static $deja_vu = [];
239
-	static $local = [];
238
+    static $deja_vu = [];
239
+    static $local = [];
240 240
 
241
-	if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) {
242
-		return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte;
243
-	}
241
+    if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) {
242
+        return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte;
243
+    }
244 244
 
245
-	// modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES
246
-	if (strpos($ori, ':')) {
247
-		[$modules, $code] = explode(':', $ori, 2);
248
-		$modules = explode('|', $modules);
249
-		$ori_complet = $ori;
250
-	} else {
251
-		$modules = ['spip', 'ecrire'];
252
-		$code = $ori;
253
-		$ori_complet = implode('|', $modules) . ':' . $ori;
254
-	}
245
+    // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES
246
+    if (strpos($ori, ':')) {
247
+        [$modules, $code] = explode(':', $ori, 2);
248
+        $modules = explode('|', $modules);
249
+        $ori_complet = $ori;
250
+    } else {
251
+        $modules = ['spip', 'ecrire'];
252
+        $code = $ori;
253
+        $ori_complet = implode('|', $modules) . ':' . $ori;
254
+    }
255 255
 
256
-	$desc = new SPIP_Traductions_Description();
256
+    $desc = new SPIP_Traductions_Description();
257 257
 
258
-	// parcourir tous les modules jusqu'a ce qu'on trouve
259
-	foreach ($modules as $module) {
260
-		$var = 'i18n_' . $module . '_' . $lang;
258
+    // parcourir tous les modules jusqu'a ce qu'on trouve
259
+    foreach ($modules as $module) {
260
+        $var = 'i18n_' . $module . '_' . $lang;
261 261
 
262
-		if (empty($GLOBALS[$var])) {
263
-			charger_langue($lang, $module);
264
-			// surcharges persos -- on cherche
265
-			// (lang/)local_xx.php et/ou (lang/)local.php ...
266
-			if (!isset($local['local_' . $lang])) {
267
-				// redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer)
268
-				$GLOBALS['idx_lang'] = $var;
269
-				// ... (lang/)local_xx.php
270
-				$local['local_' . $lang] = chercher_module_lang('local', $lang);
271
-			}
272
-			if ($local['local_' . $lang]) {
273
-				surcharger_langue($local['local_' . $lang]);
274
-			}
275
-			// ... puis (lang/)local.php
276
-			if (!isset($local['local'])) {
277
-				$local['local'] = chercher_module_lang('local');
278
-			}
279
-			if ($local['local']) {
280
-				surcharger_langue($local['local']);
281
-			}
282
-		}
262
+        if (empty($GLOBALS[$var])) {
263
+            charger_langue($lang, $module);
264
+            // surcharges persos -- on cherche
265
+            // (lang/)local_xx.php et/ou (lang/)local.php ...
266
+            if (!isset($local['local_' . $lang])) {
267
+                // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer)
268
+                $GLOBALS['idx_lang'] = $var;
269
+                // ... (lang/)local_xx.php
270
+                $local['local_' . $lang] = chercher_module_lang('local', $lang);
271
+            }
272
+            if ($local['local_' . $lang]) {
273
+                surcharger_langue($local['local_' . $lang]);
274
+            }
275
+            // ... puis (lang/)local.php
276
+            if (!isset($local['local'])) {
277
+                $local['local'] = chercher_module_lang('local');
278
+            }
279
+            if ($local['local']) {
280
+                surcharger_langue($local['local']);
281
+            }
282
+        }
283 283
 
284
-		if (isset($GLOBALS[$var][$code])) {
285
-			$desc->code = $code;
286
-			$desc->module = $module;
287
-			$desc->langue = $GLOBALS['lang_' . $var];
288
-			$desc->texte = $GLOBALS[$var][$code];
289
-			break;
290
-		}
291
-	}
284
+        if (isset($GLOBALS[$var][$code])) {
285
+            $desc->code = $code;
286
+            $desc->module = $module;
287
+            $desc->langue = $GLOBALS['lang_' . $var];
288
+            $desc->texte = $GLOBALS[$var][$code];
289
+            break;
290
+        }
291
+    }
292 292
 
293
-	if (!$desc->corrections) {
294
-		$desc->corrections = true;
295
-		// Retour aux sources si la chaine est absente dans la langue cible ;
296
-		// on essaie d'abord la langue du site, puis a defaut la langue fr
297
-		if (
298
-			($desc->texte === null || !strlen($desc->texte)) 
299
-			and $lang !== _LANGUE_PAR_DEFAUT
300
-		) {
301
-			if ($lang !== $GLOBALS['meta']['langue_site']) {
302
-				$desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true);
303
-			} else {
304
-				$desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true);
305
-			}
306
-		}
293
+    if (!$desc->corrections) {
294
+        $desc->corrections = true;
295
+        // Retour aux sources si la chaine est absente dans la langue cible ;
296
+        // on essaie d'abord la langue du site, puis a defaut la langue fr
297
+        if (
298
+            ($desc->texte === null || !strlen($desc->texte)) 
299
+            and $lang !== _LANGUE_PAR_DEFAUT
300
+        ) {
301
+            if ($lang !== $GLOBALS['meta']['langue_site']) {
302
+                $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true);
303
+            } else {
304
+                $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true);
305
+            }
306
+        }
307 307
 
308
-		// Supprimer la mention <NEW> ou <MODIF>
309
-		if ($desc->texte && substr($desc->texte, 0, 1) === '<') {
310
-			$desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte);
311
-		}
308
+        // Supprimer la mention <NEW> ou <MODIF>
309
+        if ($desc->texte && substr($desc->texte, 0, 1) === '<') {
310
+            $desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte);
311
+        }
312 312
 
313
-		// Si on n'est pas en utf-8, la chaine peut l'etre...
314
-		// le cas echeant on la convertit en entites html &#xxx;
315
-		if (
316
-			(!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8')
317
-			and preg_match(',[\x7f-\xff],S', $desc->texte)
318
-		) {
319
-			include_spip('inc/charsets');
320
-			$desc->texte = charset2unicode($desc->texte, 'utf-8');
321
-		}
322
-	}
313
+        // Si on n'est pas en utf-8, la chaine peut l'etre...
314
+        // le cas echeant on la convertit en entites html &#xxx;
315
+        if (
316
+            (!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8')
317
+            and preg_match(',[\x7f-\xff],S', $desc->texte)
318
+        ) {
319
+            include_spip('inc/charsets');
320
+            $desc->texte = charset2unicode($desc->texte, 'utf-8');
321
+        }
322
+    }
323 323
 
324
-	if (_request('var_mode') == 'traduction') {
325
-		$desc = definir_details_traduction($desc, $ori_complet);
326
-	} else {
327
-		$deja_vu[$lang][$ori] = $desc;
328
-	}
324
+    if (_request('var_mode') == 'traduction') {
325
+        $desc = definir_details_traduction($desc, $ori_complet);
326
+    } else {
327
+        $deja_vu[$lang][$ori] = $desc;
328
+    }
329 329
 
330
-	return $raw ? $desc : $desc->texte;
330
+    return $raw ? $desc : $desc->texte;
331 331
 }
332 332
 
333 333
 /**
@@ -339,23 +339,23 @@  discard block
 block discarded – undo
339 339
  * @return SPIP_Traductions_Description
340 340
  */
341 341
 function definir_details_traduction($desc, $modules) {
342
-	if (!$desc->mode and $desc->texte) {
343
-		// ne pas modifier 2 fois l'affichage
344
-		$desc->mode = 'traduction';
345
-		$classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : '');
346
-		$desc->texte = '<span '
347
-			. 'lang=' . $desc->langue
348
-			. ' class=' . $classe
349
-			. ' data-module=' . $desc->module
350
-			. ' data-code=' . $desc->code
351
-			. ' title=' . $modules . '(' . $desc->langue . ')>'
352
-			. $desc->texte
353
-			. '</span>';
354
-		$desc->texte = str_replace(
355
-			["$desc->module:", "$desc->module|"],
356
-			["*$desc->module*:", "*$desc->module*|"],
357
-			$desc->texte
358
-		);
359
-	}
360
-	return $desc;
342
+    if (!$desc->mode and $desc->texte) {
343
+        // ne pas modifier 2 fois l'affichage
344
+        $desc->mode = 'traduction';
345
+        $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : '');
346
+        $desc->texte = '<span '
347
+            . 'lang=' . $desc->langue
348
+            . ' class=' . $classe
349
+            . ' data-module=' . $desc->module
350
+            . ' data-code=' . $desc->code
351
+            . ' title=' . $modules . '(' . $desc->langue . ')>'
352
+            . $desc->texte
353
+            . '</span>';
354
+        $desc->texte = str_replace(
355
+            ["$desc->module:", "$desc->module|"],
356
+            ["*$desc->module*:", "*$desc->module*|"],
357
+            $desc->texte
358
+        );
359
+    }
360
+    return $desc;
361 361
 }
Please login to merge, or discard this patch.
ecrire/inc/rubriques.php 1 patch
Indentation   +621 added lines, -621 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
 
@@ -54,65 +54,65 @@  discard block
 block discarded – undo
54 54
  *     true si le statut change effectivement
55 55
  **/
56 56
 function calculer_rubriques_if($id_rubrique, $modifs, $infos = [], $postdate = false) {
57
-	$statuts_publies = null;
58
-	$neuf = false;
59
-
60
-	// Compat avec l'ancienne signature
61
-	if (is_string($infos)) {
62
-		$infos = ['statut_ancien' => $infos];
63
-	}
64
-	if (!isset($infos['statut_ancien'])) {
65
-		$infos['statut_ancien'] = '';
66
-	}
67
-
68
-	// On recherche quels statuts tester
69
-	if (
70
-		isset($infos['objet'])
71
-		and include_spip('inc/filtres')
72
-		and $declaration_statut = objet_info($infos['objet'], 'statut')
73
-		and is_array($declaration_statut)
74
-	) {
75
-		foreach ($declaration_statut as $champ_statut) {
76
-			if ($champ_statut['champ'] == 'statut') {
77
-				$statuts_publies = array_map('trim', explode(',', $champ_statut['publie']));
78
-				break; // stop on a trouvé le bon champ
79
-			}
80
-		}
81
-	}
82
-	else {
83
-		$statuts_publies = ['publie'];
84
-	}
85
-
86
-	if (in_array($infos['statut_ancien'], $statuts_publies)) {
87
-		if (
88
-			isset($modifs['statut'])
89
-			or isset($modifs['id_rubrique'])
90
-			or ($postdate and strtotime($postdate) > time())
91
-		) {
92
-			$neuf |= depublier_branche_rubrique_if($id_rubrique);
93
-		}
94
-		// ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur
95
-		if ($postdate) {
96
-			calculer_prochain_postdate(true);
97
-			$neuf |= (strtotime($postdate) <= time()); // par securite
98
-		} elseif (isset($modifs['id_rubrique'])) {
99
-			$neuf |= publier_branche_rubrique($modifs['id_rubrique']);
100
-		}
101
-	} elseif (isset($modifs['statut']) and in_array($modifs['statut'], $statuts_publies)) {
102
-		if ($postdate) {
103
-			calculer_prochain_postdate(true);
104
-			$neuf |= (strtotime($postdate) <= time()); // par securite
105
-		} else {
106
-			$neuf |= publier_branche_rubrique($id_rubrique);
107
-		}
108
-	}
109
-
110
-	if ($neuf) { // Sauver la date de la derniere mise a jour (pour menu_rubriques)
111
-	ecrire_meta('date_calcul_rubriques', date('U'));
112
-	}
113
-
114
-	$langues = calculer_langues_utilisees();
115
-	ecrire_meta('langues_utilisees', $langues);
57
+    $statuts_publies = null;
58
+    $neuf = false;
59
+
60
+    // Compat avec l'ancienne signature
61
+    if (is_string($infos)) {
62
+        $infos = ['statut_ancien' => $infos];
63
+    }
64
+    if (!isset($infos['statut_ancien'])) {
65
+        $infos['statut_ancien'] = '';
66
+    }
67
+
68
+    // On recherche quels statuts tester
69
+    if (
70
+        isset($infos['objet'])
71
+        and include_spip('inc/filtres')
72
+        and $declaration_statut = objet_info($infos['objet'], 'statut')
73
+        and is_array($declaration_statut)
74
+    ) {
75
+        foreach ($declaration_statut as $champ_statut) {
76
+            if ($champ_statut['champ'] == 'statut') {
77
+                $statuts_publies = array_map('trim', explode(',', $champ_statut['publie']));
78
+                break; // stop on a trouvé le bon champ
79
+            }
80
+        }
81
+    }
82
+    else {
83
+        $statuts_publies = ['publie'];
84
+    }
85
+
86
+    if (in_array($infos['statut_ancien'], $statuts_publies)) {
87
+        if (
88
+            isset($modifs['statut'])
89
+            or isset($modifs['id_rubrique'])
90
+            or ($postdate and strtotime($postdate) > time())
91
+        ) {
92
+            $neuf |= depublier_branche_rubrique_if($id_rubrique);
93
+        }
94
+        // ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur
95
+        if ($postdate) {
96
+            calculer_prochain_postdate(true);
97
+            $neuf |= (strtotime($postdate) <= time()); // par securite
98
+        } elseif (isset($modifs['id_rubrique'])) {
99
+            $neuf |= publier_branche_rubrique($modifs['id_rubrique']);
100
+        }
101
+    } elseif (isset($modifs['statut']) and in_array($modifs['statut'], $statuts_publies)) {
102
+        if ($postdate) {
103
+            calculer_prochain_postdate(true);
104
+            $neuf |= (strtotime($postdate) <= time()); // par securite
105
+        } else {
106
+            $neuf |= publier_branche_rubrique($id_rubrique);
107
+        }
108
+    }
109
+
110
+    if ($neuf) { // Sauver la date de la derniere mise a jour (pour menu_rubriques)
111
+    ecrire_meta('date_calcul_rubriques', date('U'));
112
+    }
113
+
114
+    $langues = calculer_langues_utilisees();
115
+    ecrire_meta('langues_utilisees', $langues);
116 116
 }
117 117
 
118 118
 
@@ -130,22 +130,22 @@  discard block
 block discarded – undo
130 130
  *     true si le statut change effectivement
131 131
  */
132 132
 function publier_branche_rubrique($id_rubrique) {
133
-	$id_pred = $id_rubrique;
134
-	while (true) {
135
-		sql_updateq(
136
-			'spip_rubriques',
137
-			['statut' => 'publie', 'date' => date('Y-m-d H:i:s')],
138
-			'id_rubrique=' . intval($id_rubrique)
139
-		);
140
-		$id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique));
141
-		if (!$id_parent) {
142
-			break;
143
-		}
144
-		$id_rubrique = $id_parent;
145
-	}
133
+    $id_pred = $id_rubrique;
134
+    while (true) {
135
+        sql_updateq(
136
+            'spip_rubriques',
137
+            ['statut' => 'publie', 'date' => date('Y-m-d H:i:s')],
138
+            'id_rubrique=' . intval($id_rubrique)
139
+        );
140
+        $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique));
141
+        if (!$id_parent) {
142
+            break;
143
+        }
144
+        $id_rubrique = $id_parent;
145
+    }
146 146
 
147 147
 #	spip_log(" publier_branche_rubrique($id_rubrique $id_pred");
148
-	return $id_pred != $id_rubrique;
148
+    return $id_pred != $id_rubrique;
149 149
 }
150 150
 
151 151
 /**
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
  *     true si le statut change effectivement
164 164
  */
165 165
 function depublier_branche_rubrique_if($id_rubrique) {
166
-	$date = date('Y-m-d H:i:s'); // figer la date
167
-
168
-	#	spip_log("depublier_branche_rubrique($id_rubrique ?");
169
-	$id_pred = $id_rubrique;
170
-	while ($id_pred) {
171
-		if (!depublier_rubrique_if($id_pred, $date)) {
172
-			return $id_pred != $id_rubrique;
173
-		}
174
-		// passer au parent si on a depublie
175
-		$r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred));
176
-		$id_pred = $r['id_parent'];
177
-	}
178
-
179
-	return $id_pred != $id_rubrique;
166
+    $date = date('Y-m-d H:i:s'); // figer la date
167
+
168
+    #	spip_log("depublier_branche_rubrique($id_rubrique ?");
169
+    $id_pred = $id_rubrique;
170
+    while ($id_pred) {
171
+        if (!depublier_rubrique_if($id_pred, $date)) {
172
+            return $id_pred != $id_rubrique;
173
+        }
174
+        // passer au parent si on a depublie
175
+        $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred));
176
+        $id_pred = $r['id_parent'];
177
+    }
178
+
179
+    return $id_pred != $id_rubrique;
180 180
 }
181 181
 
182 182
 /**
@@ -193,61 +193,61 @@  discard block
 block discarded – undo
193 193
  *    true si la rubrique a été dépubliée
194 194
  */
195 195
 function depublier_rubrique_if($id_rubrique, $date = null) {
196
-	if (is_null($date)) {
197
-		$date = date('Y-m-d H:i:s');
198
-	}
199
-	$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
200
-		' AND date <= ' . sql_quote($date) : '';
201
-
202
-	if (!$id_rubrique = intval($id_rubrique)) {
203
-		return false;
204
-	}
205
-
206
-	// verifier qu'elle existe et est bien publiee
207
-	$r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
208
-	if (!$r or $r['statut'] !== 'publie') {
209
-		return false;
210
-	}
211
-
212
-	// On met le nombre de chaque type d'enfants dans un tableau
213
-	// Le type de l'objet est au pluriel
214
-	$compte = [
215
-		'articles' => sql_countsel(
216
-			'spip_articles',
217
-			'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates"
218
-		),
219
-		'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"),
220
-		'documents' => sql_countsel(
221
-			'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document',
222
-			'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') "
223
-		)
224
-	];
225
-
226
-	// On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants
227
-	$compte = pipeline(
228
-		'objet_compte_enfants',
229
-		[
230
-			'args' => [
231
-				'objet' => 'rubrique',
232
-				'id_objet' => $id_rubrique,
233
-				'statut' => 'publie',
234
-				'date' => $date
235
-			],
236
-			'data' => $compte
237
-		]
238
-	);
239
-
240
-	// S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas
241
-	foreach ($compte as $objet => $n) {
242
-		if ($n) {
243
-			return false;
244
-		}
245
-	}
246
-
247
-	sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique));
196
+    if (is_null($date)) {
197
+        $date = date('Y-m-d H:i:s');
198
+    }
199
+    $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
200
+        ' AND date <= ' . sql_quote($date) : '';
201
+
202
+    if (!$id_rubrique = intval($id_rubrique)) {
203
+        return false;
204
+    }
205
+
206
+    // verifier qu'elle existe et est bien publiee
207
+    $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
208
+    if (!$r or $r['statut'] !== 'publie') {
209
+        return false;
210
+    }
211
+
212
+    // On met le nombre de chaque type d'enfants dans un tableau
213
+    // Le type de l'objet est au pluriel
214
+    $compte = [
215
+        'articles' => sql_countsel(
216
+            'spip_articles',
217
+            'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates"
218
+        ),
219
+        'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"),
220
+        'documents' => sql_countsel(
221
+            'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document',
222
+            'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') "
223
+        )
224
+    ];
225
+
226
+    // On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants
227
+    $compte = pipeline(
228
+        'objet_compte_enfants',
229
+        [
230
+            'args' => [
231
+                'objet' => 'rubrique',
232
+                'id_objet' => $id_rubrique,
233
+                'statut' => 'publie',
234
+                'date' => $date
235
+            ],
236
+            'data' => $compte
237
+        ]
238
+    );
239
+
240
+    // S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas
241
+    foreach ($compte as $objet => $n) {
242
+        if ($n) {
243
+            return false;
244
+        }
245
+    }
246
+
247
+    sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique));
248 248
 
249 249
 #		spip_log("depublier_rubrique $id_pred");
250
-	return true;
250
+    return true;
251 251
 }
252 252
 
253 253
 
@@ -270,18 +270,18 @@  discard block
 block discarded – undo
270 270
  **/
271 271
 function calculer_rubriques() {
272 272
 
273
-	calculer_rubriques_publiees();
273
+    calculer_rubriques_publiees();
274 274
 
275
-	// Apres chaque (de)publication
276
-	// recalculer les langues utilisees sur le site
277
-	$langues = calculer_langues_utilisees();
278
-	ecrire_meta('langues_utilisees', $langues);
275
+    // Apres chaque (de)publication
276
+    // recalculer les langues utilisees sur le site
277
+    $langues = calculer_langues_utilisees();
278
+    ecrire_meta('langues_utilisees', $langues);
279 279
 
280
-	// Sauver la date de la derniere mise a jour (pour menu_rubriques)
281
-	ecrire_meta('date_calcul_rubriques', date('U'));
280
+    // Sauver la date de la derniere mise a jour (pour menu_rubriques)
281
+    ecrire_meta('date_calcul_rubriques', date('U'));
282 282
 
283
-	// on calcule la date du prochain article post-date
284
-	calculer_prochain_postdate();
283
+    // on calcule la date du prochain article post-date
284
+    calculer_prochain_postdate();
285 285
 }
286 286
 
287 287
 
@@ -298,61 +298,61 @@  discard block
 block discarded – undo
298 298
  **/
299 299
 function calculer_rubriques_publiees() {
300 300
 
301
-	// Mettre les compteurs a zero
302
-	sql_updateq('spip_rubriques', ['date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa']);
303
-
304
-	//
305
-	// Publier et dater les rubriques qui ont un article publie
306
-	//
307
-
308
-	// Afficher les articles post-dates ?
309
-	$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
310
-		'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
311
-
312
-	$r = sql_select(
313
-		'R.id_rubrique AS id, max(A.date) AS date_h',
314
-		'spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique',
315
-		"A.date>R.date_tmp AND A.statut='publie' $postdates ",
316
-		'R.id_rubrique'
317
-	);
318
-	while ($row = sql_fetch($r)) {
319
-		sql_updateq(
320
-			'spip_rubriques',
321
-			['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
322
-			'id_rubrique=' . intval($row['id'])
323
-		);
324
-	}
325
-
326
-	// point d'entree pour permettre a des plugins de gerer le statut
327
-	// autrement (par ex: toute rubrique est publiee des sa creation)
328
-	// Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates
329
-	// c'est statut_tmp/date_tmp qu'il doit modifier
330
-	// [C'est un trigger... a renommer en trig_calculer_rubriques ?]
331
-	pipeline('calculer_rubriques', null);
332
-
333
-
334
-	// Les rubriques qui ont une rubrique fille plus recente
335
-	// on tourne tant que les donnees remontent vers la racine.
336
-	do {
337
-		$continuer = false;
338
-		$r = sql_select(
339
-			'R.id_rubrique AS id, max(SR.date_tmp) AS date_h',
340
-			'spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent',
341
-			"(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ",
342
-			'R.id_rubrique'
343
-		);
344
-		while ($row = sql_fetch($r)) {
345
-			sql_updateq(
346
-				'spip_rubriques',
347
-				['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
348
-				'id_rubrique=' . intval($row['id'])
349
-			);
350
-			$continuer = true;
351
-		}
352
-	} while ($continuer);
353
-
354
-	// Enregistrement des modifs
355
-	sql_update('spip_rubriques', ['date' => 'date_tmp', 'statut' => 'statut_tmp']);
301
+    // Mettre les compteurs a zero
302
+    sql_updateq('spip_rubriques', ['date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa']);
303
+
304
+    //
305
+    // Publier et dater les rubriques qui ont un article publie
306
+    //
307
+
308
+    // Afficher les articles post-dates ?
309
+    $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
310
+        'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
311
+
312
+    $r = sql_select(
313
+        'R.id_rubrique AS id, max(A.date) AS date_h',
314
+        'spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique',
315
+        "A.date>R.date_tmp AND A.statut='publie' $postdates ",
316
+        'R.id_rubrique'
317
+    );
318
+    while ($row = sql_fetch($r)) {
319
+        sql_updateq(
320
+            'spip_rubriques',
321
+            ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
322
+            'id_rubrique=' . intval($row['id'])
323
+        );
324
+    }
325
+
326
+    // point d'entree pour permettre a des plugins de gerer le statut
327
+    // autrement (par ex: toute rubrique est publiee des sa creation)
328
+    // Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates
329
+    // c'est statut_tmp/date_tmp qu'il doit modifier
330
+    // [C'est un trigger... a renommer en trig_calculer_rubriques ?]
331
+    pipeline('calculer_rubriques', null);
332
+
333
+
334
+    // Les rubriques qui ont une rubrique fille plus recente
335
+    // on tourne tant que les donnees remontent vers la racine.
336
+    do {
337
+        $continuer = false;
338
+        $r = sql_select(
339
+            'R.id_rubrique AS id, max(SR.date_tmp) AS date_h',
340
+            'spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent',
341
+            "(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ",
342
+            'R.id_rubrique'
343
+        );
344
+        while ($row = sql_fetch($r)) {
345
+            sql_updateq(
346
+                'spip_rubriques',
347
+                ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
348
+                'id_rubrique=' . intval($row['id'])
349
+            );
350
+            $continuer = true;
351
+        }
352
+    } while ($continuer);
353
+
354
+    // Enregistrement des modifs
355
+    sql_update('spip_rubriques', ['date' => 'date_tmp', 'statut' => 'statut_tmp']);
356 356
 }
357 357
 
358 358
 /**
@@ -367,123 +367,123 @@  discard block
 block discarded – undo
367 367
  * @return void
368 368
  **/
369 369
 function propager_les_secteurs() {
370
-	// Profondeur 0
371
-	// Toutes les rubriques racines sont de profondeur 0
372
-	// et fixer les id_secteur des rubriques racines
373
-	sql_update('spip_rubriques', ['id_secteur' => 'id_rubrique', 'profondeur' => 0], 'id_parent=0');
374
-	// Toute rubrique non racine est de profondeur >0
375
-	sql_updateq('spip_rubriques', ['profondeur' => 1], 'id_parent<>0 AND profondeur=0');
376
-
377
-	// securite : pas plus d'iteration que de rubriques dans la base
378
-	$maxiter = sql_countsel('spip_rubriques');
379
-
380
-	// reparer les rubriques qui n'ont pas l'id_secteur de leur parent
381
-	// on fait profondeur par profondeur
382
-
383
-	$prof = 0;
384
-	do {
385
-		$continuer = false;
386
-
387
-		// Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes
388
-		// on fixe le profondeur $prof+1
389
-
390
-		// Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1
391
-		// on teste A.profondeur > $prof+1 car :
392
-		// - toutes les rubriques de profondeur 0 à $prof sont bonnes
393
-		// - si A.profondeur = $prof+1 c'est bon
394
-		// - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques
395
-		$maxiter2 = $maxiter;
396
-		while (
397
-			$maxiter2--
398
-			and $rows = sql_allfetsel(
399
-				'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur',
400
-				'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique',
401
-				'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)',
402
-				'',
403
-				'R.id_secteur',
404
-				'0,100'
405
-			)
406
-		) {
407
-			$id_secteur = null;
408
-			$ids = [];
409
-			while ($row = array_shift($rows)) {
410
-				if ($row['id_secteur'] !== $id_secteur) {
411
-					if (count($ids)) {
412
-						sql_updateq(
413
-							'spip_rubriques',
414
-							['id_secteur' => $id_secteur, 'profondeur' => $prof + 1],
415
-							sql_in('id_rubrique', $ids)
416
-						);
417
-					}
418
-					$id_secteur = $row['id_secteur'];
419
-					$ids = [];
420
-				}
421
-				$ids[] = $row['id'];
422
-			}
423
-			if (count($ids)) {
424
-				sql_updateq(
425
-					'spip_rubriques',
426
-					['id_secteur' => $id_secteur, 'profondeur' => $prof + 1],
427
-					sql_in('id_rubrique', $ids)
428
-				);
429
-			}
430
-		}
431
-
432
-
433
-		// Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees
434
-		$maxiter2 = $maxiter;
435
-		while (
436
-			$maxiter2--
437
-			and $rows = sql_allfetsel(
438
-				'id_rubrique as id',
439
-				'spip_rubriques',
440
-				'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select(
441
-					'zzz.id_rubrique',
442
-					'spip_rubriques AS zzz',
443
-					'zzz.profondeur=' . intval($prof)
444
-				) . ')',
445
-				'',
446
-				'',
447
-				'0,100'
448
-			)
449
-		) {
450
-			$rows = array_column($rows, 'id');
451
-			sql_updateq('spip_rubriques', ['profondeur' => $prof + 2], sql_in('id_rubrique', $rows));
452
-		}
453
-
454
-		// ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK
455
-		// si pas de rubrique a profondeur $prof+1 pas la peine de continuer
456
-		// si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse)
457
-		// on arrete les frais
458
-		if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) {
459
-			$prof++;
460
-			$continuer = true;
461
-		}
462
-	} while ($continuer and $maxiter--);
463
-
464
-	// loger si la table des rubriques semble foireuse
465
-	// et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles
466
-	if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) {
467
-		spip_log(
468
-			'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)',
469
-			_LOG_CRITIQUE
470
-		);
471
-		sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1));
472
-	}
473
-
474
-	// reparer les articles
475
-	$r = sql_select(
476
-		'A.id_article AS id, R.id_secteur AS secteur',
477
-		'spip_articles AS A, spip_rubriques AS R',
478
-		'A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur'
479
-	);
480
-
481
-	while ($row = sql_fetch($r)) {
482
-		sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id']));
483
-	}
484
-
485
-	// avertir les plugins qui peuvent faire leur mises a jour egalement
486
-	pipeline('trig_propager_les_secteurs', '');
370
+    // Profondeur 0
371
+    // Toutes les rubriques racines sont de profondeur 0
372
+    // et fixer les id_secteur des rubriques racines
373
+    sql_update('spip_rubriques', ['id_secteur' => 'id_rubrique', 'profondeur' => 0], 'id_parent=0');
374
+    // Toute rubrique non racine est de profondeur >0
375
+    sql_updateq('spip_rubriques', ['profondeur' => 1], 'id_parent<>0 AND profondeur=0');
376
+
377
+    // securite : pas plus d'iteration que de rubriques dans la base
378
+    $maxiter = sql_countsel('spip_rubriques');
379
+
380
+    // reparer les rubriques qui n'ont pas l'id_secteur de leur parent
381
+    // on fait profondeur par profondeur
382
+
383
+    $prof = 0;
384
+    do {
385
+        $continuer = false;
386
+
387
+        // Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes
388
+        // on fixe le profondeur $prof+1
389
+
390
+        // Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1
391
+        // on teste A.profondeur > $prof+1 car :
392
+        // - toutes les rubriques de profondeur 0 à $prof sont bonnes
393
+        // - si A.profondeur = $prof+1 c'est bon
394
+        // - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques
395
+        $maxiter2 = $maxiter;
396
+        while (
397
+            $maxiter2--
398
+            and $rows = sql_allfetsel(
399
+                'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur',
400
+                'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique',
401
+                'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)',
402
+                '',
403
+                'R.id_secteur',
404
+                '0,100'
405
+            )
406
+        ) {
407
+            $id_secteur = null;
408
+            $ids = [];
409
+            while ($row = array_shift($rows)) {
410
+                if ($row['id_secteur'] !== $id_secteur) {
411
+                    if (count($ids)) {
412
+                        sql_updateq(
413
+                            'spip_rubriques',
414
+                            ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1],
415
+                            sql_in('id_rubrique', $ids)
416
+                        );
417
+                    }
418
+                    $id_secteur = $row['id_secteur'];
419
+                    $ids = [];
420
+                }
421
+                $ids[] = $row['id'];
422
+            }
423
+            if (count($ids)) {
424
+                sql_updateq(
425
+                    'spip_rubriques',
426
+                    ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1],
427
+                    sql_in('id_rubrique', $ids)
428
+                );
429
+            }
430
+        }
431
+
432
+
433
+        // Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees
434
+        $maxiter2 = $maxiter;
435
+        while (
436
+            $maxiter2--
437
+            and $rows = sql_allfetsel(
438
+                'id_rubrique as id',
439
+                'spip_rubriques',
440
+                'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select(
441
+                    'zzz.id_rubrique',
442
+                    'spip_rubriques AS zzz',
443
+                    'zzz.profondeur=' . intval($prof)
444
+                ) . ')',
445
+                '',
446
+                '',
447
+                '0,100'
448
+            )
449
+        ) {
450
+            $rows = array_column($rows, 'id');
451
+            sql_updateq('spip_rubriques', ['profondeur' => $prof + 2], sql_in('id_rubrique', $rows));
452
+        }
453
+
454
+        // ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK
455
+        // si pas de rubrique a profondeur $prof+1 pas la peine de continuer
456
+        // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse)
457
+        // on arrete les frais
458
+        if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) {
459
+            $prof++;
460
+            $continuer = true;
461
+        }
462
+    } while ($continuer and $maxiter--);
463
+
464
+    // loger si la table des rubriques semble foireuse
465
+    // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles
466
+    if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) {
467
+        spip_log(
468
+            'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)',
469
+            _LOG_CRITIQUE
470
+        );
471
+        sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1));
472
+    }
473
+
474
+    // reparer les articles
475
+    $r = sql_select(
476
+        'A.id_article AS id, R.id_secteur AS secteur',
477
+        'spip_articles AS A, spip_rubriques AS R',
478
+        'A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur'
479
+    );
480
+
481
+    while ($row = sql_fetch($r)) {
482
+        sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id']));
483
+    }
484
+
485
+    // avertir les plugins qui peuvent faire leur mises a jour egalement
486
+    pipeline('trig_propager_les_secteurs', '');
487 487
 }
488 488
 
489 489
 
@@ -498,23 +498,23 @@  discard block
 block discarded – undo
498 498
  *     true si un changement a eu lieu
499 499
  **/
500 500
 function calculer_langues_rubriques_etape() {
501
-	$s = sql_select(
502
-		'A.id_rubrique AS id_rubrique, R.lang AS lang',
503
-		'spip_rubriques AS A, spip_rubriques AS R',
504
-		"A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang"
505
-	);
506
-
507
-	$t = false;
508
-	while ($row = sql_fetch($s)) {
509
-		$id_rubrique = $row['id_rubrique'];
510
-		$t = sql_updateq(
511
-			'spip_rubriques',
512
-			['lang' => $row['lang'], 'langue_choisie' => 'non'],
513
-			'id_rubrique=' . intval($id_rubrique)
514
-		);
515
-	}
516
-
517
-	return $t;
501
+    $s = sql_select(
502
+        'A.id_rubrique AS id_rubrique, R.lang AS lang',
503
+        'spip_rubriques AS A, spip_rubriques AS R',
504
+        "A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang"
505
+    );
506
+
507
+    $t = false;
508
+    while ($row = sql_fetch($s)) {
509
+        $id_rubrique = $row['id_rubrique'];
510
+        $t = sql_updateq(
511
+            'spip_rubriques',
512
+            ['lang' => $row['lang'], 'langue_choisie' => 'non'],
513
+            'id_rubrique=' . intval($id_rubrique)
514
+        );
515
+    }
516
+
517
+    return $t;
518 518
 }
519 519
 
520 520
 /**
@@ -534,38 +534,38 @@  discard block
 block discarded – undo
534 534
  **/
535 535
 function calculer_langues_rubriques() {
536 536
 
537
-	// rubriques (recursivite)
538
-	sql_updateq(
539
-		'spip_rubriques',
540
-		['lang' => $GLOBALS['meta']['langue_site'], 'langue_choisie' => 'non'],
541
-		"id_parent=0 AND langue_choisie != 'oui'"
542
-	);
543
-	while (calculer_langues_rubriques_etape()) {
544
-		;
545
-	}
546
-
547
-	// articles
548
-	$s = sql_select(
549
-		'A.id_article AS id_article, R.lang AS lang',
550
-		'spip_articles AS A, spip_rubriques AS R',
551
-		"A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang"
552
-	);
553
-	while ($row = sql_fetch($s)) {
554
-		$id_article = $row['id_article'];
555
-		sql_updateq(
556
-			'spip_articles',
557
-			['lang' => $row['lang'], 'langue_choisie' => 'non'],
558
-			'id_article=' . intval($id_article)
559
-		);
560
-	}
561
-
562
-	if ($GLOBALS['meta']['multi_rubriques'] == 'oui') {
563
-		$langues = calculer_langues_utilisees();
564
-		ecrire_meta('langues_utilisees', $langues);
565
-	}
566
-
567
-	// avertir les plugins qui peuvent faire leur mises a jour egalement
568
-	pipeline('trig_calculer_langues_rubriques', '');
537
+    // rubriques (recursivite)
538
+    sql_updateq(
539
+        'spip_rubriques',
540
+        ['lang' => $GLOBALS['meta']['langue_site'], 'langue_choisie' => 'non'],
541
+        "id_parent=0 AND langue_choisie != 'oui'"
542
+    );
543
+    while (calculer_langues_rubriques_etape()) {
544
+        ;
545
+    }
546
+
547
+    // articles
548
+    $s = sql_select(
549
+        'A.id_article AS id_article, R.lang AS lang',
550
+        'spip_articles AS A, spip_rubriques AS R',
551
+        "A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang"
552
+    );
553
+    while ($row = sql_fetch($s)) {
554
+        $id_article = $row['id_article'];
555
+        sql_updateq(
556
+            'spip_articles',
557
+            ['lang' => $row['lang'], 'langue_choisie' => 'non'],
558
+            'id_article=' . intval($id_article)
559
+        );
560
+    }
561
+
562
+    if ($GLOBALS['meta']['multi_rubriques'] == 'oui') {
563
+        $langues = calculer_langues_utilisees();
564
+        ecrire_meta('langues_utilisees', $langues);
565
+    }
566
+
567
+    // avertir les plugins qui peuvent faire leur mises a jour egalement
568
+    pipeline('trig_calculer_langues_rubriques', '');
569 569
 }
570 570
 
571 571
 
@@ -582,80 +582,80 @@  discard block
 block discarded – undo
582 582
  *    Liste des langues utilisées séparées par des virgules
583 583
  **/
584 584
 function calculer_langues_utilisees($serveur = '') {
585
-	include_spip('public/interfaces');
586
-	include_spip('public/compiler');
587
-	include_spip('public/composer');
588
-	include_spip('public/phraser_html');
589
-	$langues = [];
590
-
591
-	$langues[$GLOBALS['meta']['langue_site']] = 1;
592
-
593
-	include_spip('base/objets');
594
-	$tables = lister_tables_objets_sql();
595
-	$trouver_table = charger_fonction('trouver_table', 'base');
596
-
597
-	foreach (array_keys($tables) as $t) {
598
-		$desc = $trouver_table($t, $serveur);
599
-		// c'est une table avec des langues
600
-		if (
601
-			$desc['exist']
602
-			and isset($desc['field']['lang'])
603
-			and isset($desc['field']['langue_choisie'])
604
-		) {
605
-			$boucle = new Boucle();
606
-			$boucle->show = $desc;
607
-			$boucle->nom = 'calculer_langues_utilisees';
608
-			$boucle->id_boucle = $desc['table_objet'];
609
-			$boucle->id_table = $desc['table_objet'];
610
-			$boucle->primary = $desc['key']['PRIMARY KEY'] ?? '';
611
-			$boucle->sql_serveur = $serveur;
612
-			$boucle->select[] = 'DISTINCT lang';
613
-			$boucle->from[$desc['table_objet']] = $t;
614
-			$boucle->separateur[] = ',';
615
-			$boucle->return = '$Pile[$SP][\'lang\']';
616
-			$boucle->iterateur = 'sql';
617
-
618
-			$boucle->descr['nom'] = 'calculer_langues_utilisees'; // eviter notice php
619
-			$boucle->descr['sourcefile'] = 'internal';
620
-			$boucle->descr['gram'] = 'html';
621
-
622
-			$boucle = pipeline('pre_boucle', $boucle);
623
-
624
-			if (
625
-				isset($desc['statut'])
626
-				and $desc['statut']
627
-			) {
628
-				$boucles = [
629
-					'calculer_langues_utilisees' => $boucle,
630
-				];
631
-				// generer un nom de fonction "anonyme" unique
632
-				do {
633
-					$functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . random_int(0, mt_getrandmax());
634
-				} while (function_exists($functionname));
635
-				$code = calculer_boucle('calculer_langues_utilisees', $boucles);
636
-				$code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code;
637
-				$code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();';
638
-				$res = '';
639
-				eval($code);
640
-				$res = explode(',', $res);
641
-				foreach ($res as $lang) {
642
-					$langues[$lang] = 1;
643
-				}
644
-			} else {
645
-				$res = sql_select(implode(',', $boucle->select), $boucle->from);
646
-				while ($row = sql_fetch($res)) {
647
-					$langues[$row['lang']] = 1;
648
-				}
649
-			}
650
-		}
651
-	}
652
-
653
-	$langues = array_filter(array_keys($langues));
654
-	sort($langues);
655
-	$langues = join(',', $langues);
656
-	spip_log("langues utilisees: $langues");
657
-
658
-	return $langues;
585
+    include_spip('public/interfaces');
586
+    include_spip('public/compiler');
587
+    include_spip('public/composer');
588
+    include_spip('public/phraser_html');
589
+    $langues = [];
590
+
591
+    $langues[$GLOBALS['meta']['langue_site']] = 1;
592
+
593
+    include_spip('base/objets');
594
+    $tables = lister_tables_objets_sql();
595
+    $trouver_table = charger_fonction('trouver_table', 'base');
596
+
597
+    foreach (array_keys($tables) as $t) {
598
+        $desc = $trouver_table($t, $serveur);
599
+        // c'est une table avec des langues
600
+        if (
601
+            $desc['exist']
602
+            and isset($desc['field']['lang'])
603
+            and isset($desc['field']['langue_choisie'])
604
+        ) {
605
+            $boucle = new Boucle();
606
+            $boucle->show = $desc;
607
+            $boucle->nom = 'calculer_langues_utilisees';
608
+            $boucle->id_boucle = $desc['table_objet'];
609
+            $boucle->id_table = $desc['table_objet'];
610
+            $boucle->primary = $desc['key']['PRIMARY KEY'] ?? '';
611
+            $boucle->sql_serveur = $serveur;
612
+            $boucle->select[] = 'DISTINCT lang';
613
+            $boucle->from[$desc['table_objet']] = $t;
614
+            $boucle->separateur[] = ',';
615
+            $boucle->return = '$Pile[$SP][\'lang\']';
616
+            $boucle->iterateur = 'sql';
617
+
618
+            $boucle->descr['nom'] = 'calculer_langues_utilisees'; // eviter notice php
619
+            $boucle->descr['sourcefile'] = 'internal';
620
+            $boucle->descr['gram'] = 'html';
621
+
622
+            $boucle = pipeline('pre_boucle', $boucle);
623
+
624
+            if (
625
+                isset($desc['statut'])
626
+                and $desc['statut']
627
+            ) {
628
+                $boucles = [
629
+                    'calculer_langues_utilisees' => $boucle,
630
+                ];
631
+                // generer un nom de fonction "anonyme" unique
632
+                do {
633
+                    $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . random_int(0, mt_getrandmax());
634
+                } while (function_exists($functionname));
635
+                $code = calculer_boucle('calculer_langues_utilisees', $boucles);
636
+                $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code;
637
+                $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();';
638
+                $res = '';
639
+                eval($code);
640
+                $res = explode(',', $res);
641
+                foreach ($res as $lang) {
642
+                    $langues[$lang] = 1;
643
+                }
644
+            } else {
645
+                $res = sql_select(implode(',', $boucle->select), $boucle->from);
646
+                while ($row = sql_fetch($res)) {
647
+                    $langues[$row['lang']] = 1;
648
+                }
649
+            }
650
+        }
651
+    }
652
+
653
+    $langues = array_filter(array_keys($langues));
654
+    sort($langues);
655
+    $langues = join(',', $langues);
656
+    spip_log("langues utilisees: $langues");
657
+
658
+    return $langues;
659 659
 }
660 660
 
661 661
 /**
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
  *     incluant les rubriques noeuds et toutes leurs descendances
673 673
  */
674 674
 function calcul_branche_in($id) {
675
-	$calcul_branche_in = charger_fonction('calcul_branche_in', 'inc');
675
+    $calcul_branche_in = charger_fonction('calcul_branche_in', 'inc');
676 676
 
677
-	return $calcul_branche_in($id);
677
+    return $calcul_branche_in($id);
678 678
 }
679 679
 
680 680
 /**
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
  *     incluant les rubriques transmises et toutes leurs parentées
693 693
  */
694 694
 function calcul_hierarchie_in($id, $tout = true) {
695
-	$calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc');
695
+    $calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc');
696 696
 
697
-	return $calcul_hierarchie_in($id, $tout);
697
+    return $calcul_hierarchie_in($id, $tout);
698 698
 }
699 699
 
700 700
 
@@ -715,40 +715,40 @@  discard block
 block discarded – undo
715 715
  *     incluant les rubriques noeuds et toutes leurs descendances
716 716
  */
717 717
 function inc_calcul_branche_in_dist($id) {
718
-	static $b = [];
719
-
720
-	// normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
721
-	if (!is_array($id)) {
722
-		$id = explode(',', $id);
723
-	}
724
-	$id = join(',', array_map('intval', $id));
725
-	if (isset($b[$id])) {
726
-		return $b[$id];
727
-	}
728
-
729
-	// Notre branche commence par la rubrique de depart
730
-	$branche = $r = $id;
731
-
732
-	// On ajoute une generation (les filles de la generation precedente)
733
-	// jusqu'a epuisement, en se protegeant des references circulaires
734
-	$maxiter = 10000;
735
-	while (
736
-		$maxiter-- and $filles = sql_allfetsel(
737
-			'id_rubrique',
738
-			'spip_rubriques',
739
-			sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT')
740
-		)
741
-	) {
742
-		$r = join(',', array_column($filles, 'id_rubrique'));
743
-		$branche .= ',' . $r;
744
-	}
745
-
746
-	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
747
-	if (strlen($branche) < 10000) {
748
-		$b[$id] = $branche;
749
-	}
750
-
751
-	return $branche;
718
+    static $b = [];
719
+
720
+    // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
721
+    if (!is_array($id)) {
722
+        $id = explode(',', $id);
723
+    }
724
+    $id = join(',', array_map('intval', $id));
725
+    if (isset($b[$id])) {
726
+        return $b[$id];
727
+    }
728
+
729
+    // Notre branche commence par la rubrique de depart
730
+    $branche = $r = $id;
731
+
732
+    // On ajoute une generation (les filles de la generation precedente)
733
+    // jusqu'a epuisement, en se protegeant des references circulaires
734
+    $maxiter = 10000;
735
+    while (
736
+        $maxiter-- and $filles = sql_allfetsel(
737
+            'id_rubrique',
738
+            'spip_rubriques',
739
+            sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT')
740
+        )
741
+    ) {
742
+        $r = join(',', array_column($filles, 'id_rubrique'));
743
+        $branche .= ',' . $r;
744
+    }
745
+
746
+    # securite pour ne pas plomber la conso memoire sur les sites prolifiques
747
+    if (strlen($branche) < 10000) {
748
+        $b[$id] = $branche;
749
+    }
750
+
751
+    return $branche;
752 752
 }
753 753
 
754 754
 
@@ -770,45 +770,45 @@  discard block
 block discarded – undo
770 770
  *     incluant les rubriques transmises et toutes leurs parentées
771 771
  */
772 772
 function inc_calcul_hierarchie_in_dist($id, $tout = true) {
773
-	static $b = [];
774
-
775
-	// normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
776
-	if (!is_array($id)) {
777
-		$id = explode(',', $id);
778
-	}
779
-	$id = join(',', array_map('intval', $id));
780
-
781
-	if (isset($b[$id])) {
782
-		// Notre branche commence par la rubrique de depart si $tout=true
783
-		return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id];
784
-	}
785
-
786
-	$hier = '';
787
-
788
-	// On ajoute une generation (les filles de la generation precedente)
789
-	// jusqu'a epuisement, en se protegeant des references circulaires
790
-	$ids_nouveaux_parents = $id;
791
-	$maxiter = 10000;
792
-	while (
793
-		$maxiter-- and $parents = sql_allfetsel(
794
-			'id_parent',
795
-			'spip_rubriques',
796
-			sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT')
797
-		)
798
-	) {
799
-		$ids_nouveaux_parents = join(',', array_column($parents, 'id_parent'));
800
-		$hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : '');
801
-	}
802
-
803
-	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
804
-	if (strlen($hier) < 10000) {
805
-		$b[$id] = $hier;
806
-	}
807
-
808
-	// Notre branche commence par la rubrique de depart si $tout=true
809
-	$hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier;
810
-
811
-	return $hier;
773
+    static $b = [];
774
+
775
+    // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
776
+    if (!is_array($id)) {
777
+        $id = explode(',', $id);
778
+    }
779
+    $id = join(',', array_map('intval', $id));
780
+
781
+    if (isset($b[$id])) {
782
+        // Notre branche commence par la rubrique de depart si $tout=true
783
+        return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id];
784
+    }
785
+
786
+    $hier = '';
787
+
788
+    // On ajoute une generation (les filles de la generation precedente)
789
+    // jusqu'a epuisement, en se protegeant des references circulaires
790
+    $ids_nouveaux_parents = $id;
791
+    $maxiter = 10000;
792
+    while (
793
+        $maxiter-- and $parents = sql_allfetsel(
794
+            'id_parent',
795
+            'spip_rubriques',
796
+            sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT')
797
+        )
798
+    ) {
799
+        $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent'));
800
+        $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : '');
801
+    }
802
+
803
+    # securite pour ne pas plomber la conso memoire sur les sites prolifiques
804
+    if (strlen($hier) < 10000) {
805
+        $b[$id] = $hier;
806
+    }
807
+
808
+    // Notre branche commence par la rubrique de depart si $tout=true
809
+    $hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier;
810
+
811
+    return $hier;
812 812
 }
813 813
 
814 814
 
@@ -826,47 +826,47 @@  discard block
 block discarded – undo
826 826
  * @return void
827 827
  **/
828 828
 function calculer_prochain_postdate($check = false) {
829
-	include_spip('base/abstract_sql');
830
-	if ($check) {
831
-		$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
832
-			'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
833
-
834
-		$r = sql_select(
835
-			'DISTINCT A.id_rubrique AS id',
836
-			'spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique',
837
-			"R.statut != 'publie' AND A.statut='publie'$postdates"
838
-		);
839
-		while ($row = sql_fetch($r)) {
840
-			publier_branche_rubrique($row['id']);
841
-		}
842
-
843
-		pipeline('trig_calculer_prochain_postdate', '');
844
-	}
845
-
846
-	$t = sql_fetsel(
847
-		'date',
848
-		'spip_articles',
849
-		"statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')),
850
-		'',
851
-		'date',
852
-		'1'
853
-	);
854
-
855
-	if ($t) {
856
-		$t = $t['date'];
857
-		if (
858
-			!isset($GLOBALS['meta']['date_prochain_postdate'])
859
-			or $t <> $GLOBALS['meta']['date_prochain_postdate']
860
-		) {
861
-			ecrire_meta('date_prochain_postdate', strtotime($t));
862
-			ecrire_meta('derniere_modif', time());
863
-		}
864
-	} else {
865
-		effacer_meta('date_prochain_postdate');
866
-		ecrire_meta('derniere_modif', time());
867
-	}
868
-
869
-	spip_log("prochain postdate: $t");
829
+    include_spip('base/abstract_sql');
830
+    if ($check) {
831
+        $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
832
+            'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
833
+
834
+        $r = sql_select(
835
+            'DISTINCT A.id_rubrique AS id',
836
+            'spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique',
837
+            "R.statut != 'publie' AND A.statut='publie'$postdates"
838
+        );
839
+        while ($row = sql_fetch($r)) {
840
+            publier_branche_rubrique($row['id']);
841
+        }
842
+
843
+        pipeline('trig_calculer_prochain_postdate', '');
844
+    }
845
+
846
+    $t = sql_fetsel(
847
+        'date',
848
+        'spip_articles',
849
+        "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')),
850
+        '',
851
+        'date',
852
+        '1'
853
+    );
854
+
855
+    if ($t) {
856
+        $t = $t['date'];
857
+        if (
858
+            !isset($GLOBALS['meta']['date_prochain_postdate'])
859
+            or $t <> $GLOBALS['meta']['date_prochain_postdate']
860
+        ) {
861
+            ecrire_meta('date_prochain_postdate', strtotime($t));
862
+            ecrire_meta('derniere_modif', time());
863
+        }
864
+    } else {
865
+        effacer_meta('date_prochain_postdate');
866
+        ecrire_meta('derniere_modif', time());
867
+    }
868
+
869
+    spip_log("prochain postdate: $t");
870 870
 }
871 871
 
872 872
 /**
@@ -891,62 +891,62 @@  discard block
 block discarded – undo
891 891
  */
892 892
 function creer_rubrique_nommee($titre, $id_parent = 0, $serveur = '') {
893 893
 
894
-	// eclater l'arborescence demandee
895
-	// echapper les </multi> et autres balises fermantes html
896
-	$titre = preg_replace(',</([a-z][^>]*)>,ims', "<@\\1>", $titre);
897
-	$arbo = explode('/', preg_replace(',^/,', '', $titre));
898
-	include_spip('base/abstract_sql');
899
-	foreach ($arbo as $titre) {
900
-		// retablir les </multi> et autres balises fermantes html
901
-		$titre = preg_replace(',<@([a-z][^>]*)>,ims', "</\\1>", $titre);
902
-		$r = sql_getfetsel(
903
-			'id_rubrique',
904
-			'spip_rubriques',
905
-			'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent),
906
-			$groupby = [],
907
-			$orderby = [],
908
-			$limit = '',
909
-			$having = [],
910
-			$serveur
911
-		);
912
-		if ($r !== null) {
913
-			$id_parent = $r;
914
-		} else {
915
-			$id_rubrique = sql_insertq('spip_rubriques', [
916
-					'titre' => $titre,
917
-					'id_parent' => $id_parent,
918
-					'statut' => 'prepa'
919
-				], $desc = [], $serveur);
920
-			if ($id_parent > 0) {
921
-				$data = sql_fetsel(
922
-					'id_secteur,lang',
923
-					'spip_rubriques',
924
-					"id_rubrique=$id_parent",
925
-					$groupby = [],
926
-					$orderby = [],
927
-					$limit = '',
928
-					$having = [],
929
-					$serveur
930
-				);
931
-				$id_secteur = $data['id_secteur'];
932
-				$lang = $data['lang'];
933
-			} else {
934
-				$id_secteur = $id_rubrique;
935
-				$lang = $GLOBALS['meta']['langue_site'];
936
-			}
937
-
938
-			sql_updateq(
939
-				'spip_rubriques',
940
-				['id_secteur' => $id_secteur, 'lang' => $lang],
941
-				'id_rubrique=' . intval($id_rubrique),
942
-				$desc = '',
943
-				$serveur
944
-			);
945
-
946
-			// pour la recursion
947
-			$id_parent = $id_rubrique;
948
-		}
949
-	}
950
-
951
-	return intval($id_parent);
894
+    // eclater l'arborescence demandee
895
+    // echapper les </multi> et autres balises fermantes html
896
+    $titre = preg_replace(',</([a-z][^>]*)>,ims', "<@\\1>", $titre);
897
+    $arbo = explode('/', preg_replace(',^/,', '', $titre));
898
+    include_spip('base/abstract_sql');
899
+    foreach ($arbo as $titre) {
900
+        // retablir les </multi> et autres balises fermantes html
901
+        $titre = preg_replace(',<@([a-z][^>]*)>,ims', "</\\1>", $titre);
902
+        $r = sql_getfetsel(
903
+            'id_rubrique',
904
+            'spip_rubriques',
905
+            'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent),
906
+            $groupby = [],
907
+            $orderby = [],
908
+            $limit = '',
909
+            $having = [],
910
+            $serveur
911
+        );
912
+        if ($r !== null) {
913
+            $id_parent = $r;
914
+        } else {
915
+            $id_rubrique = sql_insertq('spip_rubriques', [
916
+                    'titre' => $titre,
917
+                    'id_parent' => $id_parent,
918
+                    'statut' => 'prepa'
919
+                ], $desc = [], $serveur);
920
+            if ($id_parent > 0) {
921
+                $data = sql_fetsel(
922
+                    'id_secteur,lang',
923
+                    'spip_rubriques',
924
+                    "id_rubrique=$id_parent",
925
+                    $groupby = [],
926
+                    $orderby = [],
927
+                    $limit = '',
928
+                    $having = [],
929
+                    $serveur
930
+                );
931
+                $id_secteur = $data['id_secteur'];
932
+                $lang = $data['lang'];
933
+            } else {
934
+                $id_secteur = $id_rubrique;
935
+                $lang = $GLOBALS['meta']['langue_site'];
936
+            }
937
+
938
+            sql_updateq(
939
+                'spip_rubriques',
940
+                ['id_secteur' => $id_secteur, 'lang' => $lang],
941
+                'id_rubrique=' . intval($id_rubrique),
942
+                $desc = '',
943
+                $serveur
944
+            );
945
+
946
+            // pour la recursion
947
+            $id_parent = $id_rubrique;
948
+        }
949
+    }
950
+
951
+    return intval($id_parent);
952 952
 }
Please login to merge, or discard this patch.
ecrire/inc/bandeau.php 1 patch
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/boutons');
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
  *     Contexte
38 38
  **/
39 39
 function definir_barre_contexte($contexte = null) {
40
-	if (is_null($contexte)) {
41
-		$contexte = $_GET;
42
-	} elseif (is_string($contexte)) {
43
-		$contexte = unserialize($contexte);
44
-	}
45
-	if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) {
46
-		if (!function_exists('trouver_objet_exec')) {
47
-			include_spip('inc/pipelines_ecrire');
48
-		}
49
-		if ($e = trouver_objet_exec($contexte['exec'])) {
50
-			$_id = $e['id_table_objet'];
51
-			if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) {
52
-				$table = $e['table_objet_sql'];
53
-				$row = sql_fetsel('*', $table, "$_id=" . intval($id));
54
-				if (isset($row['id_rubrique'])) {
55
-					$contexte['id_rubrique'] = $row['id_rubrique'];
56
-					if (isset($row['id_secteur'])) {
57
-						$contexte['id_secteur'] = $row['id_secteur'];
58
-					}
59
-				} elseif (isset($row['id_groupe'])) {
60
-					// TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
61
-					$contexte['id_groupe'] = $row['id_groupe'];
62
-				}
63
-			}
64
-		}
65
-	}
66
-	return $contexte;
40
+    if (is_null($contexte)) {
41
+        $contexte = $_GET;
42
+    } elseif (is_string($contexte)) {
43
+        $contexte = unserialize($contexte);
44
+    }
45
+    if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) {
46
+        if (!function_exists('trouver_objet_exec')) {
47
+            include_spip('inc/pipelines_ecrire');
48
+        }
49
+        if ($e = trouver_objet_exec($contexte['exec'])) {
50
+            $_id = $e['id_table_objet'];
51
+            if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) {
52
+                $table = $e['table_objet_sql'];
53
+                $row = sql_fetsel('*', $table, "$_id=" . intval($id));
54
+                if (isset($row['id_rubrique'])) {
55
+                    $contexte['id_rubrique'] = $row['id_rubrique'];
56
+                    if (isset($row['id_secteur'])) {
57
+                        $contexte['id_secteur'] = $row['id_secteur'];
58
+                    }
59
+                } elseif (isset($row['id_groupe'])) {
60
+                    // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
61
+                    $contexte['id_groupe'] = $row['id_groupe'];
62
+                }
63
+            }
64
+        }
65
+    }
66
+    return $contexte;
67 67
 }
68 68
 
69 69
 /**
@@ -79,92 +79,92 @@  discard block
 block discarded – undo
79 79
  * @return array
80 80
  */
81 81
 function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) {
82
-	include_spip('inc/autoriser');
83
-	$boutons_admin = [];
82
+    include_spip('inc/autoriser');
83
+    $boutons_admin = [];
84 84
 
85
-	// les boutons du core, issus de ecrire/paquet.xml
86
-	$liste_boutons = [];
85
+    // les boutons du core, issus de ecrire/paquet.xml
86
+    $liste_boutons = [];
87 87
 
88
-	// ajouter les boutons issus des plugin via paquet.xml
89
-	if (
90
-		function_exists('boutons_plugins')
91
-		and is_array($liste_boutons_plugins = boutons_plugins())
92
-	) {
93
-		$liste_boutons = &$liste_boutons_plugins;
94
-	}
88
+    // ajouter les boutons issus des plugin via paquet.xml
89
+    if (
90
+        function_exists('boutons_plugins')
91
+        and is_array($liste_boutons_plugins = boutons_plugins())
92
+    ) {
93
+        $liste_boutons = &$liste_boutons_plugins;
94
+    }
95 95
 
96
-	foreach ($liste_boutons as $id => $infos) {
97
-		$parent = '';
98
-		// les boutons principaux ne sont pas soumis a autorisation
99
-		if (
100
-			!isset($infos['parent'])
101
-			or !($parent = $infos['parent'])
102
-			or !$autorise
103
-			or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
104
-		) {
105
-			if (
106
-				$parent
107
-				and $parent = preg_replace(',^bando_,', 'menu_', $parent)
108
-				and isset($boutons_admin[$parent])
109
-			) {
110
-				if (!is_array($boutons_admin[$parent]->sousmenu)) {
111
-					$boutons_admin[$parent]->sousmenu = [];
112
-				}
113
-				$position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu);
114
-				if ($position < 0) {
115
-					$position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
116
-				}
117
-				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
118
-					+ [
119
-						$id => new Bouton(
120
-							($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
121
-							$infos['titre'],  // titre
122
-							(isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
123
-							(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
124
-						)
125
-					]
126
-					+ array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
127
-			}
128
-			if (
129
-				!$parent
130
-				// provisoire, eviter les vieux boutons
131
-				and (!in_array($id, ['forum', 'statistiques_visites']))
132
-				and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
133
-			) {
134
-				$position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin);
135
-				$boutons_admin = array_slice($boutons_admin, 0, $position)
136
-					+ [
137
-						$id => new Bouton(
138
-							($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
139
-							$infos['titre'],  // titre
140
-							(isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
141
-							(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
142
-						)
143
-					]
144
-					+ array_slice($boutons_admin, $position, 100);
145
-			}
146
-		}
147
-	}
148
-	$boutons_admin = pipeline('ajouter_menus', $boutons_admin);
96
+    foreach ($liste_boutons as $id => $infos) {
97
+        $parent = '';
98
+        // les boutons principaux ne sont pas soumis a autorisation
99
+        if (
100
+            !isset($infos['parent'])
101
+            or !($parent = $infos['parent'])
102
+            or !$autorise
103
+            or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
104
+        ) {
105
+            if (
106
+                $parent
107
+                and $parent = preg_replace(',^bando_,', 'menu_', $parent)
108
+                and isset($boutons_admin[$parent])
109
+            ) {
110
+                if (!is_array($boutons_admin[$parent]->sousmenu)) {
111
+                    $boutons_admin[$parent]->sousmenu = [];
112
+                }
113
+                $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu);
114
+                if ($position < 0) {
115
+                    $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
116
+                }
117
+                $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
118
+                    + [
119
+                        $id => new Bouton(
120
+                            ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
121
+                            $infos['titre'],  // titre
122
+                            (isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
123
+                            (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
124
+                        )
125
+                    ]
126
+                    + array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
127
+            }
128
+            if (
129
+                !$parent
130
+                // provisoire, eviter les vieux boutons
131
+                and (!in_array($id, ['forum', 'statistiques_visites']))
132
+                and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
133
+            ) {
134
+                $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin);
135
+                $boutons_admin = array_slice($boutons_admin, 0, $position)
136
+                    + [
137
+                        $id => new Bouton(
138
+                            ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
139
+                            $infos['titre'],  // titre
140
+                            (isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
141
+                            (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
142
+                        )
143
+                    ]
144
+                    + array_slice($boutons_admin, $position, 100);
145
+            }
146
+        }
147
+    }
148
+    $boutons_admin = pipeline('ajouter_menus', $boutons_admin);
149 149
 
150
-	// définir les favoris et positions d’origine
151
-	if ($boutons_admin) {
152
-		$menus_favoris = obtenir_menus_favoris();
153
-		$i = 1;
154
-		foreach ($boutons_admin as $key => $menu) {
155
-			$menu->favori = table_valeur($menus_favoris, $key, false);
156
-			$menu->position = $i++;
157
-			if ($menu->sousmenu) {
158
-				$j = 1;
159
-				foreach ($menu->sousmenu as $key => $bouton) {
160
-					$bouton->favori = table_valeur($menus_favoris, $key, false);
161
-					$bouton->position = $j++;
162
-				}
163
-			}
164
-		}
165
-	}
150
+    // définir les favoris et positions d’origine
151
+    if ($boutons_admin) {
152
+        $menus_favoris = obtenir_menus_favoris();
153
+        $i = 1;
154
+        foreach ($boutons_admin as $key => $menu) {
155
+            $menu->favori = table_valeur($menus_favoris, $key, false);
156
+            $menu->position = $i++;
157
+            if ($menu->sousmenu) {
158
+                $j = 1;
159
+                foreach ($menu->sousmenu as $key => $bouton) {
160
+                    $bouton->favori = table_valeur($menus_favoris, $key, false);
161
+                    $bouton->position = $j++;
162
+                }
163
+            }
164
+        }
165
+    }
166 166
 
167
-	return $boutons_admin;
167
+    return $boutons_admin;
168 168
 }
169 169
 
170 170
 /**
@@ -176,22 +176,22 @@  discard block
 block discarded – undo
176 176
  * @return Bouton[]
177 177
  */
178 178
 function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) {
179
-	foreach ($menus as $menu) {
180
-		if ($menu->sousmenu) {
181
-			$libelles = $isfavoris = $favoris = [];
182
-			foreach ($menu->sousmenu as $key => $item) {
183
-				$libelles[$key] = strtolower(translitteration(_T($item->libelle)));
184
-				$isfavoris[$key] = (bool)$item->favori;
185
-				$favoris[$key] = $item->favori;
186
-			}
187
-			if ($avec_favoris) {
188
-				array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
189
-			} else {
190
-				array_multisort($libelles, SORT_ASC, $menu->sousmenu);
191
-			}
192
-		}
193
-	}
194
-	return $menus;
179
+    foreach ($menus as $menu) {
180
+        if ($menu->sousmenu) {
181
+            $libelles = $isfavoris = $favoris = [];
182
+            foreach ($menu->sousmenu as $key => $item) {
183
+                $libelles[$key] = strtolower(translitteration(_T($item->libelle)));
184
+                $isfavoris[$key] = (bool)$item->favori;
185
+                $favoris[$key] = $item->favori;
186
+            }
187
+            if ($avec_favoris) {
188
+                array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
189
+            } else {
190
+                array_multisort($libelles, SORT_ASC, $menu->sousmenu);
191
+            }
192
+        }
193
+    }
194
+    return $menus;
195 195
 }
196 196
 
197 197
 /**
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
  * @return Bouton[]
203 203
  */
204 204
 function trier_boutons_enfants_par_favoris_alpha($menus) {
205
-	return trier_boutons_enfants_par_alpha($menus, true);
205
+    return trier_boutons_enfants_par_alpha($menus, true);
206 206
 }
207 207
 
208 208
 
@@ -215,23 +215,23 @@  discard block
 block discarded – undo
215 215
  * @return string
216 216
  */
217 217
 function bandeau_creer_url($url, $args = '', $contexte = null) {
218
-	if (!preg_match(',[\/\?],', $url)) {
219
-		$url = generer_url_ecrire($url, $args, true);
220
-		// recuperer les parametres du contexte demande par l'url sous la forme
221
-		// &truc=@machin@
222
-		// @machin@ etant remplace par _request('machin')
223
-		$url = str_replace('&amp;', '&', $url);
224
-		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
225
-			if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) {
226
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique']));
227
-			}
228
-			$val = _request($matches[2], $contexte);
229
-			$url = parametre_url($url, $matches[1], $val ?: '', '&');
230
-		}
231
-		$url = str_replace('&', '&amp;', $url);
232
-	}
218
+    if (!preg_match(',[\/\?],', $url)) {
219
+        $url = generer_url_ecrire($url, $args, true);
220
+        // recuperer les parametres du contexte demande par l'url sous la forme
221
+        // &truc=@machin@
222
+        // @machin@ etant remplace par _request('machin')
223
+        $url = str_replace('&amp;', '&', $url);
224
+        while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
225
+            if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) {
226
+                $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique']));
227
+            }
228
+            $val = _request($matches[2], $contexte);
229
+            $url = parametre_url($url, $matches[1], $val ?: '', '&');
230
+        }
231
+        $url = str_replace('&', '&amp;', $url);
232
+    }
233 233
 
234
-	return $url;
234
+    return $url;
235 235
 }
236 236
 
237 237
 /**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  *     Code HTML du bandeau
242 242
  */
243 243
 function inc_bandeau_dist() {
244
-	return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
244
+    return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
245 245
 }
246 246
 
247 247
 
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
  * @return array
251 251
  */
252 252
 function obtenir_menus_favoris() {
253
-	if (
254
-		isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
255
-		and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
256
-		and $GLOBALS['visiteur_session']['prefs']['menus_favoris']
257
-	) {
258
-		return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
259
-	}
260
-	$definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
261
-	return $definir_menus_favoris();
253
+    if (
254
+        isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
255
+        and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
256
+        and $GLOBALS['visiteur_session']['prefs']['menus_favoris']
257
+    ) {
258
+        return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
259
+    }
260
+    $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
261
+    return $definir_menus_favoris();
262 262
 }
Please login to merge, or discard this patch.
ecrire/inc/presentation_mini.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Affichage
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return string Code HTML
26 26
  */
27 27
 function debut_grand_cadre() {
28
- return "\n<div class = 'table_page'>\n";
28
+    return "\n<div class = 'table_page'>\n";
29 29
 }
30 30
 
31 31
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return string Code HTML
35 35
  */
36 36
 function fin_grand_cadre() {
37
- return "\n</div>";
37
+    return "\n</div>";
38 38
 }
39 39
 
40 40
 // Debut de la colonne de gauche
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
  * @return string Code HTML
50 50
  */
51 51
 function debut_gauche() {
52
-	return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n";
52
+    return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n";
53 53
 }
54 54
 
55 55
 /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
  * @return string Code HTML
59 59
  */
60 60
 function fin_gauche() {
61
- return "</div></div><br class = 'nettoyeur' />";
61
+    return "</div></div><br class = 'nettoyeur' />";
62 62
 }
63 63
 
64 64
 /**
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
  * @return string Code HTML
68 68
  */
69 69
 function creer_colonne_droite() {
70
-	static $deja_colonne_droite;
71
-	if ($deja_colonne_droite) {
72
-		return '';
73
-	}
74
-	$deja_colonne_droite = true;
70
+    static $deja_colonne_droite;
71
+    if ($deja_colonne_droite) {
72
+        return '';
73
+    }
74
+    $deja_colonne_droite = true;
75 75
 
76
-	return "\n</div><div id='extra' class='lat' role='complementary'>";
76
+    return "\n</div><div id='extra' class='lat' role='complementary'>";
77 77
 }
78 78
 
79 79
 /**
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
  * @return string Code HTML
83 83
  */
84 84
 function debut_droite() {
85
-	return liste_objets_bloques(_request('exec'))
86
-	. creer_colonne_droite()
87
-	. '</div>'
88
-	. "\n<div id='contenu'>";
85
+    return liste_objets_bloques(_request('exec'))
86
+    . creer_colonne_droite()
87
+    . '</div>'
88
+    . "\n<div id='contenu'>";
89 89
 }
90 90
 
91 91
 /**
@@ -107,31 +107,31 @@  discard block
 block discarded – undo
107 107
  *     Code HTML
108 108
  **/
109 109
 function liste_objets_bloques($exec, $contexte = [], $auteur = null) {
110
-	$res = '';
111
-	if ($GLOBALS['meta']['articles_modif'] != 'non') {
112
-		include_spip('inc/drapeau_edition');
113
-		if (is_null($auteur)) {
114
-			$auteur = $GLOBALS['visiteur_session'];
115
-		}
116
-		if (
117
-			$en_cours = trouver_objet_exec($exec)
118
-			and $en_cours['edition']
119
-			and $type = $en_cours['type']
120
-			and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
121
-				or $id = _request($en_cours['id_table_objet']))
122
-		) {
123
-			// marquer le fait que l'objet est ouvert en edition par toto
124
-			// a telle date ; une alerte sera donnee aux autres redacteurs
125
-			signale_edition($id, $auteur, $type);
126
-		}
127
-
128
-		$objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
129
-		if (count($objets_ouverts)) {
130
-			$res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]);
131
-		}
132
-	}
133
-
134
-	return $res;
110
+    $res = '';
111
+    if ($GLOBALS['meta']['articles_modif'] != 'non') {
112
+        include_spip('inc/drapeau_edition');
113
+        if (is_null($auteur)) {
114
+            $auteur = $GLOBALS['visiteur_session'];
115
+        }
116
+        if (
117
+            $en_cours = trouver_objet_exec($exec)
118
+            and $en_cours['edition']
119
+            and $type = $en_cours['type']
120
+            and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
121
+                or $id = _request($en_cours['id_table_objet']))
122
+        ) {
123
+            // marquer le fait que l'objet est ouvert en edition par toto
124
+            // a telle date ; une alerte sera donnee aux autres redacteurs
125
+            signale_edition($id, $auteur, $type);
126
+        }
127
+
128
+        $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
129
+        if (count($objets_ouverts)) {
130
+            $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]);
131
+        }
132
+    }
133
+
134
+    return $res;
135 135
 }
136 136
 
137 137
 
@@ -145,20 +145,20 @@  discard block
 block discarded – undo
145 145
  * @return string Code HTML
146 146
  **/
147 147
 function fin_page() {
148
-	include_spip('inc/pipelines');
149
-	// avec &var_profile=1 on a le tableau de mesures SQL
150
-	$debug = ((_request('exec') !== 'valider_xml')
151
-		and ((_request('var_mode') == 'debug')
152
-			or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
153
-			and isset($_COOKIE['spip_admin'])));
154
-	$t = '</div><div id="pied"><div class="largeur">'
155
-		. recuperer_fond('prive/squelettes/inclure/pied')
156
-		. '</div>'
157
-		. '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page()
158
-		. ($debug ? erreur_squelette() : '')
159
-		. "</body></html>\n";
160
-
161
-	return f_queue($t);
148
+    include_spip('inc/pipelines');
149
+    // avec &var_profile=1 on a le tableau de mesures SQL
150
+    $debug = ((_request('exec') !== 'valider_xml')
151
+        and ((_request('var_mode') == 'debug')
152
+            or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
153
+            and isset($_COOKIE['spip_admin'])));
154
+    $t = '</div><div id="pied"><div class="largeur">'
155
+        . recuperer_fond('prive/squelettes/inclure/pied')
156
+        . '</div>'
157
+        . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page()
158
+        . ($debug ? erreur_squelette() : '')
159
+        . "</body></html>\n";
160
+
161
+    return f_queue($t);
162 162
 }
163 163
 
164 164
 /**
@@ -173,22 +173,22 @@  discard block
 block discarded – undo
173 173
  * @return string Code HTML
174 174
  **/
175 175
 function html_tests_js() {
176
-	if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
177
-		// pour le pied de page (deja defini si on est validation XML)
178
-		define(
179
-			'_TESTER_NOSCRIPT',
180
-			"<noscript>\n<div style='display:none;'><img src='"
181
-			. generer_url_ecrire('test_ajax', 'js=-1')
182
-			. "' width='1' height='1' alt='' /></div></noscript>\n"
183
-		);
184
-	}
185
-
186
-	$rejouer = '';
187
-	if (defined('_SESSION_REJOUER')) {
188
-		$rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
189
-	}
190
-
191
-	return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
176
+    if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
177
+        // pour le pied de page (deja defini si on est validation XML)
178
+        define(
179
+            '_TESTER_NOSCRIPT',
180
+            "<noscript>\n<div style='display:none;'><img src='"
181
+            . generer_url_ecrire('test_ajax', 'js=-1')
182
+            . "' width='1' height='1' alt='' /></div></noscript>\n"
183
+        );
184
+    }
185
+
186
+    $rejouer = '';
187
+    if (defined('_SESSION_REJOUER')) {
188
+        $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
189
+    }
190
+
191
+    return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
192 192
 }
193 193
 
194 194
 /**
@@ -198,25 +198,25 @@  discard block
 block discarded – undo
198 198
  **/
199 199
 function info_maj_spip() {
200 200
 
201
-	$maj = $GLOBALS['meta']['info_maj_spip'] ?? null;
202
-	if (!$maj) {
203
-		return '';
204
-	}
201
+    $maj = $GLOBALS['meta']['info_maj_spip'] ?? null;
202
+    if (!$maj) {
203
+        return '';
204
+    }
205 205
 
206
-	$maj = explode('|', $maj);
207
-	// c'est une ancienne notif, on a fait la maj depuis !
208
-	if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
209
-		return '';
210
-	}
206
+    $maj = explode('|', $maj);
207
+    // c'est une ancienne notif, on a fait la maj depuis !
208
+    if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
209
+        return '';
210
+    }
211 211
 
212
-	if (!autoriser('webmestre')) {
213
-		return '';
214
-	}
212
+    if (!autoriser('webmestre')) {
213
+        return '';
214
+    }
215 215
 
216
-	array_shift($maj);
217
-	$maj = implode('|', $maj);
216
+    array_shift($maj);
217
+    $maj = implode('|', $maj);
218 218
 
219
-	return "$maj<br />";
219
+    return "$maj<br />";
220 220
 }
221 221
 
222 222
 /**
@@ -227,47 +227,47 @@  discard block
 block discarded – undo
227 227
  **/
228 228
 function info_copyright() {
229 229
 
230
-	$version = $GLOBALS['spip_version_affichee'];
231
-
232
-	//
233
-	// Mention, le cas echeant, de la revision SVN courante
234
-	//
235
-	if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
236
-		if ($vcs['vcs'] === 'GIT') {
237
-			$url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
238
-		} elseif ($vcs['vcs'] === 'SVN') {
239
-			$url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
240
-		} else {
241
-			$url = '';
242
-		}
243
-		// affichage "GIT [master: abcdef]"
244
-		$commit = $vcs['commit_short'] ?? $vcs['commit'];
245
-		if ($url) {
246
-			$commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
247
-		}
248
-		if ($vcs['branch']) {
249
-			$commit = $vcs['branch'] . ': ' . $commit;
250
-		}
251
-		$version .= " {$vcs['vcs']} [$commit]";
252
-	}
253
-
254
-	// et la version de l'ecran de securite
255
-	$secu = defined('_ECRAN_SECURITE')
256
-		? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
257
-		: '';
258
-
259
-	return _T(
260
-		'info_copyright',
261
-		[
262
-			'spip' => "<b>SPIP $version</b> ",
263
-			'lien_gpl' =>
264
-				"<a href='" . generer_url_ecrire(
265
-					'aide',
266
-					'aide=licence&var_lang=' . $GLOBALS['spip_lang']
267
-				) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
268
-		]
269
-	)
270
-	. $secu;
230
+    $version = $GLOBALS['spip_version_affichee'];
231
+
232
+    //
233
+    // Mention, le cas echeant, de la revision SVN courante
234
+    //
235
+    if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
236
+        if ($vcs['vcs'] === 'GIT') {
237
+            $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
238
+        } elseif ($vcs['vcs'] === 'SVN') {
239
+            $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
240
+        } else {
241
+            $url = '';
242
+        }
243
+        // affichage "GIT [master: abcdef]"
244
+        $commit = $vcs['commit_short'] ?? $vcs['commit'];
245
+        if ($url) {
246
+            $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
247
+        }
248
+        if ($vcs['branch']) {
249
+            $commit = $vcs['branch'] . ': ' . $commit;
250
+        }
251
+        $version .= " {$vcs['vcs']} [$commit]";
252
+    }
253
+
254
+    // et la version de l'ecran de securite
255
+    $secu = defined('_ECRAN_SECURITE')
256
+        ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
257
+        : '';
258
+
259
+    return _T(
260
+        'info_copyright',
261
+        [
262
+            'spip' => "<b>SPIP $version</b> ",
263
+            'lien_gpl' =>
264
+                "<a href='" . generer_url_ecrire(
265
+                    'aide',
266
+                    'aide=licence&var_lang=' . $GLOBALS['spip_lang']
267
+                ) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
268
+        ]
269
+    )
270
+    . $secu;
271 271
 }
272 272
 
273 273
 /**
@@ -282,17 +282,17 @@  discard block
 block discarded – undo
282 282
  * @return string             Code HTML
283 283
  **/
284 284
 function formulaire_recherche($page, $complement = '') {
285
-	$recherche = _request('recherche');
286
-	$recherche_aff = entites_html($recherche);
287
-	if (!strlen($recherche)) {
288
-		$recherche_aff = _T('info_rechercher');
289
-		$onfocus = " onfocus=\"this.value='';\"";
290
-	} else {
291
-		$onfocus = '';
292
-	}
293
-
294
-	$form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
295
-	$form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
296
-
297
-	return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
285
+    $recherche = _request('recherche');
286
+    $recherche_aff = entites_html($recherche);
287
+    if (!strlen($recherche)) {
288
+        $recherche_aff = _T('info_rechercher');
289
+        $onfocus = " onfocus=\"this.value='';\"";
290
+    } else {
291
+        $onfocus = '';
292
+    }
293
+
294
+    $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
295
+    $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
296
+
297
+    return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
298 298
 }
Please login to merge, or discard this patch.
ecrire/inc/presenter_enfants.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/autoriser');
@@ -30,80 +30,80 @@  discard block
 block discarded – undo
30 30
  *  Un tableau des sous rubriques
31 31
  */
32 32
 function enfant_rub($collection, $debut = 0, $limite = 500) {
33
-	$voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non');
34
-	$logo = '';
35
-
36
-	if ($voir_logo) {
37
-		$chercher_logo = charger_fonction('chercher_logo', 'inc');
38
-		include_spip('inc/filtres_images_mini');
39
-	}
40
-
41
-	$res = [];
42
-
43
-	$result = sql_select(
44
-		'id_rubrique, id_parent, titre, descriptif, lang',
45
-		'spip_rubriques',
46
-		'id_parent=' . intval($collection),
47
-		'',
48
-		'0+titre,titre',
49
-		"$debut,$limite"
50
-	);
51
-	while ($row = sql_fetch($result)) {
52
-		$id_rubrique = $row['id_rubrique'];
53
-		$id_parent = $row['id_parent'];
54
-		// pour etre sur de passer par tous les traitements
55
-		$titre = generer_info_entite($id_rubrique, 'rubrique', 'titre');
56
-		if ('' !== ($rang = recuperer_numero($row['titre']))) {
57
-			$rang = "<span class='rang'>$rang.</span> ";
58
-		}
59
-
60
-		if (autoriser('voir', 'rubrique', $id_rubrique)) {
61
-			$les_sous_enfants = sous_enfant_rub($id_rubrique);
62
-
63
-			changer_typo($row['lang']);
64
-			$lang_dir = lang_dir($row['lang']);
65
-			$descriptif = propre($row['descriptif']);
66
-
67
-			if ($voir_logo) {
68
-				if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) {
69
-					[$fid, $dir, $nom, $format] = $logo;
70
-					$logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
71
-					if ($logo) {
72
-						$logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">');
73
-					}
74
-				}
75
-			}
76
-
77
-			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
78
-					http_img_pack(
79
-						'auteur-0minirezo-16.png',
80
-						'',
81
-						" width='16' height='16'",
82
-						_T('image_administrer_rubrique')
83
-					)) .
84
-				" <a class='titremlien' dir='$lang_dir'" .
85
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
86
-				" href='" .
87
-				generer_url_entite($id_rubrique, 'rubrique') .
88
-				"'><span class='titre'>" .
89
-				$rang . $titre
90
-				. '</span>'
91
-				. (is_string($logo) ? $logo : '')
92
-				. '</a>';
93
-
94
-			$titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
95
-				. (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>")
96
-				;
97
-
98
-			$res[] =
99
-				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
100
-				$les_sous_enfants .
101
-				fin_cadre_sous_rub();
102
-		}
103
-	}
104
-
105
-	changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
106
-	return $res;
33
+    $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non');
34
+    $logo = '';
35
+
36
+    if ($voir_logo) {
37
+        $chercher_logo = charger_fonction('chercher_logo', 'inc');
38
+        include_spip('inc/filtres_images_mini');
39
+    }
40
+
41
+    $res = [];
42
+
43
+    $result = sql_select(
44
+        'id_rubrique, id_parent, titre, descriptif, lang',
45
+        'spip_rubriques',
46
+        'id_parent=' . intval($collection),
47
+        '',
48
+        '0+titre,titre',
49
+        "$debut,$limite"
50
+    );
51
+    while ($row = sql_fetch($result)) {
52
+        $id_rubrique = $row['id_rubrique'];
53
+        $id_parent = $row['id_parent'];
54
+        // pour etre sur de passer par tous les traitements
55
+        $titre = generer_info_entite($id_rubrique, 'rubrique', 'titre');
56
+        if ('' !== ($rang = recuperer_numero($row['titre']))) {
57
+            $rang = "<span class='rang'>$rang.</span> ";
58
+        }
59
+
60
+        if (autoriser('voir', 'rubrique', $id_rubrique)) {
61
+            $les_sous_enfants = sous_enfant_rub($id_rubrique);
62
+
63
+            changer_typo($row['lang']);
64
+            $lang_dir = lang_dir($row['lang']);
65
+            $descriptif = propre($row['descriptif']);
66
+
67
+            if ($voir_logo) {
68
+                if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) {
69
+                    [$fid, $dir, $nom, $format] = $logo;
70
+                    $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
71
+                    if ($logo) {
72
+                        $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">');
73
+                    }
74
+                }
75
+            }
76
+
77
+            $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
78
+                    http_img_pack(
79
+                        'auteur-0minirezo-16.png',
80
+                        '',
81
+                        " width='16' height='16'",
82
+                        _T('image_administrer_rubrique')
83
+                    )) .
84
+                " <a class='titremlien' dir='$lang_dir'" .
85
+                ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
86
+                " href='" .
87
+                generer_url_entite($id_rubrique, 'rubrique') .
88
+                "'><span class='titre'>" .
89
+                $rang . $titre
90
+                . '</span>'
91
+                . (is_string($logo) ? $logo : '')
92
+                . '</a>';
93
+
94
+            $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
95
+                . (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>")
96
+                ;
97
+
98
+            $res[] =
99
+                debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
100
+                $les_sous_enfants .
101
+                fin_cadre_sous_rub();
102
+        }
103
+    }
104
+
105
+    changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
106
+    return $res;
107 107
 }
108 108
 
109 109
 /**
@@ -116,71 +116,71 @@  discard block
 block discarded – undo
116 116
  *  Le contenu du bloc dépliable
117 117
  */
118 118
 function sous_enfant_rub($collection2) {
119
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2));
120
-
121
-	$retour = '';
122
-	$pagination = '';
123
-	$debut = 0;
124
-	$limite = 500;
125
-
126
-	/**
127
-	 * On ne va afficher que 500 résultats max
128
-	 * Si > 500 on affiche une pagination
129
-	 */
130
-	if ($nb > $limite) {
131
-		$debut = _request('debut_rubrique' . $collection2) ?: $debut;
132
-		$pagination = chercher_filtre('pagination');
133
-		$pagination = '<p class="pagination">' . $pagination(
134
-			$nb,
135
-			'_rubrique' . $collection2,
136
-			$debut,
137
-			$limite,
138
-			true,
139
-			'prive'
140
-		) . '</p>';
141
-		$limite = $debut + $limite;
142
-	}
143
-
144
-	$result = sql_select(
145
-		'id_rubrique, id_parent, titre, lang',
146
-		'spip_rubriques',
147
-		'id_parent=' . intval($collection2),
148
-		'',
149
-		'0+titre,titre',
150
-		"$debut,$limite"
151
-	);
152
-
153
-	while ($row = sql_fetch($result)) {
154
-		$id_rubrique2 = $row['id_rubrique'];
155
-		$titre2 = generer_info_entite(
156
-			$id_rubrique2,
157
-			'rubrique',
158
-			'titre'
159
-		); // pour etre sur de passer par tous les traitements
160
-		if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
161
-			$rang2 = "<span class='rang'>$rang2.</span> ";
162
-		}
163
-
164
-		changer_typo($row['lang']);
165
-		$lang_dir = lang_dir($row['lang']);
166
-		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
167
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite(
168
-				$id_rubrique2,
169
-				'rubrique'
170
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
171
-		}
172
-	}
173
-
174
-	$retour = $pagination . $retour . $pagination;
175
-
176
-	if (!$retour) {
177
-		return '';
178
-	}
179
-
180
-	return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
181
-	. "\n<ul class='liste-items sous-sous-rub'>\n"
182
-	. $retour
183
-	. "</ul>\n" . fin_block() . "\n\n";
119
+    $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2));
120
+
121
+    $retour = '';
122
+    $pagination = '';
123
+    $debut = 0;
124
+    $limite = 500;
125
+
126
+    /**
127
+     * On ne va afficher que 500 résultats max
128
+     * Si > 500 on affiche une pagination
129
+     */
130
+    if ($nb > $limite) {
131
+        $debut = _request('debut_rubrique' . $collection2) ?: $debut;
132
+        $pagination = chercher_filtre('pagination');
133
+        $pagination = '<p class="pagination">' . $pagination(
134
+            $nb,
135
+            '_rubrique' . $collection2,
136
+            $debut,
137
+            $limite,
138
+            true,
139
+            'prive'
140
+        ) . '</p>';
141
+        $limite = $debut + $limite;
142
+    }
143
+
144
+    $result = sql_select(
145
+        'id_rubrique, id_parent, titre, lang',
146
+        'spip_rubriques',
147
+        'id_parent=' . intval($collection2),
148
+        '',
149
+        '0+titre,titre',
150
+        "$debut,$limite"
151
+    );
152
+
153
+    while ($row = sql_fetch($result)) {
154
+        $id_rubrique2 = $row['id_rubrique'];
155
+        $titre2 = generer_info_entite(
156
+            $id_rubrique2,
157
+            'rubrique',
158
+            'titre'
159
+        ); // pour etre sur de passer par tous les traitements
160
+        if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
161
+            $rang2 = "<span class='rang'>$rang2.</span> ";
162
+        }
163
+
164
+        changer_typo($row['lang']);
165
+        $lang_dir = lang_dir($row['lang']);
166
+        if (autoriser('voir', 'rubrique', $id_rubrique2)) {
167
+            $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite(
168
+                $id_rubrique2,
169
+                'rubrique'
170
+            ) . "'>" . $rang2 . $titre2 . "</a></li>\n";
171
+        }
172
+    }
173
+
174
+    $retour = $pagination . $retour . $pagination;
175
+
176
+    if (!$retour) {
177
+        return '';
178
+    }
179
+
180
+    return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
181
+    . "\n<ul class='liste-items sous-sous-rub'>\n"
182
+    . $retour
183
+    . "</ul>\n" . fin_block() . "\n\n";
184 184
 }
185 185
 
186 186
 /**
@@ -195,44 +195,44 @@  discard block
 block discarded – undo
195 195
  *  Le contenu textuel affiché, la liste des sous rubriques
196 196
  */
197 197
 function afficher_enfant_rub($id_rubrique = 0) {
198
-	$pagination = '';
199
-	$debut = 0;
200
-	$limite = 500;
201
-
202
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique));
203
-
204
-	if ($nb > $limite) {
205
-		$debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
206
-		$pagination = chercher_filtre('pagination');
207
-		$pagination = '<br class="nettoyeur"><p class="pagination">' .
208
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
209
-		'</p>';
210
-	}
211
-
212
-	$les_enfants = enfant_rub($id_rubrique, $debut, $limite);
213
-
214
-	if (!$n = count($les_enfants)) {
215
-		return '';
216
-	}
217
-
218
-	if ($n == 1) {
219
-		$les_enfants = reset($les_enfants);
220
-		$les_enfants2 = '';
221
-	} else {
222
-		$n = ceil($n / 2);
223
-		$les_enfants2 = implode('', array_slice($les_enfants, $n));
224
-		$les_enfants = implode('', array_slice($les_enfants, 0, $n));
225
-	}
226
-
227
-	$res =
228
-		$pagination
229
-		. "<div class='gauche'>"
230
-		. $les_enfants
231
-		. '</div>'
232
-		. "<div class='droite'>"
233
-		. $les_enfants2
234
-		. '</div>'
235
-		. $pagination;
236
-
237
-	return $res;
198
+    $pagination = '';
199
+    $debut = 0;
200
+    $limite = 500;
201
+
202
+    $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique));
203
+
204
+    if ($nb > $limite) {
205
+        $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
206
+        $pagination = chercher_filtre('pagination');
207
+        $pagination = '<br class="nettoyeur"><p class="pagination">' .
208
+            $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
209
+        '</p>';
210
+    }
211
+
212
+    $les_enfants = enfant_rub($id_rubrique, $debut, $limite);
213
+
214
+    if (!$n = count($les_enfants)) {
215
+        return '';
216
+    }
217
+
218
+    if ($n == 1) {
219
+        $les_enfants = reset($les_enfants);
220
+        $les_enfants2 = '';
221
+    } else {
222
+        $n = ceil($n / 2);
223
+        $les_enfants2 = implode('', array_slice($les_enfants, $n));
224
+        $les_enfants = implode('', array_slice($les_enfants, 0, $n));
225
+    }
226
+
227
+    $res =
228
+        $pagination
229
+        . "<div class='gauche'>"
230
+        . $les_enfants
231
+        . '</div>'
232
+        . "<div class='droite'>"
233
+        . $les_enfants2
234
+        . '</div>'
235
+        . $pagination;
236
+
237
+    return $res;
238 238
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_images_mini.php 1 patch
Indentation   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 include_spip('inc/filtres_images_lib_mini'); // par precaution
24 24
 
@@ -31,161 +31,161 @@  discard block
 block discarded – undo
31 31
  *    Le code hexadécimal de la couleur (sans le #) ou le code couleur textuel si non trouvé
32 32
  */
33 33
 function couleur_html_to_hex($couleur) {
34
-	$couleurs_html = [
35
-		'aliceblue' => 'F0F8FF',
36
-		'antiquewhite' => 'FAEBD7',
37
-		'aqua' => '00FFFF',
38
-		'aquamarine' => '7FFFD4',
39
-		'azure' => 'F0FFFF',
40
-		'beige' => 'F5F5DC',
41
-		'bisque' => 'FFE4C4',
42
-		'black' => '000000',
43
-		'blanchedalmond' => 'FFEBCD',
44
-		'blue' => '0000FF',
45
-		'blueviolet' => '8A2BE2',
46
-		'brown' => 'A52A2A',
47
-		'burlywood' => 'DEB887',
48
-		'cadetblue' => '5F9EA0',
49
-		'chartreuse' => '7FFF00',
50
-		'chocolate' => 'D2691E',
51
-		'coral' => 'FF7F50',
52
-		'cornflowerblue' => '6495ED',
53
-		'cornsilk' => 'FFF8DC',
54
-		'crimson' => 'DC143C',
55
-		'cyan' => '00FFFF',
56
-		'darkblue' => '00008B',
57
-		'darkcyan' => '008B8B',
58
-		'darkgoldenrod' => 'B8860B',
59
-		'darkgray' => 'A9A9A9',
60
-		'darkgreen' => '006400',
61
-		'darkgrey' => 'A9A9A9',
62
-		'darkkhaki' => 'BDB76B',
63
-		'darkmagenta' => '8B008B',
64
-		'darkolivegreen' => '556B2F',
65
-		'darkorange' => 'FF8C00',
66
-		'darkorchid' => '9932CC',
67
-		'darkred' => '8B0000',
68
-		'darksalmon' => 'E9967A',
69
-		'darkseagreen' => '8FBC8F',
70
-		'darkslateblue' => '483D8B',
71
-		'darkslategray' => '2F4F4F',
72
-		'darkslategrey' => '2F4F4F',
73
-		'darkturquoise' => '00CED1',
74
-		'darkviolet' => '9400D3',
75
-		'deeppink' => 'FF1493',
76
-		'deepskyblue' => '00BFFF',
77
-		'dimgray' => '696969',
78
-		'dimgrey' => '696969',
79
-		'dodgerblue' => '1E90FF',
80
-		'firebrick' => 'B22222',
81
-		'floralwhite' => 'FFFAF0',
82
-		'forestgreen' => '228B22',
83
-		'fuchsia' => 'FF00FF',
84
-		'gainsboro' => 'DCDCDC',
85
-		'ghostwhite' => 'F8F8FF',
86
-		'gold' => 'FFD700',
87
-		'goldenrod' => 'DAA520',
88
-		'gray' => '808080',
89
-		'green' => '008000',
90
-		'greenyellow' => 'ADFF2F',
91
-		'grey' => '808080',
92
-		'honeydew' => 'F0FFF0',
93
-		'hotpink' => 'FF69B4',
94
-		'indianred' => 'CD5C5C',
95
-		'indigo' => '4B0082',
96
-		'ivory' => 'FFFFF0',
97
-		'khaki' => 'F0E68C',
98
-		'lavender' => 'E6E6FA',
99
-		'lavenderblush' => 'FFF0F5',
100
-		'lawngreen' => '7CFC00',
101
-		'lemonchiffon' => 'FFFACD',
102
-		'lightblue' => 'ADD8E6',
103
-		'lightcoral' => 'F08080',
104
-		'lightcyan' => 'E0FFFF',
105
-		'lightgoldenrodyellow' => 'FAFAD2',
106
-		'lightgray' => 'D3D3D3',
107
-		'lightgreen' => '90EE90',
108
-		'lightgrey' => 'D3D3D3',
109
-		'lightpink' => 'FFB6C1',
110
-		'lightsalmon' => 'FFA07A',
111
-		'lightseagreen' => '20B2AA',
112
-		'lightskyblue' => '87CEFA',
113
-		'lightslategray' => '778899',
114
-		'lightslategrey' => '778899',
115
-		'lightsteelblue' => 'B0C4DE',
116
-		'lightyellow' => 'FFFFE0',
117
-		'lime' => '00FF00',
118
-		'limegreen' => '32CD32',
119
-		'linen' => 'FAF0E6',
120
-		'magenta' => 'FF00FF',
121
-		'maroon' => '800000',
122
-		'mediumaquamarine' => '66CDAA',
123
-		'mediumblue' => '0000CD',
124
-		'mediumorchid' => 'BA55D3',
125
-		'mediumpurple' => '9370DB',
126
-		'mediumseagreen' => '3CB371',
127
-		'mediumslateblue' => '7B68EE',
128
-		'mediumspringgreen' => '00FA9A',
129
-		'mediumturquoise' => '48D1CC',
130
-		'mediumvioletred' => 'C71585',
131
-		'midnightblue' => '191970',
132
-		'mintcream' => 'F5FFFA',
133
-		'mistyrose' => 'FFE4E1',
134
-		'moccasin' => 'FFE4B5',
135
-		'navajowhite' => 'FFDEAD',
136
-		'navy' => '000080',
137
-		'oldlace' => 'FDF5E6',
138
-		'olive' => '808000',
139
-		'olivedrab' => '6B8E23',
140
-		'orange' => 'FFA500',
141
-		'orangered' => 'FF4500',
142
-		'orchid' => 'DA70D6',
143
-		'palegoldenrod' => 'EEE8AA',
144
-		'palegreen' => '98FB98',
145
-		'paleturquoise' => 'AFEEEE',
146
-		'palevioletred' => 'DB7093',
147
-		'papayawhip' => 'FFEFD5',
148
-		'peachpuff' => 'FFDAB9',
149
-		'peru' => 'CD853F',
150
-		'pink' => 'FFC0CB',
151
-		'plum' => 'DDA0DD',
152
-		'powderblue' => 'B0E0E6',
153
-		'purple' => '800080',
154
-		'rebeccapurple' => '663399',
155
-		'red' => 'FF0000',
156
-		'rosybrown' => 'BC8F8F',
157
-		'royalblue' => '4169E1',
158
-		'saddlebrown' => '8B4513',
159
-		'salmon' => 'FA8072',
160
-		'sandybrown' => 'F4A460',
161
-		'seagreen' => '2E8B57',
162
-		'seashell' => 'FFF5EE',
163
-		'sienna' => 'A0522D',
164
-		'silver' => 'C0C0C0',
165
-		'skyblue' => '87CEEB',
166
-		'slateblue' => '6A5ACD',
167
-		'slategray' => '708090',
168
-		'slategrey' => '708090',
169
-		'snow' => 'FFFAFA',
170
-		'springgreen' => '00FF7F',
171
-		'steelblue' => '4682B4',
172
-		'tan' => 'D2B48C',
173
-		'teal' => '008080',
174
-		'thistle' => 'D8BFD8',
175
-		'tomato' => 'FF6347',
176
-		'turquoise' => '40E0D0',
177
-		'violet' => 'EE82EE',
178
-		'wheat' => 'F5DEB3',
179
-		'white' => 'FFFFFF',
180
-		'whitesmoke' => 'F5F5F5',
181
-		'yellow' => 'FFFF00',
182
-		'yellowgreen' => '9ACD32',
183
-	];
184
-	if (isset($couleurs_html[$lc = strtolower($couleur)])) {
185
-		return $couleurs_html[$lc];
186
-	}
187
-
188
-	return $couleur;
34
+    $couleurs_html = [
35
+        'aliceblue' => 'F0F8FF',
36
+        'antiquewhite' => 'FAEBD7',
37
+        'aqua' => '00FFFF',
38
+        'aquamarine' => '7FFFD4',
39
+        'azure' => 'F0FFFF',
40
+        'beige' => 'F5F5DC',
41
+        'bisque' => 'FFE4C4',
42
+        'black' => '000000',
43
+        'blanchedalmond' => 'FFEBCD',
44
+        'blue' => '0000FF',
45
+        'blueviolet' => '8A2BE2',
46
+        'brown' => 'A52A2A',
47
+        'burlywood' => 'DEB887',
48
+        'cadetblue' => '5F9EA0',
49
+        'chartreuse' => '7FFF00',
50
+        'chocolate' => 'D2691E',
51
+        'coral' => 'FF7F50',
52
+        'cornflowerblue' => '6495ED',
53
+        'cornsilk' => 'FFF8DC',
54
+        'crimson' => 'DC143C',
55
+        'cyan' => '00FFFF',
56
+        'darkblue' => '00008B',
57
+        'darkcyan' => '008B8B',
58
+        'darkgoldenrod' => 'B8860B',
59
+        'darkgray' => 'A9A9A9',
60
+        'darkgreen' => '006400',
61
+        'darkgrey' => 'A9A9A9',
62
+        'darkkhaki' => 'BDB76B',
63
+        'darkmagenta' => '8B008B',
64
+        'darkolivegreen' => '556B2F',
65
+        'darkorange' => 'FF8C00',
66
+        'darkorchid' => '9932CC',
67
+        'darkred' => '8B0000',
68
+        'darksalmon' => 'E9967A',
69
+        'darkseagreen' => '8FBC8F',
70
+        'darkslateblue' => '483D8B',
71
+        'darkslategray' => '2F4F4F',
72
+        'darkslategrey' => '2F4F4F',
73
+        'darkturquoise' => '00CED1',
74
+        'darkviolet' => '9400D3',
75
+        'deeppink' => 'FF1493',
76
+        'deepskyblue' => '00BFFF',
77
+        'dimgray' => '696969',
78
+        'dimgrey' => '696969',
79
+        'dodgerblue' => '1E90FF',
80
+        'firebrick' => 'B22222',
81
+        'floralwhite' => 'FFFAF0',
82
+        'forestgreen' => '228B22',
83
+        'fuchsia' => 'FF00FF',
84
+        'gainsboro' => 'DCDCDC',
85
+        'ghostwhite' => 'F8F8FF',
86
+        'gold' => 'FFD700',
87
+        'goldenrod' => 'DAA520',
88
+        'gray' => '808080',
89
+        'green' => '008000',
90
+        'greenyellow' => 'ADFF2F',
91
+        'grey' => '808080',
92
+        'honeydew' => 'F0FFF0',
93
+        'hotpink' => 'FF69B4',
94
+        'indianred' => 'CD5C5C',
95
+        'indigo' => '4B0082',
96
+        'ivory' => 'FFFFF0',
97
+        'khaki' => 'F0E68C',
98
+        'lavender' => 'E6E6FA',
99
+        'lavenderblush' => 'FFF0F5',
100
+        'lawngreen' => '7CFC00',
101
+        'lemonchiffon' => 'FFFACD',
102
+        'lightblue' => 'ADD8E6',
103
+        'lightcoral' => 'F08080',
104
+        'lightcyan' => 'E0FFFF',
105
+        'lightgoldenrodyellow' => 'FAFAD2',
106
+        'lightgray' => 'D3D3D3',
107
+        'lightgreen' => '90EE90',
108
+        'lightgrey' => 'D3D3D3',
109
+        'lightpink' => 'FFB6C1',
110
+        'lightsalmon' => 'FFA07A',
111
+        'lightseagreen' => '20B2AA',
112
+        'lightskyblue' => '87CEFA',
113
+        'lightslategray' => '778899',
114
+        'lightslategrey' => '778899',
115
+        'lightsteelblue' => 'B0C4DE',
116
+        'lightyellow' => 'FFFFE0',
117
+        'lime' => '00FF00',
118
+        'limegreen' => '32CD32',
119
+        'linen' => 'FAF0E6',
120
+        'magenta' => 'FF00FF',
121
+        'maroon' => '800000',
122
+        'mediumaquamarine' => '66CDAA',
123
+        'mediumblue' => '0000CD',
124
+        'mediumorchid' => 'BA55D3',
125
+        'mediumpurple' => '9370DB',
126
+        'mediumseagreen' => '3CB371',
127
+        'mediumslateblue' => '7B68EE',
128
+        'mediumspringgreen' => '00FA9A',
129
+        'mediumturquoise' => '48D1CC',
130
+        'mediumvioletred' => 'C71585',
131
+        'midnightblue' => '191970',
132
+        'mintcream' => 'F5FFFA',
133
+        'mistyrose' => 'FFE4E1',
134
+        'moccasin' => 'FFE4B5',
135
+        'navajowhite' => 'FFDEAD',
136
+        'navy' => '000080',
137
+        'oldlace' => 'FDF5E6',
138
+        'olive' => '808000',
139
+        'olivedrab' => '6B8E23',
140
+        'orange' => 'FFA500',
141
+        'orangered' => 'FF4500',
142
+        'orchid' => 'DA70D6',
143
+        'palegoldenrod' => 'EEE8AA',
144
+        'palegreen' => '98FB98',
145
+        'paleturquoise' => 'AFEEEE',
146
+        'palevioletred' => 'DB7093',
147
+        'papayawhip' => 'FFEFD5',
148
+        'peachpuff' => 'FFDAB9',
149
+        'peru' => 'CD853F',
150
+        'pink' => 'FFC0CB',
151
+        'plum' => 'DDA0DD',
152
+        'powderblue' => 'B0E0E6',
153
+        'purple' => '800080',
154
+        'rebeccapurple' => '663399',
155
+        'red' => 'FF0000',
156
+        'rosybrown' => 'BC8F8F',
157
+        'royalblue' => '4169E1',
158
+        'saddlebrown' => '8B4513',
159
+        'salmon' => 'FA8072',
160
+        'sandybrown' => 'F4A460',
161
+        'seagreen' => '2E8B57',
162
+        'seashell' => 'FFF5EE',
163
+        'sienna' => 'A0522D',
164
+        'silver' => 'C0C0C0',
165
+        'skyblue' => '87CEEB',
166
+        'slateblue' => '6A5ACD',
167
+        'slategray' => '708090',
168
+        'slategrey' => '708090',
169
+        'snow' => 'FFFAFA',
170
+        'springgreen' => '00FF7F',
171
+        'steelblue' => '4682B4',
172
+        'tan' => 'D2B48C',
173
+        'teal' => '008080',
174
+        'thistle' => 'D8BFD8',
175
+        'tomato' => 'FF6347',
176
+        'turquoise' => '40E0D0',
177
+        'violet' => 'EE82EE',
178
+        'wheat' => 'F5DEB3',
179
+        'white' => 'FFFFFF',
180
+        'whitesmoke' => 'F5F5F5',
181
+        'yellow' => 'FFFF00',
182
+        'yellowgreen' => '9ACD32',
183
+    ];
184
+    if (isset($couleurs_html[$lc = strtolower($couleur)])) {
185
+        return $couleurs_html[$lc];
186
+    }
187
+
188
+    return $couleur;
189 189
 }
190 190
 
191 191
 /**
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
  * @return string Couleur tel que "hsl(200, 40%, 34%)" ou valeur formattée
202 202
  */
203 203
 function couleur_hex_to_hsl($couleur, $format = null) {
204
-	$hsl = _couleur_hex_to_hsl($couleur);
205
-	$hsl = [
206
-		'h' => round($hsl['h'] * 360),
207
-		's' => round($hsl['s'] * 100) . '%',
208
-		'l' => round($hsl['l'] * 100) . '%'
209
-	];
210
-	if ($format === null) {
211
-		return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})";
212
-	}
213
-	return str_replace(array_keys($hsl), $hsl, $format);
204
+    $hsl = _couleur_hex_to_hsl($couleur);
205
+    $hsl = [
206
+        'h' => round($hsl['h'] * 360),
207
+        's' => round($hsl['s'] * 100) . '%',
208
+        'l' => round($hsl['l'] * 100) . '%'
209
+    ];
210
+    if ($format === null) {
211
+        return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})";
212
+    }
213
+    return str_replace(array_keys($hsl), $hsl, $format);
214 214
 }
215 215
 
216 216
 
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
  * @return string Couleur tel que "rgb(200, 40, 84)" ou valeur formattée
228 228
  */
229 229
 function couleur_hex_to_rgb($couleur, $format = null) {
230
-	$rgb = _couleur_hex_to_dec($couleur);
231
-	$rgb = [
232
-		'r' => $rgb['red'],
233
-		'g' => $rgb['green'],
234
-		'b' => $rgb['blue'],
235
-	];
236
-	if ($format === null) {
237
-		return "rgb({$rgb['r']}, {$rgb['g']}, {$rgb['b']})";
238
-	}
239
-	return str_replace(array_keys($rgb), $rgb, $format);
230
+    $rgb = _couleur_hex_to_dec($couleur);
231
+    $rgb = [
232
+        'r' => $rgb['red'],
233
+        'g' => $rgb['green'],
234
+        'b' => $rgb['blue'],
235
+    ];
236
+    if ($format === null) {
237
+        return "rgb({$rgb['r']}, {$rgb['g']}, {$rgb['b']})";
238
+    }
239
+    return str_replace(array_keys($rgb), $rgb, $format);
240 240
 }
241 241
 
242 242
 /**
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
  *    Code hexadécimal de la couleur plus foncée
253 253
  */
254 254
 function couleur_foncer($couleur, $coeff = 0.5) {
255
-	$couleurs = _couleur_hex_to_dec($couleur);
255
+    $couleurs = _couleur_hex_to_dec($couleur);
256 256
 
257
-	$red = $couleurs['red'] - round(($couleurs['red']) * $coeff);
258
-	$green = $couleurs['green'] - round(($couleurs['green']) * $coeff);
259
-	$blue = $couleurs['blue'] - round(($couleurs['blue']) * $coeff);
257
+    $red = $couleurs['red'] - round(($couleurs['red']) * $coeff);
258
+    $green = $couleurs['green'] - round(($couleurs['green']) * $coeff);
259
+    $blue = $couleurs['blue'] - round(($couleurs['blue']) * $coeff);
260 260
 
261
-	$couleur = _couleur_dec_to_hex($red, $green, $blue);
261
+    $couleur = _couleur_dec_to_hex($red, $green, $blue);
262 262
 
263
-	return $couleur;
263
+    return $couleur;
264 264
 }
265 265
 
266 266
 /**
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
  *    Code hexadécimal de la couleur éclaircie
277 277
  */
278 278
 function couleur_eclaircir($couleur, $coeff = 0.5) {
279
-	$couleurs = _couleur_hex_to_dec($couleur);
279
+    $couleurs = _couleur_hex_to_dec($couleur);
280 280
 
281
-	$red = $couleurs['red'] + round((255 - $couleurs['red']) * $coeff);
282
-	$green = $couleurs['green'] + round((255 - $couleurs['green']) * $coeff);
283
-	$blue = $couleurs['blue'] + round((255 - $couleurs['blue']) * $coeff);
281
+    $red = $couleurs['red'] + round((255 - $couleurs['red']) * $coeff);
282
+    $green = $couleurs['green'] + round((255 - $couleurs['green']) * $coeff);
283
+    $blue = $couleurs['blue'] + round((255 - $couleurs['blue']) * $coeff);
284 284
 
285
-	$couleur = _couleur_dec_to_hex($red, $green, $blue);
285
+    $couleur = _couleur_dec_to_hex($red, $green, $blue);
286 286
 
287
-	return $couleur;
287
+    return $couleur;
288 288
 }
289 289
 
290 290
 /**
@@ -307,28 +307,28 @@  discard block
 block discarded – undo
307 307
  *    Le tag html `<img src=... />` avec une class `filtre_inactif` ou pas
308 308
  */
309 309
 function image_select($img, $width_min = 0, $height_min = 0, $width_max = 10000, $height_max = 1000) {
310
-	if (!$img) {
311
-		return $img;
312
-	}
313
-	[$h, $l] = taille_image($img);
314
-	$select = true;
315
-	if ($l < $width_min or $l > $width_max or $h < $height_min or $h > $height_max) {
316
-		$select = false;
317
-	}
318
-
319
-	$class = extraire_attribut($img, 'class');
320
-	$p = strpos($class, 'filtre_inactif');
321
-	if (($select == false) and ($p === false)) {
322
-		$class .= ' filtre_inactif';
323
-		$img = inserer_attribut($img, 'class', $class);
324
-	}
325
-	if (($select == true) and ($p !== false)) {
326
-		// no_image_filtrer : historique, a virer
327
-		$class = preg_replace(',\s*(filtre_inactif|no_image_filtrer),', '', $class);
328
-		$img = inserer_attribut($img, 'class', $class);
329
-	}
330
-
331
-	return $img;
310
+    if (!$img) {
311
+        return $img;
312
+    }
313
+    [$h, $l] = taille_image($img);
314
+    $select = true;
315
+    if ($l < $width_min or $l > $width_max or $h < $height_min or $h > $height_max) {
316
+        $select = false;
317
+    }
318
+
319
+    $class = extraire_attribut($img, 'class');
320
+    $p = strpos($class, 'filtre_inactif');
321
+    if (($select == false) and ($p === false)) {
322
+        $class .= ' filtre_inactif';
323
+        $img = inserer_attribut($img, 'class', $class);
324
+    }
325
+    if (($select == true) and ($p !== false)) {
326
+        // no_image_filtrer : historique, a virer
327
+        $class = preg_replace(',\s*(filtre_inactif|no_image_filtrer),', '', $class);
328
+        $img = inserer_attribut($img, 'class', $class);
329
+    }
330
+
331
+    return $img;
332 332
 }
333 333
 
334 334
 /**
@@ -376,45 +376,45 @@  discard block
 block discarded – undo
376 376
  *     Code HTML de l'image ou du texte.
377 377
  **/
378 378
 function image_passe_partout(
379
-	$img,
380
-	$taille_x = -1,
381
-	$taille_y = -1,
382
-	$force = false,
383
-	$cherche_image = false,
384
-	$process = 'AUTO'
379
+    $img,
380
+    $taille_x = -1,
381
+    $taille_y = -1,
382
+    $force = false,
383
+    $cherche_image = false,
384
+    $process = 'AUTO'
385 385
 ) {
386
-	// PHP 7+ type hint
387
-	$img = (string)$img;
388
-	$taille_x = (int)$taille_x;
389
-	$taille_y = (int)$taille_y;
390
-	$force = (bool)$force;
391
-	$process = (string)$process;
392
-
393
-	if (!$img) {
394
-		return '';
395
-	}
396
-	[$hauteur, $largeur] = taille_image($img);
397
-	if ($taille_x === -1) {
398
-		$taille_x = $GLOBALS['meta']['taille_preview'] ?? 150;
399
-	}
400
-	if ($taille_y === -1) {
401
-		$taille_y = $taille_x;
402
-	}
403
-
404
-	if ($taille_x === 0 and $taille_y > 0) {
405
-		$taille_x = 1;
406
-	} # {0,300} -> c'est 300 qui compte
407
-	elseif ($taille_x > 0 and $taille_y === 0) {
408
-		$taille_y = 1;
409
-	} # {300,0} -> c'est 300 qui compte
410
-	elseif ($taille_x == 0 and $taille_y === 0) {
411
-		return '';
412
-	}
413
-
414
-	[$destWidth, $destHeight, $ratio] = ratio_passe_partout($largeur ?? 0, $hauteur ?? 0, $taille_x, $taille_y);
415
-	$fonction = ['image_passe_partout', func_get_args()];
416
-
417
-	return process_image_reduire($fonction, $img, $destWidth, $destHeight, $force, $process);
386
+    // PHP 7+ type hint
387
+    $img = (string)$img;
388
+    $taille_x = (int)$taille_x;
389
+    $taille_y = (int)$taille_y;
390
+    $force = (bool)$force;
391
+    $process = (string)$process;
392
+
393
+    if (!$img) {
394
+        return '';
395
+    }
396
+    [$hauteur, $largeur] = taille_image($img);
397
+    if ($taille_x === -1) {
398
+        $taille_x = $GLOBALS['meta']['taille_preview'] ?? 150;
399
+    }
400
+    if ($taille_y === -1) {
401
+        $taille_y = $taille_x;
402
+    }
403
+
404
+    if ($taille_x === 0 and $taille_y > 0) {
405
+        $taille_x = 1;
406
+    } # {0,300} -> c'est 300 qui compte
407
+    elseif ($taille_x > 0 and $taille_y === 0) {
408
+        $taille_y = 1;
409
+    } # {300,0} -> c'est 300 qui compte
410
+    elseif ($taille_x == 0 and $taille_y === 0) {
411
+        return '';
412
+    }
413
+
414
+    [$destWidth, $destHeight, $ratio] = ratio_passe_partout($largeur ?? 0, $hauteur ?? 0, $taille_x, $taille_y);
415
+    $fonction = ['image_passe_partout', func_get_args()];
416
+
417
+    return process_image_reduire($fonction, $img, $destWidth, $destHeight, $force, $process);
418 418
 }
419 419
 
420 420
 /**
@@ -457,44 +457,44 @@  discard block
 block discarded – undo
457 457
  *     Code HTML de l'image ou du texte.
458 458
  **/
459 459
 function image_reduire(
460
-	$img,
461
-	$taille = -1,
462
-	$taille_y = -1,
463
-	$force = false,
464
-	$cherche_image = false,
465
-	$process = 'AUTO'
460
+    $img,
461
+    $taille = -1,
462
+    $taille_y = -1,
463
+    $force = false,
464
+    $cherche_image = false,
465
+    $process = 'AUTO'
466 466
 ) {
467
-	// PHP 7+ type hint
468
-	$img = (string)$img;
469
-	$taille = (int)$taille;
470
-	$taille_y = (int)$taille_y;
471
-	$force = (bool)$force;
472
-	$process = (string)$process;
473
-
474
-	// Determiner la taille x,y maxi
475
-	// prendre le reglage de previsu par defaut
476
-	if ($taille === -1) {
477
-		$taille = (isset($GLOBALS['meta']['taille_preview']) and intval($GLOBALS['meta']['taille_preview']))
478
-			? intval($GLOBALS['meta']['taille_preview'])
479
-			: 150;
480
-	}
481
-	if ($taille_y === -1) {
482
-		$taille_y = $taille;
483
-	}
484
-
485
-	if ($taille === 0 and $taille_y > 0) {
486
-		$taille = 10000;
487
-	} # {0,300} -> c'est 300 qui compte
488
-	elseif ($taille > 0 and $taille_y === 0) {
489
-		$taille_y = 10000;
490
-	} # {300,0} -> c'est 300 qui compte
491
-	elseif ($taille == 0 and $taille_y === 0) {
492
-		return '';
493
-	}
494
-
495
-	$fonction = ['image_reduire', func_get_args()];
496
-
497
-	return process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process);
467
+    // PHP 7+ type hint
468
+    $img = (string)$img;
469
+    $taille = (int)$taille;
470
+    $taille_y = (int)$taille_y;
471
+    $force = (bool)$force;
472
+    $process = (string)$process;
473
+
474
+    // Determiner la taille x,y maxi
475
+    // prendre le reglage de previsu par defaut
476
+    if ($taille === -1) {
477
+        $taille = (isset($GLOBALS['meta']['taille_preview']) and intval($GLOBALS['meta']['taille_preview']))
478
+            ? intval($GLOBALS['meta']['taille_preview'])
479
+            : 150;
480
+    }
481
+    if ($taille_y === -1) {
482
+        $taille_y = $taille;
483
+    }
484
+
485
+    if ($taille === 0 and $taille_y > 0) {
486
+        $taille = 10000;
487
+    } # {0,300} -> c'est 300 qui compte
488
+    elseif ($taille > 0 and $taille_y === 0) {
489
+        $taille_y = 10000;
490
+    } # {300,0} -> c'est 300 qui compte
491
+    elseif ($taille == 0 and $taille_y === 0) {
492
+        return '';
493
+    }
494
+
495
+    $fonction = ['image_reduire', func_get_args()];
496
+
497
+    return process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process);
498 498
 }
499 499
 
500 500
 /**
@@ -505,16 +505,16 @@  discard block
 block discarded – undo
505 505
  *
506 506
  **/
507 507
 function image_recadre_avec_fallback(
508
-	$im,
509
-	$width,
510
-	$height = '-',
511
-	$position = 'focus',
512
-	$background_color = 'white'
508
+    $im,
509
+    $width,
510
+    $height = '-',
511
+    $position = 'focus',
512
+    $background_color = 'white'
513 513
 ) {
514
-	if (function_exists('image_recadre') && ($GLOBALS['meta']['image_process'] ?? '') === 'gd2') {
515
-		return image_reduire(image_recadre($im, $width . ':' . $height, '-', $position, $background_color), $width, $height);
516
-	} else { return image_passe_partout($im, $width, $height);
517
-	}
514
+    if (function_exists('image_recadre') && ($GLOBALS['meta']['image_process'] ?? '') === 'gd2') {
515
+        return image_reduire(image_recadre($im, $width . ':' . $height, '-', $position, $background_color), $width, $height);
516
+    } else { return image_passe_partout($im, $width, $height);
517
+    }
518 518
 }
519 519
 
520 520
 /**
@@ -532,25 +532,25 @@  discard block
 block discarded – undo
532 532
  *     Code HTML de l'image ou du texte.
533 533
  **/
534 534
 function image_reduire_par($img, $val = 1, $force = false) {
535
-	// PHP 7+ type hint
536
-	$img = (string)$img;
537
-	$val = (int)$val;
538
-	$force = (bool)$force;
535
+    // PHP 7+ type hint
536
+    $img = (string)$img;
537
+    $val = (int)$val;
538
+    $force = (bool)$force;
539 539
 
540
-	[$hauteur, $largeur] = taille_image($img);
540
+    [$hauteur, $largeur] = taille_image($img);
541 541
 
542
-	$l = round($largeur / $val);
543
-	$h = round($hauteur / $val);
542
+    $l = round($largeur / $val);
543
+    $h = round($hauteur / $val);
544 544
 
545
-	if ($l > $h) {
546
-		$h = 0;
547
-	} else {
548
-		$l = 0;
549
-	}
545
+    if ($l > $h) {
546
+        $h = 0;
547
+    } else {
548
+        $l = 0;
549
+    }
550 550
 
551
-	$img = image_reduire($img, $l, $h, $force);
551
+    $img = image_reduire($img, $l, $h, $force);
552 552
 
553
-	return $img;
553
+    return $img;
554 554
 }
555 555
 
556 556
 /**
@@ -573,10 +573,10 @@  discard block
 block discarded – undo
573 573
  *      Couleur en écriture hexadécimale.
574 574
 **/
575 575
 function filtre_couleur_saturation_dist($couleur, $val, $strict = false) {
576
-	if (function_exists('couleur_saturation')) {
577
-		return couleur_saturation($couleur, $val, $strict);
578
-	}
579
-	return $couleur;
576
+    if (function_exists('couleur_saturation')) {
577
+        return couleur_saturation($couleur, $val, $strict);
578
+    }
579
+    return $couleur;
580 580
 }
581 581
 
582 582
 /**
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
  *      Couleur en écriture hexadécimale.
598 598
 **/
599 599
 function filtre_couleur_luminance_dist($couleur, $val) {
600
-	if (function_exists('couleur_luminance')) {
601
-		return couleur_luminance($couleur, $val);
602
-	}
603
-	return $couleur;
600
+    if (function_exists('couleur_luminance')) {
601
+        return couleur_luminance($couleur, $val);
602
+    }
603
+    return $couleur;
604 604
 }
Please login to merge, or discard this patch.