Completed
Push — master ( 89cac1...7b34bc )
by cam
01:10
created
ecrire/inc/meta.php 1 patch
Indentation   +191 added lines, -191 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
 // Les parametres generaux du site sont dans une table SQL;
@@ -28,47 +28,47 @@  discard block
 block discarded – undo
28 28
 
29 29
 // https://code.spip.net/@inc_meta_dist
30 30
 function inc_meta_dist($table = 'meta') {
31
-	// Lire les meta, en cache si present, valide et lisible
32
-	// en cas d'install ne pas faire confiance au meta_cache eventuel
33
-	$cache = cache_meta($table);
31
+    // Lire les meta, en cache si present, valide et lisible
32
+    // en cas d'install ne pas faire confiance au meta_cache eventuel
33
+    $cache = cache_meta($table);
34 34
 
35
-	if ((!$exec = _request('exec') or !autoriser_sans_cookie($exec))
36
-		and $new = jeune_fichier($cache, _META_CACHE_TIME)
37
-		and lire_fichier_securise($cache, $meta)
38
-		and $meta = @unserialize($meta)
39
-	) {
40
-		$GLOBALS[$table] = $meta;
41
-	}
35
+    if ((!$exec = _request('exec') or !autoriser_sans_cookie($exec))
36
+        and $new = jeune_fichier($cache, _META_CACHE_TIME)
37
+        and lire_fichier_securise($cache, $meta)
38
+        and $meta = @unserialize($meta)
39
+    ) {
40
+        $GLOBALS[$table] = $meta;
41
+    }
42 42
 
43
-	if (isset($GLOBALS[$table]['touch'])
44
-		and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME)
45
-	) {
46
-		$GLOBALS[$table] = array();
47
-	}
48
-	// sinon lire en base
49
-	if (!$GLOBALS[$table]) {
50
-		$new = !lire_metas($table);
51
-	}
43
+    if (isset($GLOBALS[$table]['touch'])
44
+        and ($GLOBALS[$table]['touch'] < time() - _META_CACHE_TIME)
45
+    ) {
46
+        $GLOBALS[$table] = array();
47
+    }
48
+    // sinon lire en base
49
+    if (!$GLOBALS[$table]) {
50
+        $new = !lire_metas($table);
51
+    }
52 52
 
53
-	// renouveller l'alea general si trop vieux ou sur demande explicite
54
-	if ((test_espace_prive() || isset($_GET['renouvelle_alea']))
55
-		and $GLOBALS[$table]
56
-		and (time() > _RENOUVELLE_ALEA + (isset($GLOBALS['meta']['alea_ephemere_date']) ? $GLOBALS['meta']['alea_ephemere_date'] : 0))
57
-	) {
58
-		// si on n'a pas l'acces en ecriture sur le cache,
59
-		// ne pas renouveller l'alea sinon le cache devient faux
60
-		if (supprimer_fichier($cache)) {
61
-			include_spip('inc/acces');
62
-			renouvelle_alea();
63
-			$new = false;
64
-		} else {
65
-			spip_log("impossible d'ecrire dans " . $cache);
66
-		}
67
-	}
68
-	// et refaire le cache si on a du lire en base
69
-	if (!$new) {
70
-		touch_meta(false, $table);
71
-	}
53
+    // renouveller l'alea general si trop vieux ou sur demande explicite
54
+    if ((test_espace_prive() || isset($_GET['renouvelle_alea']))
55
+        and $GLOBALS[$table]
56
+        and (time() > _RENOUVELLE_ALEA + (isset($GLOBALS['meta']['alea_ephemere_date']) ? $GLOBALS['meta']['alea_ephemere_date'] : 0))
57
+    ) {
58
+        // si on n'a pas l'acces en ecriture sur le cache,
59
+        // ne pas renouveller l'alea sinon le cache devient faux
60
+        if (supprimer_fichier($cache)) {
61
+            include_spip('inc/acces');
62
+            renouvelle_alea();
63
+            $new = false;
64
+        } else {
65
+            spip_log("impossible d'ecrire dans " . $cache);
66
+        }
67
+    }
68
+    // et refaire le cache si on a du lire en base
69
+    if (!$new) {
70
+        touch_meta(false, $table);
71
+    }
72 72
 }
73 73
 
74 74
 // fonctions aussi appelees a l'install ==> spip_query en premiere requete 
@@ -77,38 +77,38 @@  discard block
 block discarded – undo
77 77
 // https://code.spip.net/@lire_metas
78 78
 function lire_metas($table = 'meta') {
79 79
 
80
-	if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
81
-		include_spip('base/abstract_sql');
82
-		$GLOBALS[$table] = array();
83
-		while ($row = sql_fetch($result)) {
84
-			$GLOBALS[$table][$row['nom']] = $row['valeur'];
85
-		}
86
-		sql_free($result);
80
+    if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) {
81
+        include_spip('base/abstract_sql');
82
+        $GLOBALS[$table] = array();
83
+        while ($row = sql_fetch($result)) {
84
+            $GLOBALS[$table][$row['nom']] = $row['valeur'];
85
+        }
86
+        sql_free($result);
87 87
 
88
-		if (!isset($GLOBALS[$table]['charset'])
89
-			or !$GLOBALS[$table]['charset']
90
-			or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
91
-		) {
92
-			ecrire_meta('charset', _DEFAULT_CHARSET, null, $table);
93
-		}
88
+        if (!isset($GLOBALS[$table]['charset'])
89
+            or !$GLOBALS[$table]['charset']
90
+            or $GLOBALS[$table]['charset'] == '_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install
91
+        ) {
92
+            ecrire_meta('charset', _DEFAULT_CHARSET, null, $table);
93
+        }
94 94
 
95
-		// noter cette table de configuration dans les meta de SPIP
96
-		if ($table !== 'meta') {
97
-			$liste = array();
98
-			if (isset($GLOBALS['meta']['tables_config'])) {
99
-				$liste = unserialize($GLOBALS['meta']['tables_config']);
100
-			}
101
-			if (!$liste) {
102
-				$liste = array();
103
-			}
104
-			if (!in_array($table, $liste)) {
105
-				$liste[] = $table;
106
-				ecrire_meta('tables_config', serialize($liste));
107
-			}
108
-		}
109
-	}
95
+        // noter cette table de configuration dans les meta de SPIP
96
+        if ($table !== 'meta') {
97
+            $liste = array();
98
+            if (isset($GLOBALS['meta']['tables_config'])) {
99
+                $liste = unserialize($GLOBALS['meta']['tables_config']);
100
+            }
101
+            if (!$liste) {
102
+                $liste = array();
103
+            }
104
+            if (!in_array($table, $liste)) {
105
+                $liste[] = $table;
106
+                ecrire_meta('tables_config', serialize($liste));
107
+            }
108
+        }
109
+    }
110 110
 
111
-	return isset($GLOBALS[$table]) ? $GLOBALS[$table] : null;
111
+    return isset($GLOBALS[$table]) ? $GLOBALS[$table] : null;
112 112
 }
113 113
 
114 114
 
@@ -122,22 +122,22 @@  discard block
 block discarded – undo
122 122
  *      Table SQL d'enregistrement des meta.
123 123
  **/
124 124
 function touch_meta($antidate = false, $table = 'meta') {
125
-	$file = cache_meta($table);
126
-	if (!$antidate or !@touch($file, $antidate)) {
127
-		$r = isset($GLOBALS[$table]) ? $GLOBALS[$table] : array();
128
-		if ($table == 'meta') {
129
-			unset($r['alea_ephemere']);
130
-			unset($r['alea_ephemere_ancien']);
131
-			// le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables
132
-			// mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
133
-			// meme si son squelette est en cache
134
-			//unset($r['secret_du_site']);
135
-			if ($antidate) {
136
-				$r['touch'] = $antidate;
137
-			}
138
-		}
139
-		ecrire_fichier_securise($file, serialize($r));
140
-	}
125
+    $file = cache_meta($table);
126
+    if (!$antidate or !@touch($file, $antidate)) {
127
+        $r = isset($GLOBALS[$table]) ? $GLOBALS[$table] : array();
128
+        if ($table == 'meta') {
129
+            unset($r['alea_ephemere']);
130
+            unset($r['alea_ephemere_ancien']);
131
+            // le secret du site est utilise pour encoder les contextes ajax que l'on considere fiables
132
+            // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique
133
+            // meme si son squelette est en cache
134
+            //unset($r['secret_du_site']);
135
+            if ($antidate) {
136
+                $r['touch'] = $antidate;
137
+            }
138
+        }
139
+        ecrire_fichier_securise($file, serialize($r));
140
+    }
141 141
 }
142 142
 
143 143
 /**
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
  *     Table SQL d'enregistrement de la meta.
154 154
  **/
155 155
 function effacer_meta($nom, $table = 'meta') {
156
-	// section critique sur le cache:
157
-	// l'invalider avant et apres la MAJ de la BD
158
-	// c'est un peu moins bien qu'un vrai verrou mais ca suffira
159
-	// et utiliser une statique pour eviter des acces disques a repetition
160
-	static $touch = array();
161
-	$antidate = time() - (_META_CACHE_TIME << 4);
162
-	if (!isset($touch[$table])) {
163
-		touch_meta($antidate, $table);
164
-	}
165
-	sql_delete('spip_' . $table, "nom='$nom'", '', 'continue');
166
-	unset($GLOBALS[$table][$nom]);
167
-	if (!isset($touch[$table])) {
168
-		touch_meta($antidate, $table);
169
-		$touch[$table] = false;
170
-	}
156
+    // section critique sur le cache:
157
+    // l'invalider avant et apres la MAJ de la BD
158
+    // c'est un peu moins bien qu'un vrai verrou mais ca suffira
159
+    // et utiliser une statique pour eviter des acces disques a repetition
160
+    static $touch = array();
161
+    $antidate = time() - (_META_CACHE_TIME << 4);
162
+    if (!isset($touch[$table])) {
163
+        touch_meta($antidate, $table);
164
+    }
165
+    sql_delete('spip_' . $table, "nom='$nom'", '', 'continue');
166
+    unset($GLOBALS[$table][$nom]);
167
+    if (!isset($touch[$table])) {
168
+        touch_meta($antidate, $table);
169
+        $touch[$table] = false;
170
+    }
171 171
 }
172 172
 
173 173
 /**
@@ -188,52 +188,52 @@  discard block
 block discarded – undo
188 188
  **/
189 189
 function ecrire_meta($nom, $valeur, $importable = null, $table = 'meta') {
190 190
 
191
-	static $touch = array();
192
-	if (!$nom) {
193
-		return;
194
-	}
195
-	include_spip('base/abstract_sql');
196
-	$res = sql_select("*", 'spip_' . $table, "nom=" . sql_quote($nom), '', '', '', '', '', 'continue');
197
-	// table pas encore installee, travailler en php seulement
198
-	if (!$res) {
199
-		$GLOBALS[$table][$nom] = $valeur;
191
+    static $touch = array();
192
+    if (!$nom) {
193
+        return;
194
+    }
195
+    include_spip('base/abstract_sql');
196
+    $res = sql_select("*", 'spip_' . $table, "nom=" . sql_quote($nom), '', '', '', '', '', 'continue');
197
+    // table pas encore installee, travailler en php seulement
198
+    if (!$res) {
199
+        $GLOBALS[$table][$nom] = $valeur;
200 200
 
201
-		return;
202
-	}
203
-	$row = sql_fetch($res);
204
-	sql_free($res);
201
+        return;
202
+    }
203
+    $row = sql_fetch($res);
204
+    sql_free($res);
205 205
 
206
-	// ne pas invalider le cache si affectation a l'identique
207
-	// (tant pis si impt aurait du changer)
208
-	if ($row and $valeur == $row['valeur']
209
-		and isset($GLOBALS[$table][$nom])
210
-		and $GLOBALS[$table][$nom] == $valeur
211
-	) {
212
-		return;
213
-	}
206
+    // ne pas invalider le cache si affectation a l'identique
207
+    // (tant pis si impt aurait du changer)
208
+    if ($row and $valeur == $row['valeur']
209
+        and isset($GLOBALS[$table][$nom])
210
+        and $GLOBALS[$table][$nom] == $valeur
211
+    ) {
212
+        return;
213
+    }
214 214
 
215
-	$GLOBALS[$table][$nom] = $valeur;
216
-	// cf effacer pour comprendre le double touch
217
-	$antidate = time() - (_META_CACHE_TIME << 1);
218
-	if (!isset($touch[$table])) {
219
-		touch_meta($antidate, $table);
220
-	}
221
-	$r = array('nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text'));
222
-	// Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
223
-	// ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot
224
-	// de lecture des descriptions des tables
225
-	if ($importable and isset($row['impt'])) {
226
-		$r['impt'] = sql_quote($importable, '', 'text');
227
-	}
228
-	if ($row) {
229
-		sql_update('spip_' . $table, $r, "nom=" . sql_quote($nom));
230
-	} else {
231
-		sql_insert('spip_' . $table, "(" . join(',', array_keys($r)) . ")", "(" . join(',', array_values($r)) . ")");
232
-	}
233
-	if (!isset($touch[$table])) {
234
-		touch_meta($antidate, $table);
235
-		$touch[$table] = false;
236
-	}
215
+    $GLOBALS[$table][$nom] = $valeur;
216
+    // cf effacer pour comprendre le double touch
217
+    $antidate = time() - (_META_CACHE_TIME << 1);
218
+    if (!isset($touch[$table])) {
219
+        touch_meta($antidate, $table);
220
+    }
221
+    $r = array('nom' => sql_quote($nom, '', 'text'), 'valeur' => sql_quote($valeur, '', 'text'));
222
+    // Gaffe aux tables sans impt (vieilles versions de SPIP notamment)
223
+    // ici on utilise pas sql_updateq et sql_insertq pour ne pas provoquer trop tot
224
+    // de lecture des descriptions des tables
225
+    if ($importable and isset($row['impt'])) {
226
+        $r['impt'] = sql_quote($importable, '', 'text');
227
+    }
228
+    if ($row) {
229
+        sql_update('spip_' . $table, $r, "nom=" . sql_quote($nom));
230
+    } else {
231
+        sql_insert('spip_' . $table, "(" . join(',', array_keys($r)) . ")", "(" . join(',', array_values($r)) . ")");
232
+    }
233
+    if (!isset($touch[$table])) {
234
+        touch_meta($antidate, $table);
235
+        $touch[$table] = false;
236
+    }
237 237
 }
238 238
 
239 239
 /**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
  *     Nom du fichier cache
246 246
  **/
247 247
 function cache_meta($table = 'meta') {
248
-	return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php');
248
+    return ($table == 'meta') ? _FILE_META : (_DIR_CACHE . $table . '.php');
249 249
 }
250 250
 
251 251
 /**
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
  * @param string $table
255 255
  */
256 256
 function installer_table_meta($table) {
257
-	$trouver_table = charger_fonction('trouver_table', 'base');
258
-	if (!$trouver_table("spip_$table")) {
259
-		include_spip('base/auxiliaires');
260
-		include_spip('base/create');
261
-		creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false);
262
-		$trouver_table('');
263
-	}
264
-	lire_metas($table);
257
+    $trouver_table = charger_fonction('trouver_table', 'base');
258
+    if (!$trouver_table("spip_$table")) {
259
+        include_spip('base/auxiliaires');
260
+        include_spip('base/create');
261
+        creer_ou_upgrader_table("spip_$table", $GLOBALS['tables_auxiliaires']['spip_meta'], false, false);
262
+        $trouver_table('');
263
+    }
264
+    lire_metas($table);
265 265
 }
266 266
 
267 267
 /**
@@ -273,47 +273,47 @@  discard block
 block discarded – undo
273 273
  * @param bool $force
274 274
  */
275 275
 function supprimer_table_meta($table, $force = false) {
276
-	if ($table !== 'meta') {
277
-		// Vérifier le contenu restant de la table
278
-		$nb_variables = sql_countsel("spip_$table");
276
+    if ($table !== 'meta') {
277
+        // Vérifier le contenu restant de la table
278
+        $nb_variables = sql_countsel("spip_$table");
279 279
 
280
-		// Supprimer si :
281
-		// - la table est vide
282
-		// - ou limitée à la variable charset
283
-		// - ou qu'on force la suppression
284
-		if (
285
-			$force
286
-			or !$nb_variables
287
-			or (
288
-				($nb_variables == 1)
289
-				and isset($GLOBALS[$table]['charset'])
290
-			)
291
-		) {
292
-			// Supprimer la table des globaleset de la base
293
-			unset($GLOBALS[$table]);
294
-			sql_drop_table("spip_$table");
295
-			// Supprimer le fichier cache
296
-			include_spip('inc/flock');
297
-			$cache = cache_meta($table);
298
-			supprimer_fichier($cache);
280
+        // Supprimer si :
281
+        // - la table est vide
282
+        // - ou limitée à la variable charset
283
+        // - ou qu'on force la suppression
284
+        if (
285
+            $force
286
+            or !$nb_variables
287
+            or (
288
+                ($nb_variables == 1)
289
+                and isset($GLOBALS[$table]['charset'])
290
+            )
291
+        ) {
292
+            // Supprimer la table des globaleset de la base
293
+            unset($GLOBALS[$table]);
294
+            sql_drop_table("spip_$table");
295
+            // Supprimer le fichier cache
296
+            include_spip('inc/flock');
297
+            $cache = cache_meta($table);
298
+            supprimer_fichier($cache);
299 299
 
300
-			// vider le cache des tables
301
-			$trouver_table = charger_fonction('trouver_table', 'base');
302
-			$trouver_table('');
300
+            // vider le cache des tables
301
+            $trouver_table = charger_fonction('trouver_table', 'base');
302
+            $trouver_table('');
303 303
 
304
-			// Supprimer la table de la liste des tables de configuration autres que spip_meta
305
-			if (isset($GLOBALS['meta']['tables_config'])) {
306
-				$liste = unserialize($GLOBALS['meta']['tables_config']);
307
-				$cle = array_search($table, $liste);
308
-				if ($cle !== false) {
309
-					unset($liste[$cle]);
310
-					if ($liste ) {
311
-						ecrire_meta('tables_config', serialize($liste));
312
-					} else {
313
-						effacer_meta('tables_config');
314
-					}
315
-				}
316
-			}
317
-		}
318
-	}
304
+            // Supprimer la table de la liste des tables de configuration autres que spip_meta
305
+            if (isset($GLOBALS['meta']['tables_config'])) {
306
+                $liste = unserialize($GLOBALS['meta']['tables_config']);
307
+                $cle = array_search($table, $liste);
308
+                if ($cle !== false) {
309
+                    unset($liste[$cle]);
310
+                    if ($liste ) {
311
+                        ecrire_meta('tables_config', serialize($liste));
312
+                    } else {
313
+                        effacer_meta('tables_config');
314
+                    }
315
+                }
316
+            }
317
+        }
318
+    }
319 319
 }
Please login to merge, or discard this patch.
ecrire/inc/lien.php 1 patch
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('base/abstract_sql');
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 //
24 24
 
25 25
 function inc_lien_dist(
26
-	$lien,
27
-	$texte = '',
28
-	$class = '',
29
-	$title = '',
30
-	$hlang = '',
31
-	$rel = '',
32
-	$connect = '',
33
-	$env = array()
26
+    $lien,
27
+    $texte = '',
28
+    $class = '',
29
+    $title = '',
30
+    $hlang = '',
31
+    $rel = '',
32
+    $connect = '',
33
+    $env = array()
34 34
 ) {
35
-	return $lien;
35
+    return $lien;
36 36
 }
37 37
 
38 38
 // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 // https://code.spip.net/@expanser_liens
45 45
 function expanser_liens($t, $connect = '', $env = array()) {
46 46
 
47
-	$t = pipeline('pre_liens', $t);
47
+    $t = pipeline('pre_liens', $t);
48 48
 
49
-	// on passe a traiter_modeles la liste des liens reperes pour lui permettre
50
-	// de remettre le texte d'origine dans les parametres du modele
51
-	$t = traiter_modeles($t, false, false, $connect);
49
+    // on passe a traiter_modeles la liste des liens reperes pour lui permettre
50
+    // de remettre le texte d'origine dans les parametres du modele
51
+    $t = traiter_modeles($t, false, false, $connect);
52 52
 
53
-	return $t;
53
+    return $t;
54 54
 }
55 55
 
56 56
 // Meme analyse mais pour eliminer les liens
57 57
 // et ne laisser que leur titre, a expliciter si ce n'est fait
58 58
 // https://code.spip.net/@nettoyer_raccourcis_typo
59 59
 function nettoyer_raccourcis_typo($texte, $connect = '') {
60
-	return $texte;
60
+    return $texte;
61 61
 }
62 62
 
63 63
 // Repere dans la partie texte d'un raccourci [texte->...]
64 64
 // la langue et la bulle eventuelles
65 65
 // https://code.spip.net/@traiter_raccourci_lien_atts
66 66
 function traiter_raccourci_lien_atts($texte) {
67
-	$bulle = '';
68
-	$hlang = '';
67
+    $bulle = '';
68
+    $hlang = '';
69 69
 
70
-	return array(trim($texte), $bulle, $hlang);
70
+    return array(trim($texte), $bulle, $hlang);
71 71
 }
72 72
 
73 73
 define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/');
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
  * @return string
84 84
  */
85 85
 function virtuel_redirige($virtuel, $url = false) {
86
-	return $virtuel;
86
+    return $virtuel;
87 87
 }
88 88
 
89 89
 // Cherche un lien du type [->raccourci 123]
@@ -97,114 +97,114 @@  discard block
 block discarded – undo
97 97
 
98 98
 // https://code.spip.net/@calculer_url
99 99
 function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) {
100
-	$r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo);
100
+    $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo);
101 101
 
102
-	return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
102
+    return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
103 103
 }
104 104
 
105 105
 define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
106 106
 
107 107
 // https://code.spip.net/@traiter_lien_explicite
108 108
 function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) {
109
-	if (preg_match(_EXTRAIRE_LIEN, $ref)) {
110
-		return ($pour != 'tout') ? '' : array('', '', '', '');
111
-	}
112
-
113
-	$lien = entites_html(trim($ref));
114
-
115
-	// Liens explicites
116
-	if (!$texte) {
117
-		$texte = str_replace('"', '', $lien);
118
-		// evite l'affichage de trops longues urls.
119
-		$lien_court = charger_fonction('lien_court', 'inc');
120
-		$texte = $lien_court($texte);
121
-		if ($echappe_typo) {
122
-			$texte = "<html>" . quote_amp($texte) . "</html>";
123
-		}
124
-	}
125
-
126
-	// petites corrections d'URL
127
-	if (preg_match('/^www\.[^@]+$/S', $lien)) {
128
-		$lien = "http://" . $lien;
129
-	} else {
130
-		if (strpos($lien, "@") && email_valide($lien)) {
131
-			if (!$texte) {
132
-				$texte = $lien;
133
-			}
134
-			$lien = "mailto:" . $lien;
135
-		}
136
-	}
137
-
138
-	if ($pour == 'url') {
139
-		return $lien;
140
-	}
141
-
142
-	if ($pour == 'titre') {
143
-		return $texte;
144
-	}
145
-
146
-	return array('url' => $lien, 'titre' => $texte);
109
+    if (preg_match(_EXTRAIRE_LIEN, $ref)) {
110
+        return ($pour != 'tout') ? '' : array('', '', '', '');
111
+    }
112
+
113
+    $lien = entites_html(trim($ref));
114
+
115
+    // Liens explicites
116
+    if (!$texte) {
117
+        $texte = str_replace('"', '', $lien);
118
+        // evite l'affichage de trops longues urls.
119
+        $lien_court = charger_fonction('lien_court', 'inc');
120
+        $texte = $lien_court($texte);
121
+        if ($echappe_typo) {
122
+            $texte = "<html>" . quote_amp($texte) . "</html>";
123
+        }
124
+    }
125
+
126
+    // petites corrections d'URL
127
+    if (preg_match('/^www\.[^@]+$/S', $lien)) {
128
+        $lien = "http://" . $lien;
129
+    } else {
130
+        if (strpos($lien, "@") && email_valide($lien)) {
131
+            if (!$texte) {
132
+                $texte = $lien;
133
+            }
134
+            $lien = "mailto:" . $lien;
135
+        }
136
+    }
137
+
138
+    if ($pour == 'url') {
139
+        return $lien;
140
+    }
141
+
142
+    if ($pour == 'titre') {
143
+        return $texte;
144
+    }
145
+
146
+    return array('url' => $lien, 'titre' => $texte);
147 147
 }
148 148
 
149 149
 function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') {
150
-	if (function_exists($f = 'glossaire_' . $ancre)) {
151
-		$url = $f($texte, $id);
152
-	} else {
153
-		$url = glossaire_std($texte);
154
-	}
150
+    if (function_exists($f = 'glossaire_' . $ancre)) {
151
+        $url = $f($texte, $id);
152
+    } else {
153
+        $url = glossaire_std($texte);
154
+    }
155 155
 
156
-	return $url;
156
+    return $url;
157 157
 }
158 158
 
159 159
 // https://code.spip.net/@traiter_lien_implicite
160 160
 function traiter_lien_implicite($ref, $texte = '', $pour = 'url', $connect = '') {
161
-	if (!($match = typer_raccourci($ref))) {
162
-		return false;
163
-	}
164
-	@list($type, , $id, , $args, , $ancre) = $match;
165
-	// attention dans le cas des sites le lien doit pointer non pas sur
166
-	// la page locale du site, mais directement sur le site lui-meme
167
-	if ($f = charger_fonction("implicite_$type", "liens", true)) {
168
-		$url = $f($texte, $id, $type, $args, $ancre, $connect);
169
-	}
170
-	if (!$url) {
171
-		$url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null);
172
-	}
173
-	if (!$url) {
174
-		return false;
175
-	}
176
-	if (is_array($url)) {
177
-		@list($type, $id) = $url;
178
-		$url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null);
179
-	}
180
-	if ($pour === 'url') {
181
-		return $url;
182
-	}
183
-	$r = traiter_raccourci_titre($id, $type, $connect);
184
-	if ($r) {
185
-		$r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
186
-	}
187
-	if ($texte = trim($texte)) {
188
-		$r['titre'] = $texte;
189
-	}
190
-	if (!@$r['titre']) {
191
-		$r['titre'] = _T($type) . " $id";
192
-	}
193
-	if ($pour == 'titre') {
194
-		return $r['titre'];
195
-	}
196
-	$r['url'] = $url;
197
-
198
-	// dans le cas d'un lien vers un doc, ajouter le type='mime/type'
199
-	if ($type == 'document'
200
-		and $mime = sql_getfetsel('mime_type', 'spip_types_documents',
201
-			"extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")",
202
-			'', '', '', '', $connect)
203
-	) {
204
-		$r['mime'] = $mime;
205
-	}
206
-
207
-	return $r;
161
+    if (!($match = typer_raccourci($ref))) {
162
+        return false;
163
+    }
164
+    @list($type, , $id, , $args, , $ancre) = $match;
165
+    // attention dans le cas des sites le lien doit pointer non pas sur
166
+    // la page locale du site, mais directement sur le site lui-meme
167
+    if ($f = charger_fonction("implicite_$type", "liens", true)) {
168
+        $url = $f($texte, $id, $type, $args, $ancre, $connect);
169
+    }
170
+    if (!$url) {
171
+        $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null);
172
+    }
173
+    if (!$url) {
174
+        return false;
175
+    }
176
+    if (is_array($url)) {
177
+        @list($type, $id) = $url;
178
+        $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null);
179
+    }
180
+    if ($pour === 'url') {
181
+        return $url;
182
+    }
183
+    $r = traiter_raccourci_titre($id, $type, $connect);
184
+    if ($r) {
185
+        $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
186
+    }
187
+    if ($texte = trim($texte)) {
188
+        $r['titre'] = $texte;
189
+    }
190
+    if (!@$r['titre']) {
191
+        $r['titre'] = _T($type) . " $id";
192
+    }
193
+    if ($pour == 'titre') {
194
+        return $r['titre'];
195
+    }
196
+    $r['url'] = $url;
197
+
198
+    // dans le cas d'un lien vers un doc, ajouter le type='mime/type'
199
+    if ($type == 'document'
200
+        and $mime = sql_getfetsel('mime_type', 'spip_types_documents',
201
+            "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")",
202
+            '', '', '', '', $connect)
203
+    ) {
204
+        $r['mime'] = $mime;
205
+    }
206
+
207
+    return $r;
208 208
 }
209 209
 
210 210
 // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes
@@ -213,41 +213,41 @@  discard block
 block discarded – undo
213 213
 
214 214
 // https://code.spip.net/@typer_raccourci
215 215
 function typer_raccourci($lien) {
216
-	if (!preg_match(_RACCOURCI_URL, $lien, $match)) {
217
-		return array();
218
-	}
219
-	$f = $match[1];
220
-	// valeur par defaut et alias historiques
221
-	if (!$f) {
222
-		$f = 'article';
223
-	} else {
224
-		if ($f == 'art') {
225
-			$f = 'article';
226
-		} else {
227
-			if ($f == 'br') {
228
-				$f = 'breve';
229
-			} else {
230
-				if ($f == 'rub') {
231
-					$f = 'rubrique';
232
-				} else {
233
-					if ($f == 'aut') {
234
-						$f = 'auteur';
235
-					} else {
236
-						if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') {
237
-							$f = 'document';
238
-						} else {
239
-							if (preg_match('/^br..?ve$/S', $f)) {
240
-								$f = 'breve';
241
-							}
242
-						}
243
-					}
244
-				}
245
-			}
246
-		}
247
-	} # accents :(
248
-	$match[0] = $f;
249
-
250
-	return $match;
216
+    if (!preg_match(_RACCOURCI_URL, $lien, $match)) {
217
+        return array();
218
+    }
219
+    $f = $match[1];
220
+    // valeur par defaut et alias historiques
221
+    if (!$f) {
222
+        $f = 'article';
223
+    } else {
224
+        if ($f == 'art') {
225
+            $f = 'article';
226
+        } else {
227
+            if ($f == 'br') {
228
+                $f = 'breve';
229
+            } else {
230
+                if ($f == 'rub') {
231
+                    $f = 'rubrique';
232
+                } else {
233
+                    if ($f == 'aut') {
234
+                        $f = 'auteur';
235
+                    } else {
236
+                        if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') {
237
+                            $f = 'document';
238
+                        } else {
239
+                            if (preg_match('/^br..?ve$/S', $f)) {
240
+                                $f = 'breve';
241
+                            }
242
+                        }
243
+                    }
244
+                }
245
+            }
246
+        }
247
+    } # accents :(
248
+    $match[0] = $f;
249
+
250
+    return $match;
251 251
 }
252 252
 
253 253
 /**
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
  * }
263 263
  **/
264 264
 function traiter_raccourci_titre($id, $type, $connect = null) {
265
-	$trouver_table = charger_fonction('trouver_table', 'base');
266
-	$desc = $trouver_table(table_objet($type));
267
-	if (!($desc and $s = $desc['titre'])) {
268
-		return array();
269
-	}
270
-	$_id = $desc['key']['PRIMARY KEY'];
271
-	$r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
272
-	if (!$r) {
273
-		return array();
274
-	}
275
-	$r['titre'] = supprimer_numero($r['titre']);
276
-	if (!$r['titre'] and !empty($r['surnom'])) {
277
-		$r['titre'] = $r['surnom'];
278
-	}
279
-	if (!isset($r['lang'])) {
280
-		$r['lang'] = '';
281
-	}
282
-
283
-	return $r;
265
+    $trouver_table = charger_fonction('trouver_table', 'base');
266
+    $desc = $trouver_table(table_objet($type));
267
+    if (!($desc and $s = $desc['titre'])) {
268
+        return array();
269
+    }
270
+    $_id = $desc['key']['PRIMARY KEY'];
271
+    $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
272
+    if (!$r) {
273
+        return array();
274
+    }
275
+    $r['titre'] = supprimer_numero($r['titre']);
276
+    if (!$r['titre'] and !empty($r['surnom'])) {
277
+        $r['titre'] = $r['surnom'];
278
+    }
279
+    if (!isset($r['lang'])) {
280
+        $r['lang'] = '';
281
+    }
282
+
283
+    return $r;
284 284
 }
285 285
 
286 286
 // traite les modeles (dans la fonction typo), en remplacant
@@ -292,115 +292,115 @@  discard block
 block discarded – undo
292 292
 // https://code.spip.net/@traiter_modeles
293 293
 
294 294
 define('_RACCOURCI_MODELE',
295
-	'(<([a-z_-]{3,})' # <modele
296
-	. '\s*([0-9]*)\s*' # id
297
-	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
298
-	. '\s*/?' . '>)' # fin du modele >
299
-	. '\s*(<\/a>)?' # eventuel </a>
295
+    '(<([a-z_-]{3,})' # <modele
296
+    . '\s*([0-9]*)\s*' # id
297
+    . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
298
+    . '\s*/?' . '>)' # fin du modele >
299
+    . '\s*(<\/a>)?' # eventuel </a>
300 300
 );
301 301
 
302 302
 define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS');
303 303
 
304 304
 // https://code.spip.net/@traiter_modeles
305 305
 function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) {
306
-	// preserver la compatibilite : true = recherche des documents
307
-	if ($doublons === true) {
308
-		$doublons = array('documents' => array('doc', 'emb', 'img'));
309
-	}
310
-	// detecter les modeles (rapide)
311
-	if (strpos($texte, "<") !== false and
312
-		preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)
313
-	) {
314
-		include_spip('public/assembler');
315
-		$wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true);
316
-		foreach ($matches as $match) {
317
-			// Recuperer l'appel complet (y compris un eventuel lien)
318
-
319
-			$a = strpos($texte, $match[0]);
320
-			preg_match(_RACCOURCI_MODELE_DEBUT,
321
-				substr($texte, $a), $regs);
322
-			$regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
323
-			list(, $mod, $type, $id, $params, $fin) = $regs;
324
-			if ($fin and
325
-				preg_match('/<a\s[^<>]*>\s*$/i',
326
-					substr($texte, 0, $a), $r)
327
-			) {
328
-				$lien = array(
329
-					'href' => extraire_attribut($r[0], 'href'),
330
-					'class' => extraire_attribut($r[0], 'class'),
331
-					'mime' => extraire_attribut($r[0], 'type'),
332
-					'title' => extraire_attribut($r[0], 'title'),
333
-					'hreflang' => extraire_attribut($r[0], 'hreflang')
334
-				);
335
-				$n = strlen($r[0]);
336
-				$a -= $n;
337
-				$cherche = $n + strlen($regs[0]);
338
-			} else {
339
-				$lien = false;
340
-				$cherche = strlen($mod);
341
-			}
342
-
343
-			// calculer le modele
344
-			# hack indexation
345
-			if ($doublons) {
346
-				$texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
347
-			} # version normale
348
-			else {
349
-				// si un tableau de liens a ete passe, reinjecter le contenu d'origine
350
-				// dans les parametres, plutot que les liens echappes
351
-				if (!is_null($liens)) {
352
-					$params = str_replace($liens[0], $liens[1], $params);
353
-				}
354
-				$modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
355
-				// en cas d'echec, 
356
-				// si l'objet demande a une url, 
357
-				// creer un petit encadre vers elle
358
-				if ($modele === false) {
359
-					if (!$lien) {
360
-						$lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
361
-					}
362
-					if ($lien) {
363
-						$modele = '<a href="'
364
-							. $lien['url']
365
-							. '" class="spip_modele'
366
-							. '">'
367
-							. sinon($lien['titre'], _T('ecrire:info_sans_titre'))
368
-							. "</a>";
369
-					} else {
370
-						$modele = "";
371
-						if (test_espace_prive()) {
372
-							$modele = entites_html(substr($texte, $a, $cherche));
373
-							if (!is_null($liens)) {
374
-								$modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>";
375
-							}
376
-						}
377
-					}
378
-				}
379
-				// le remplacer dans le texte
380
-				if ($modele !== false) {
381
-					$modele = protege_js_modeles($modele);
382
-					if ($wrap_embed_html) {
383
-						$modele = $wrap_embed_html($mod, $modele);
384
-					}
385
-					$rempl = code_echappement($modele, $echap);
386
-					$texte = substr($texte, 0, $a)
387
-						. $rempl
388
-						. substr($texte, $a + $cherche);
389
-				}
390
-			}
391
-
392
-			// hack pour tout l'espace prive
393
-			if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) {
394
-				foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) {
395
-					if (in_array($type, $modeles)) {
396
-						$GLOBALS["doublons_{$quoi}_inclus"][] = $id;
397
-					}
398
-				}
399
-			}
400
-		}
401
-	}
402
-
403
-	return $texte;
306
+    // preserver la compatibilite : true = recherche des documents
307
+    if ($doublons === true) {
308
+        $doublons = array('documents' => array('doc', 'emb', 'img'));
309
+    }
310
+    // detecter les modeles (rapide)
311
+    if (strpos($texte, "<") !== false and
312
+        preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)
313
+    ) {
314
+        include_spip('public/assembler');
315
+        $wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true);
316
+        foreach ($matches as $match) {
317
+            // Recuperer l'appel complet (y compris un eventuel lien)
318
+
319
+            $a = strpos($texte, $match[0]);
320
+            preg_match(_RACCOURCI_MODELE_DEBUT,
321
+                substr($texte, $a), $regs);
322
+            $regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
323
+            list(, $mod, $type, $id, $params, $fin) = $regs;
324
+            if ($fin and
325
+                preg_match('/<a\s[^<>]*>\s*$/i',
326
+                    substr($texte, 0, $a), $r)
327
+            ) {
328
+                $lien = array(
329
+                    'href' => extraire_attribut($r[0], 'href'),
330
+                    'class' => extraire_attribut($r[0], 'class'),
331
+                    'mime' => extraire_attribut($r[0], 'type'),
332
+                    'title' => extraire_attribut($r[0], 'title'),
333
+                    'hreflang' => extraire_attribut($r[0], 'hreflang')
334
+                );
335
+                $n = strlen($r[0]);
336
+                $a -= $n;
337
+                $cherche = $n + strlen($regs[0]);
338
+            } else {
339
+                $lien = false;
340
+                $cherche = strlen($mod);
341
+            }
342
+
343
+            // calculer le modele
344
+            # hack indexation
345
+            if ($doublons) {
346
+                $texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
347
+            } # version normale
348
+            else {
349
+                // si un tableau de liens a ete passe, reinjecter le contenu d'origine
350
+                // dans les parametres, plutot que les liens echappes
351
+                if (!is_null($liens)) {
352
+                    $params = str_replace($liens[0], $liens[1], $params);
353
+                }
354
+                $modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
355
+                // en cas d'echec, 
356
+                // si l'objet demande a une url, 
357
+                // creer un petit encadre vers elle
358
+                if ($modele === false) {
359
+                    if (!$lien) {
360
+                        $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
361
+                    }
362
+                    if ($lien) {
363
+                        $modele = '<a href="'
364
+                            . $lien['url']
365
+                            . '" class="spip_modele'
366
+                            . '">'
367
+                            . sinon($lien['titre'], _T('ecrire:info_sans_titre'))
368
+                            . "</a>";
369
+                    } else {
370
+                        $modele = "";
371
+                        if (test_espace_prive()) {
372
+                            $modele = entites_html(substr($texte, $a, $cherche));
373
+                            if (!is_null($liens)) {
374
+                                $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>";
375
+                            }
376
+                        }
377
+                    }
378
+                }
379
+                // le remplacer dans le texte
380
+                if ($modele !== false) {
381
+                    $modele = protege_js_modeles($modele);
382
+                    if ($wrap_embed_html) {
383
+                        $modele = $wrap_embed_html($mod, $modele);
384
+                    }
385
+                    $rempl = code_echappement($modele, $echap);
386
+                    $texte = substr($texte, 0, $a)
387
+                        . $rempl
388
+                        . substr($texte, $a + $cherche);
389
+                }
390
+            }
391
+
392
+            // hack pour tout l'espace prive
393
+            if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) {
394
+                foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) {
395
+                    if (in_array($type, $modeles)) {
396
+                        $GLOBALS["doublons_{$quoi}_inclus"][] = $id;
397
+                    }
398
+                }
399
+            }
400
+        }
401
+    }
402
+
403
+    return $texte;
404 404
 }
405 405
 
406 406
 //
@@ -408,15 +408,15 @@  discard block
 block discarded – undo
408 408
 //
409 409
 // https://code.spip.net/@traiter_raccourci_ancre
410 410
 function traiter_raccourci_ancre($letexte) {
411
-	return $letexte;
411
+    return $letexte;
412 412
 }
413 413
 
414 414
 // https://code.spip.net/@traiter_raccourci_glossaire
415 415
 function traiter_raccourci_glossaire($texte) {
416
-	return $texte;
416
+    return $texte;
417 417
 }
418 418
 
419 419
 // https://code.spip.net/@glossaire_std
420 420
 function glossaire_std($terme) {
421
-	return $terme;
421
+    return $terme;
422 422
 }
Please login to merge, or discard this patch.
ecrire/inc/presentation_mini.php 1 patch
Indentation   +129 added lines, -129 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
 /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
  * @return string Code HTML
46 46
  */
47 47
 function debut_gauche() {
48
-	return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n";
48
+    return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n";
49 49
 }
50 50
 
51 51
 /**
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
  * @return string Code HTML
62 62
  */
63 63
 function creer_colonne_droite() {
64
-	static $deja_colonne_droite;
65
-	if ($deja_colonne_droite) {
66
-		return '';
67
-	}
68
-	$deja_colonne_droite = true;
64
+    static $deja_colonne_droite;
65
+    if ($deja_colonne_droite) {
66
+        return '';
67
+    }
68
+    $deja_colonne_droite = true;
69 69
 
70
-	return "\n</div><div id='extra' class='lat' role='complementary'>";
70
+    return "\n</div><div id='extra' class='lat' role='complementary'>";
71 71
 }
72 72
 
73 73
 /**
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
  * @return string Code HTML
77 77
  */
78 78
 function debut_droite() {
79
-	return liste_objets_bloques(_request('exec'))
80
-	. creer_colonne_droite()
81
-	. "</div>"
82
-	. "\n<div id='contenu'>";
79
+    return liste_objets_bloques(_request('exec'))
80
+    . creer_colonne_droite()
81
+    . "</div>"
82
+    . "\n<div id='contenu'>";
83 83
 }
84 84
 
85 85
 /**
@@ -101,30 +101,30 @@  discard block
 block discarded – undo
101 101
  *     Code HTML
102 102
  **/
103 103
 function liste_objets_bloques($exec, $contexte = array(), $auteur = null) {
104
-	$res = '';
105
-	if ($GLOBALS['meta']["articles_modif"] != "non") {
106
-		include_spip('inc/drapeau_edition');
107
-		if (is_null($auteur)) {
108
-			$auteur = $GLOBALS['visiteur_session'];
109
-		}
110
-		if ($en_cours = trouver_objet_exec($exec)
111
-			and $en_cours['edition']
112
-			and $type = $en_cours['type']
113
-			and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
114
-				or $id = _request($en_cours['id_table_objet']))
115
-		) {
116
-			// marquer le fait que l'objet est ouvert en edition par toto
117
-			// a telle date ; une alerte sera donnee aux autres redacteurs
118
-			signale_edition($id, $auteur, $type);
119
-		}
120
-
121
-		$objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
122
-		if (count($objets_ouverts)) {
123
-			$res .= recuperer_fond('prive/objets/liste/objets-en-edition', array(), array('ajax' => true));
124
-		}
125
-	}
126
-
127
-	return $res;
104
+    $res = '';
105
+    if ($GLOBALS['meta']["articles_modif"] != "non") {
106
+        include_spip('inc/drapeau_edition');
107
+        if (is_null($auteur)) {
108
+            $auteur = $GLOBALS['visiteur_session'];
109
+        }
110
+        if ($en_cours = trouver_objet_exec($exec)
111
+            and $en_cours['edition']
112
+            and $type = $en_cours['type']
113
+            and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
114
+                or $id = _request($en_cours['id_table_objet']))
115
+        ) {
116
+            // marquer le fait que l'objet est ouvert en edition par toto
117
+            // a telle date ; une alerte sera donnee aux autres redacteurs
118
+            signale_edition($id, $auteur, $type);
119
+        }
120
+
121
+        $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
122
+        if (count($objets_ouverts)) {
123
+            $res .= recuperer_fond('prive/objets/liste/objets-en-edition', array(), array('ajax' => true));
124
+        }
125
+    }
126
+
127
+    return $res;
128 128
 }
129 129
 
130 130
 
@@ -138,20 +138,20 @@  discard block
 block discarded – undo
138 138
  * @return string Code HTML
139 139
  **/
140 140
 function fin_page() {
141
-	include_spip('inc/pipelines');
142
-	// avec &var_profile=1 on a le tableau de mesures SQL
143
-	$debug = ((_request('exec') !== 'valider_xml')
144
-		and ((_request('var_mode') == 'debug')
145
-			or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
146
-			and isset($_COOKIE['spip_admin'])));
147
-	$t = '</div><div id="pied"><div class="largeur">'
148
-		. recuperer_fond('prive/squelettes/inclure/pied')
149
-		. "</div>"
150
-		. "</div></div>" // cf. div#page et div.largeur ouvertes dans conmmencer_page()
151
-		. ($debug ? erreur_squelette() : '')
152
-		. "</body></html>\n";
153
-
154
-	return f_queue($t);
141
+    include_spip('inc/pipelines');
142
+    // avec &var_profile=1 on a le tableau de mesures SQL
143
+    $debug = ((_request('exec') !== 'valider_xml')
144
+        and ((_request('var_mode') == 'debug')
145
+            or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
146
+            and isset($_COOKIE['spip_admin'])));
147
+    $t = '</div><div id="pied"><div class="largeur">'
148
+        . recuperer_fond('prive/squelettes/inclure/pied')
149
+        . "</div>"
150
+        . "</div></div>" // cf. div#page et div.largeur ouvertes dans conmmencer_page()
151
+        . ($debug ? erreur_squelette() : '')
152
+        . "</body></html>\n";
153
+
154
+    return f_queue($t);
155 155
 }
156 156
 
157 157
 /**
@@ -166,20 +166,20 @@  discard block
 block discarded – undo
166 166
  * @return string Code HTML
167 167
  **/
168 168
 function html_tests_js() {
169
-	if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
170
-		// pour le pied de page (deja defini si on est validation XML)
171
-		define('_TESTER_NOSCRIPT',
172
-			"<noscript>\n<div style='display:none;'><img src='"
173
-			. generer_url_ecrire('test_ajax', 'js=-1')
174
-			. "' width='1' height='1' alt='' /></div></noscript>\n");
175
-	}
176
-
177
-	$rejouer = '';
178
-	if (defined('_SESSION_REJOUER')) {
179
-		$rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
180
-	}
181
-
182
-	return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
169
+    if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
170
+        // pour le pied de page (deja defini si on est validation XML)
171
+        define('_TESTER_NOSCRIPT',
172
+            "<noscript>\n<div style='display:none;'><img src='"
173
+            . generer_url_ecrire('test_ajax', 'js=-1')
174
+            . "' width='1' height='1' alt='' /></div></noscript>\n");
175
+    }
176
+
177
+    $rejouer = '';
178
+    if (defined('_SESSION_REJOUER')) {
179
+        $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
180
+    }
181
+
182
+    return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
183 183
 }
184 184
 
185 185
 /**
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
  **/
190 190
 function info_maj_spip() {
191 191
 
192
-	$maj = isset($GLOBALS['meta']['info_maj_spip']) ? $GLOBALS['meta']['info_maj_spip'] : null;
193
-	if (!$maj) {
194
-		return "";
195
-	}
192
+    $maj = isset($GLOBALS['meta']['info_maj_spip']) ? $GLOBALS['meta']['info_maj_spip'] : null;
193
+    if (!$maj) {
194
+        return "";
195
+    }
196 196
 
197
-	$maj = explode('|', $maj);
198
-	// c'est une ancienne notif, on a fait la maj depuis !
199
-	if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
200
-		return "";
201
-	}
197
+    $maj = explode('|', $maj);
198
+    // c'est une ancienne notif, on a fait la maj depuis !
199
+    if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
200
+        return "";
201
+    }
202 202
 
203
-	if (!autoriser('webmestre')) {
204
-		return "";
205
-	}
203
+    if (!autoriser('webmestre')) {
204
+        return "";
205
+    }
206 206
 
207
-	array_shift($maj);
208
-	$maj = implode('|', $maj);
207
+    array_shift($maj);
208
+    $maj = implode('|', $maj);
209 209
 
210
-	return "$maj<br />";
210
+    return "$maj<br />";
211 211
 }
212 212
 
213 213
 /**
@@ -218,43 +218,43 @@  discard block
 block discarded – undo
218 218
  **/
219 219
 function info_copyright() {
220 220
 
221
-	$version = $GLOBALS['spip_version_affichee'];
222
-
223
-	//
224
-	// Mention, le cas echeant, de la revision SVN courante
225
-	//
226
-	if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
227
-		if ($vcs['vcs'] === 'GIT') {
228
-			$url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
229
-		} elseif ($vcs['vcs'] === 'SVN') {
230
-			$url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
231
-		} else {
232
-			$url = '';
233
-		}
234
-		// affichage "GIT [master: abcdef]"
235
-		$commit = isset($vcs['commit_short']) ? $vcs['commit_short'] : $vcs['commit'];
236
-		if ($url) {
237
-			$commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
238
-		}
239
-		if ($vcs['branch']) {
240
-			$commit = $vcs['branch'] . ': ' . $commit;
241
-		}
242
-		$version .= " {$vcs['vcs']} [$commit]";
243
-	}
244
-
245
-	// et la version de l'ecran de securite
246
-	$secu = defined('_ECRAN_SECURITE')
247
-		? "<br />" . _T('ecran_securite', array('version' => _ECRAN_SECURITE))
248
-		: '';
249
-
250
-	return _T('info_copyright',
251
-		array(
252
-			'spip' => "<b>SPIP $version</b> ",
253
-			'lien_gpl' =>
254
-				"<a href='" . generer_url_ecrire("aide",
255
-					"aide=licence&var_lang=" . $GLOBALS['spip_lang']) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . "</a>"
256
-		))
257
-	. $secu;
221
+    $version = $GLOBALS['spip_version_affichee'];
222
+
223
+    //
224
+    // Mention, le cas echeant, de la revision SVN courante
225
+    //
226
+    if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
227
+        if ($vcs['vcs'] === 'GIT') {
228
+            $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
229
+        } elseif ($vcs['vcs'] === 'SVN') {
230
+            $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
231
+        } else {
232
+            $url = '';
233
+        }
234
+        // affichage "GIT [master: abcdef]"
235
+        $commit = isset($vcs['commit_short']) ? $vcs['commit_short'] : $vcs['commit'];
236
+        if ($url) {
237
+            $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
238
+        }
239
+        if ($vcs['branch']) {
240
+            $commit = $vcs['branch'] . ': ' . $commit;
241
+        }
242
+        $version .= " {$vcs['vcs']} [$commit]";
243
+    }
244
+
245
+    // et la version de l'ecran de securite
246
+    $secu = defined('_ECRAN_SECURITE')
247
+        ? "<br />" . _T('ecran_securite', array('version' => _ECRAN_SECURITE))
248
+        : '';
249
+
250
+    return _T('info_copyright',
251
+        array(
252
+            'spip' => "<b>SPIP $version</b> ",
253
+            'lien_gpl' =>
254
+                "<a href='" . generer_url_ecrire("aide",
255
+                    "aide=licence&var_lang=" . $GLOBALS['spip_lang']) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . "</a>"
256
+        ))
257
+    . $secu;
258 258
 
259 259
 }
260 260
 
@@ -270,17 +270,17 @@  discard block
 block discarded – undo
270 270
  * @return string             Code HTML
271 271
  **/
272 272
 function formulaire_recherche($page, $complement = "") {
273
-	$recherche = _request('recherche');
274
-	$recherche_aff = entites_html($recherche);
275
-	if (!strlen($recherche)) {
276
-		$recherche_aff = _T('info_rechercher');
277
-		$onfocus = " onfocus=\"this.value='';\"";
278
-	} else {
279
-		$onfocus = '';
280
-	}
281
-
282
-	$form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
283
-	$form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
284
-
285
-	return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . "</div>";
273
+    $recherche = _request('recherche');
274
+    $recherche_aff = entites_html($recherche);
275
+    if (!strlen($recherche)) {
276
+        $recherche_aff = _T('info_rechercher');
277
+        $onfocus = " onfocus=\"this.value='';\"";
278
+    } else {
279
+        $onfocus = '';
280
+    }
281
+
282
+    $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
283
+    $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
284
+
285
+    return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . "</div>";
286 286
 }
Please login to merge, or discard this patch.
ecrire/inc/json.php 1 patch
Indentation   +50 added lines, -50 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
 // Les fonctions de toggg pour faire du JSON
@@ -26,64 +26,64 @@  discard block
 block discarded – undo
26 26
 
27 27
 // https://code.spip.net/@var2js
28 28
 function var2js($var) {
29
-	$asso = false;
30
-	switch (true) {
31
-		case is_null($var):
32
-			return 'null';
33
-		case is_string($var):
34
-			return '"' . addcslashes($var, "\"\\\n\r/") . '"';
35
-		case is_bool($var):
36
-			return $var ? 'true' : 'false';
37
-		case is_scalar($var):
38
-			return (string)$var;
39
-		case is_object($var):// blam
40
-			$var = get_object_vars($var);
41
-			$asso = true;
42
-			// $var devient un array, on continue
43
-		case is_array($var):
44
-			$keys = array_keys($var);
45
-			$ikey = count($keys);
46
-			while (!$asso && $ikey--) {
47
-				$asso = $ikey !== $keys[$ikey];
48
-			}
49
-			$sep = '';
50
-			if ($asso) {
51
-				$ret = '{';
52
-				foreach ($var as $key => $elt) {
53
-					$ret .= $sep . '"' . $key . '":' . var2js($elt);
54
-					$sep = ',';
55
-				}
29
+    $asso = false;
30
+    switch (true) {
31
+        case is_null($var):
32
+            return 'null';
33
+        case is_string($var):
34
+            return '"' . addcslashes($var, "\"\\\n\r/") . '"';
35
+        case is_bool($var):
36
+            return $var ? 'true' : 'false';
37
+        case is_scalar($var):
38
+            return (string)$var;
39
+        case is_object($var):// blam
40
+            $var = get_object_vars($var);
41
+            $asso = true;
42
+            // $var devient un array, on continue
43
+        case is_array($var):
44
+            $keys = array_keys($var);
45
+            $ikey = count($keys);
46
+            while (!$asso && $ikey--) {
47
+                $asso = $ikey !== $keys[$ikey];
48
+            }
49
+            $sep = '';
50
+            if ($asso) {
51
+                $ret = '{';
52
+                foreach ($var as $key => $elt) {
53
+                    $ret .= $sep . '"' . $key . '":' . var2js($elt);
54
+                    $sep = ',';
55
+                }
56 56
 
57
-				return $ret . '}';
58
-			} else {
59
-				$ret = '[';
60
-				foreach ($var as $elt) {
61
-					$ret .= $sep . var2js($elt);
62
-					$sep = ',';
63
-				}
57
+                return $ret . '}';
58
+            } else {
59
+                $ret = '[';
60
+                foreach ($var as $elt) {
61
+                    $ret .= $sep . var2js($elt);
62
+                    $sep = ',';
63
+                }
64 64
 
65
-				return $ret . ']';
66
-			}
67
-	}
65
+                return $ret . ']';
66
+            }
67
+    }
68 68
 
69
-	return false;
69
+    return false;
70 70
 }
71 71
 
72 72
 if (!function_exists('json_encode')) {
73
-	function json_encode($v) {
74
-		return var2js($v);
75
-	}
73
+    function json_encode($v) {
74
+        return var2js($v);
75
+    }
76 76
 }
77 77
 
78 78
 // https://code.spip.net/@json_export
79 79
 function json_export($var) {
80
-	$var = json_encode($var);
80
+    $var = json_encode($var);
81 81
 
82
-	// flag indiquant qu'on est en iframe et qu'il faut proteger nos
83
-	// donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop
84
-	if (defined('FILE_UPLOAD')) {
85
-		return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>';
86
-	} else {
87
-		return $var;
88
-	}
82
+    // flag indiquant qu'on est en iframe et qu'il faut proteger nos
83
+    // donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop
84
+    if (defined('FILE_UPLOAD')) {
85
+        return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>';
86
+    } else {
87
+        return $var;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
ecrire/inc/layer.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -26,41 +26,41 @@  discard block
 block discarded – undo
26 26
  * @return string Code HTML du cadre dépliable
27 27
  **/
28 28
 function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') {
29
-	$bouton = bouton_block_depliable($titre, $deplie, $ids);
30
-
31
-	return
32
-		debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
33
-		. debut_block_depliable($deplie, $ids)
34
-		. "<div class='cadre_padding'>\n"
35
-		. $contenu
36
-		. "</div>\n"
37
-		. fin_block()
38
-		. fin_cadre();
29
+    $bouton = bouton_block_depliable($titre, $deplie, $ids);
30
+
31
+    return
32
+        debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
33
+        . debut_block_depliable($deplie, $ids)
34
+        . "<div class='cadre_padding'>\n"
35
+        . $contenu
36
+        . "</div>\n"
37
+        . fin_block()
38
+        . fin_cadre();
39 39
 }
40 40
 
41 41
 // https://code.spip.net/@block_parfois_visible
42 42
 function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) {
43
-	return "\n"
44
-	. bouton_block_depliable($invite, $visible, $nom)
45
-	. debut_block_depliable($visible, $nom)
46
-	. $masque
47
-	. fin_block();
43
+    return "\n"
44
+    . bouton_block_depliable($invite, $visible, $nom)
45
+    . debut_block_depliable($visible, $nom)
46
+    . $masque
47
+    . fin_block();
48 48
 }
49 49
 
50 50
 // https://code.spip.net/@debut_block_depliable
51 51
 function debut_block_depliable($deplie, $id = "") {
52
-	$class = ' blocdeplie';
53
-	// si on n'accepte pas js, ne pas fermer
54
-	if (!$deplie) {
55
-		$class = " blocreplie";
56
-	}
52
+    $class = ' blocdeplie';
53
+    // si on n'accepte pas js, ne pas fermer
54
+    if (!$deplie) {
55
+        $class = " blocreplie";
56
+    }
57 57
 
58
-	return "<div " . ($id ? "id='$id' " : "") . "class='bloc_depliable$class'>";
58
+    return "<div " . ($id ? "id='$id' " : "") . "class='bloc_depliable$class'>";
59 59
 }
60 60
 
61 61
 // https://code.spip.net/@fin_block
62 62
 function fin_block() {
63
-	return "<div class='nettoyeur'></div>\n</div>";
63
+    return "<div class='nettoyeur'></div>\n</div>";
64 64
 }
65 65
 
66 66
 // $texte : texte du bouton
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
69 69
 // https://code.spip.net/@bouton_block_depliable
70 70
 function bouton_block_depliable($texte, $deplie, $ids = "") {
71
-	$bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
72
-
73
-	$class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie");
74
-	if (strlen($ids)) {
75
-		$cible = explode(',', $ids);
76
-		$cible = '#' . implode(",#", $cible);
77
-	} else {
78
-		$cible = "#$bouton_id + div.bloc_depliable";
79
-	}
80
-
81
-	$b = (strpos($texte, "<h") === false ? 'h3' : 'div');
82
-
83
-	return "<$b "
84
-	. ($bouton_id ? "id='$bouton_id' " : "")
85
-	. "class='titrem$class'"
86
-	. (($deplie === -1)
87
-		? ""
88
-		: " onmouseover=\"jQuery(this).depliant('$cible');\""
89
-	)
90
-	. ">"
91
-	// une ancre pour rendre accessible au clavier le depliage du sous bloc
92
-	. "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
93
-	. "$texte</$b>"
94
-	. http_script(($deplie === 'incertain')
95
-		? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
96
-		: '');
71
+    $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
72
+
73
+    $class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie");
74
+    if (strlen($ids)) {
75
+        $cible = explode(',', $ids);
76
+        $cible = '#' . implode(",#", $cible);
77
+    } else {
78
+        $cible = "#$bouton_id + div.bloc_depliable";
79
+    }
80
+
81
+    $b = (strpos($texte, "<h") === false ? 'h3' : 'div');
82
+
83
+    return "<$b "
84
+    . ($bouton_id ? "id='$bouton_id' " : "")
85
+    . "class='titrem$class'"
86
+    . (($deplie === -1)
87
+        ? ""
88
+        : " onmouseover=\"jQuery(this).depliant('$cible');\""
89
+    )
90
+    . ">"
91
+    // une ancre pour rendre accessible au clavier le depliage du sous bloc
92
+    . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
93
+    . "$texte</$b>"
94
+    . http_script(($deplie === 'incertain')
95
+        ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
96
+        : '');
97 97
 }
98 98
 
99 99
 //
@@ -102,62 +102,62 @@  discard block
 block discarded – undo
102 102
 // https://code.spip.net/@verif_butineur
103 103
 function verif_butineur() {
104 104
 
105
-	preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match);
106
-	$GLOBALS['browser_name'] = $match[1];
107
-	$GLOBALS['browser_version'] = $match[2];
108
-	$GLOBALS['browser_description'] = $match[3];
109
-	$GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
110
-	$GLOBALS['browser_barre'] = '';
111
-
112
-	if (!preg_match(",opera,i", $GLOBALS['browser_description']) && preg_match(",opera,i", $GLOBALS['browser_name'])) {
113
-		$GLOBALS['browser_name'] = "Opera";
114
-		$GLOBALS['browser_version'] = $match[2];
115
-		$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
116
-	} else {
117
-		if (preg_match(",opera,i", $GLOBALS['browser_description'])) {
118
-			preg_match(",Opera ([^\ ]*),i", $GLOBALS['browser_description'], $match);
119
-			$GLOBALS['browser_name'] = "Opera";
120
-			$GLOBALS['browser_version'] = $match[1];
121
-			$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
122
-		} else {
123
-			if (preg_match(",msie,i", $GLOBALS['browser_description'])) {
124
-				preg_match(",MSIE ([^;]*),i", $GLOBALS['browser_description'], $match);
125
-				$GLOBALS['browser_name'] = "MSIE";
126
-				$GLOBALS['browser_version'] = $match[1];
127
-				$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5);
128
-			} else {
129
-				if (preg_match(",KHTML,i", $GLOBALS['browser_description']) &&
130
-					preg_match(",Safari/([^;]*),", $GLOBALS['browser_description'], $match)
131
-				) {
132
-					$GLOBALS['browser_name'] = "Safari";
133
-					$GLOBALS['browser_version'] = $match[1];
134
-					$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0);
135
-				} else {
136
-					if (preg_match(",mozilla,i", $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) {
137
-						// Numero de version pour Mozilla "authentique"
138
-						if (preg_match(",rv:([0-9]+\.[0-9]+),", $GLOBALS['browser_description'], $match)) {
139
-							$GLOBALS['browser_rev'] = doubleval($match[1]);
140
-						} // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
141
-						else {
142
-							if (strpos($GLOBALS['browser_description'], "Gecko") and !strpos($GLOBALS['browser_description'],
143
-									"KHTML")
144
-							) {
145
-								$GLOBALS['browser_rev'] = 1.4;
146
-							} // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
147
-							else {
148
-								$GLOBALS['browser_rev'] = 1.0;
149
-							}
150
-						}
151
-						$GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3;
152
-					}
153
-				}
154
-			}
155
-		}
156
-	}
157
-
158
-	if (!$GLOBALS['browser_name']) {
159
-		$GLOBALS['browser_name'] = "Mozilla";
160
-	}
105
+    preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match);
106
+    $GLOBALS['browser_name'] = $match[1];
107
+    $GLOBALS['browser_version'] = $match[2];
108
+    $GLOBALS['browser_description'] = $match[3];
109
+    $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
110
+    $GLOBALS['browser_barre'] = '';
111
+
112
+    if (!preg_match(",opera,i", $GLOBALS['browser_description']) && preg_match(",opera,i", $GLOBALS['browser_name'])) {
113
+        $GLOBALS['browser_name'] = "Opera";
114
+        $GLOBALS['browser_version'] = $match[2];
115
+        $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
116
+    } else {
117
+        if (preg_match(",opera,i", $GLOBALS['browser_description'])) {
118
+            preg_match(",Opera ([^\ ]*),i", $GLOBALS['browser_description'], $match);
119
+            $GLOBALS['browser_name'] = "Opera";
120
+            $GLOBALS['browser_version'] = $match[1];
121
+            $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
122
+        } else {
123
+            if (preg_match(",msie,i", $GLOBALS['browser_description'])) {
124
+                preg_match(",MSIE ([^;]*),i", $GLOBALS['browser_description'], $match);
125
+                $GLOBALS['browser_name'] = "MSIE";
126
+                $GLOBALS['browser_version'] = $match[1];
127
+                $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5);
128
+            } else {
129
+                if (preg_match(",KHTML,i", $GLOBALS['browser_description']) &&
130
+                    preg_match(",Safari/([^;]*),", $GLOBALS['browser_description'], $match)
131
+                ) {
132
+                    $GLOBALS['browser_name'] = "Safari";
133
+                    $GLOBALS['browser_version'] = $match[1];
134
+                    $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0);
135
+                } else {
136
+                    if (preg_match(",mozilla,i", $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) {
137
+                        // Numero de version pour Mozilla "authentique"
138
+                        if (preg_match(",rv:([0-9]+\.[0-9]+),", $GLOBALS['browser_description'], $match)) {
139
+                            $GLOBALS['browser_rev'] = doubleval($match[1]);
140
+                        } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
141
+                        else {
142
+                            if (strpos($GLOBALS['browser_description'], "Gecko") and !strpos($GLOBALS['browser_description'],
143
+                                    "KHTML")
144
+                            ) {
145
+                                $GLOBALS['browser_rev'] = 1.4;
146
+                            } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
147
+                            else {
148
+                                $GLOBALS['browser_rev'] = 1.0;
149
+                            }
150
+                        }
151
+                        $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3;
152
+                    }
153
+                }
154
+            }
155
+        }
156
+    }
157
+
158
+    if (!$GLOBALS['browser_name']) {
159
+        $GLOBALS['browser_name'] = "Mozilla";
160
+    }
161 161
 }
162 162
 
163 163
 verif_butineur();
Please login to merge, or discard this patch.
ecrire/inc/install.php 1 patch
Indentation   +354 added lines, -354 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
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = "<" . "?php\n"
47
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
-		. $texte
49
-		. "?" . ">";
46
+    $texte = "<" . "?php\n"
47
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
+        . $texte
49
+        . "?" . ">";
50 50
 
51
-	ecrire_fichier($nom, $texte);
51
+    ecrire_fichier($nom, $texte);
52 52
 }
53 53
 
54 54
 
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
  *
78 78
  **/
79 79
 function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') {
80
-	$adr = addcslashes($adr, "'\\");
81
-	$port = addcslashes($port, "'\\");
82
-	$login = addcslashes($login, "'\\");
83
-	$pass = addcslashes($pass, "'\\");
84
-	$base = addcslashes($base, "'\\");
85
-	$type = addcslashes($type, "'\\");
86
-	$pref = addcslashes($pref, "'\\");
87
-	$ldap = addcslashes($ldap, "'\\");
88
-	$charset = addcslashes($charset, "'\\");
89
-
90
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
-	. "spip_connect_db("
92
-	. "'$adr','$port','$login','$pass','$base'"
93
-	. ",'$type', '$pref','$ldap','$charset');\n";
80
+    $adr = addcslashes($adr, "'\\");
81
+    $port = addcslashes($port, "'\\");
82
+    $login = addcslashes($login, "'\\");
83
+    $pass = addcslashes($pass, "'\\");
84
+    $base = addcslashes($base, "'\\");
85
+    $type = addcslashes($type, "'\\");
86
+    $pref = addcslashes($pref, "'\\");
87
+    $ldap = addcslashes($ldap, "'\\");
88
+    $charset = addcslashes($charset, "'\\");
89
+
90
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
+    . "spip_connect_db("
92
+    . "'$adr','$port','$login','$pass','$base'"
93
+    . ",'$type', '$pref','$ldap','$charset');\n";
94 94
 }
95 95
 
96 96
 
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
  *     Tableau des informations sur la connexion
107 107
  **/
108 108
 function analyse_fichier_connection($file) {
109
-	$s = @join('', file($file));
110
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
-		array_shift($regs);
112
-
113
-		return $regs;
114
-	} else {
115
-		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
117
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
-		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
120
-			array_shift($regs);
121
-			array_shift($regs);
122
-
123
-			return $regs;
124
-		}
125
-	}
126
-	spip_log("$file n'est pas un fichier de connexion");
127
-
128
-	return array();
109
+    $s = @join('', file($file));
110
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
+        array_shift($regs);
112
+
113
+        return $regs;
114
+    } else {
115
+        $ar = '\s*\'([^\']*)\'';
116
+        $r = '\s*,' . $ar;
117
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
+        if (preg_match($r, $s, $regs)) {
119
+            $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
120
+            array_shift($regs);
121
+            array_shift($regs);
122
+
123
+            return $regs;
124
+        }
125
+    }
126
+    spip_log("$file n'est pas un fichier de connexion");
127
+
128
+    return array();
129 129
 }
130 130
 
131 131
 /**
@@ -142,21 +142,21 @@  discard block
 block discarded – undo
142 142
  *     Liste des noms de connecteurs
143 143
  **/
144 144
 function bases_referencees($exclu = '') {
145
-	$tables = array();
146
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
-		if ($f != $exclu and analyse_fichier_connection($f)) {
148
-			$tables[] = basename($f, '.php');
149
-		}
150
-	}
151
-
152
-	return $tables;
145
+    $tables = array();
146
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
+        if ($f != $exclu and analyse_fichier_connection($f)) {
148
+            $tables[] = basename($f, '.php');
149
+        }
150
+    }
151
+
152
+    return $tables;
153 153
 }
154 154
 
155 155
 
156 156
 function install_mode_appel($server_db, $tout = true) {
157
-	return ($server_db != 'mysql') ? ''
158
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
-			. test_sql_mode_mysql($server_db));
157
+    return ($server_db != 'mysql') ? ''
158
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
+            . test_sql_mode_mysql($server_db));
160 160
 }
161 161
 
162 162
 //
@@ -164,52 +164,52 @@  discard block
 block discarded – undo
164 164
 // (sert a l'etape 1 de l'installation)
165 165
 // https://code.spip.net/@tester_compatibilite_hebergement
166 166
 function tester_compatibilite_hebergement() {
167
-	$err = array();
168
-
169
-	$p = phpversion();
170
-	if (version_compare($p, _PHP_MIN, '<')) {
171
-		$err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN));
172
-	}
173
-
174
-	// Si on n'a pas la bonne version de PHP, c'est la fin
175
-	if ($err) {
176
-		die("<div class='error'>"
177
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
178
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179
-	}
180
-
181
-	// Il faut une base de donnees tout de meme ...
182
-	$serveurs = install_select_serveur();
183
-	if (!$serveurs) {
184
-		$err[] = _T('install_extension_php_obligatoire')
185
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
186
-			. "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
187
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
188
-	}
189
-
190
-	// et il faut preg
191
-	if (!function_exists('preg_match_all')) {
192
-		$err[] = _T('install_extension_php_obligatoire')
193
-			. " <a href='http://se.php.net/pcre'>PCRE</a>";
194
-	}
195
-
196
-	// et surtout pas ce mbstring.overload
197
-	if ($a = @ini_get('mbstring.func_overload')) {
198
-		$err[] = _T('install_extension_mbstring')
199
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
200
-	}
201
-
202
-	if ($err) {
203
-		echo "<div class='error'>"
204
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
-		foreach ($err as $e) {
206
-			echo "<li><strong>$e</strong></li>\n";
207
-		}
208
-
209
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
210
-		# de forcer malgre tout (pour tester, ou si bug de detection)
211
-		echo "</ul></div>\n";
212
-	}
167
+    $err = array();
168
+
169
+    $p = phpversion();
170
+    if (version_compare($p, _PHP_MIN, '<')) {
171
+        $err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN));
172
+    }
173
+
174
+    // Si on n'a pas la bonne version de PHP, c'est la fin
175
+    if ($err) {
176
+        die("<div class='error'>"
177
+            . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
178
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179
+    }
180
+
181
+    // Il faut une base de donnees tout de meme ...
182
+    $serveurs = install_select_serveur();
183
+    if (!$serveurs) {
184
+        $err[] = _T('install_extension_php_obligatoire')
185
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
186
+            . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
187
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
188
+    }
189
+
190
+    // et il faut preg
191
+    if (!function_exists('preg_match_all')) {
192
+        $err[] = _T('install_extension_php_obligatoire')
193
+            . " <a href='http://se.php.net/pcre'>PCRE</a>";
194
+    }
195
+
196
+    // et surtout pas ce mbstring.overload
197
+    if ($a = @ini_get('mbstring.func_overload')) {
198
+        $err[] = _T('install_extension_mbstring')
199
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
200
+    }
201
+
202
+    if ($err) {
203
+        echo "<div class='error'>"
204
+            . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
+        foreach ($err as $e) {
206
+            echo "<li><strong>$e</strong></li>\n";
207
+        }
208
+
209
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
210
+        # de forcer malgre tout (pour tester, ou si bug de detection)
211
+        echo "</ul></div>\n";
212
+    }
213 213
 }
214 214
 
215 215
 
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
  * @note superflu ??
220 220
  */
221 221
 function login_hebergeur() {
222
-	$base_hebergeur = 'localhost'; # par defaut
222
+    $base_hebergeur = 'localhost'; # par defaut
223 223
 
224
-	// Free
225
-	if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
226
-		$base_hebergeur = 'sql.free.fr';
227
-		$login_hebergeur = $regs[1];
228
-	} else {
229
-		$login_hebergeur = '';
230
-	}
224
+    // Free
225
+    if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
226
+        $base_hebergeur = 'sql.free.fr';
227
+        $login_hebergeur = $regs[1];
228
+    } else {
229
+        $login_hebergeur = '';
230
+    }
231 231
 
232
-	return array($base_hebergeur, $login_hebergeur);
232
+    return array($base_hebergeur, $login_hebergeur);
233 233
 }
234 234
 
235 235
 
236 236
 // https://code.spip.net/@info_etape
237 237
 function info_etape($titre, $complement = '') {
238
-	return "<h2>" . $titre . "</h2>\n" .
239
-	($complement ? "" . $complement . "\n" : '');
238
+    return "<h2>" . $titre . "</h2>\n" .
239
+    ($complement ? "" . $complement . "\n" : '');
240 240
 }
241 241
 
242 242
 /**
@@ -246,155 +246,155 @@  discard block
 block discarded – undo
246 246
  * @return string Code HTML du bouton
247 247
  **/
248 248
 function bouton_suivant($code = '') {
249
-	if ($code == '') {
250
-		$code = _T('bouton_suivant');
251
-	}
252
-	static $suivant = 0;
253
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
254
-	$suivant += 1;
255
-
256
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
-	$code .
258
-	" >>\" /></p>\n";
249
+    if ($code == '') {
250
+        $code = _T('bouton_suivant');
251
+    }
252
+    static $suivant = 0;
253
+    $id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
254
+    $suivant += 1;
255
+
256
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
+    $code .
258
+    " >>\" /></p>\n";
259 259
 }
260 260
 
261 261
 // https://code.spip.net/@info_progression_etape
262 262
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
263
-	//$en_cours = _request('etape')?_request('etape'):"";
264
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
265
-	$debut = 1;
266
-	$etat = "ok";
267
-	$last = count($liste);
263
+    //$en_cours = _request('etape')?_request('etape'):"";
264
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
265
+    $debut = 1;
266
+    $etat = "ok";
267
+    $last = count($liste);
268 268
 //	$texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo'));
269 269
 
270
-	$intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee'));
271
-	$intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base'));
272
-	$intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles'));
273
-	$intitule_etat["etape_"][4] = typo(_T('info_derniere_etape'));
270
+    $intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee'));
271
+    $intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base'));
272
+    $intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles'));
273
+    $intitule_etat["etape_"][4] = typo(_T('info_derniere_etape'));
274 274
 
275
-	$intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap'));
276
-	$intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap'));
277
-	$intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1'));
278
-	$intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap'));
279
-	$intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok'));
275
+    $intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap'));
276
+    $intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap'));
277
+    $intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1'));
278
+    $intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap'));
279
+    $intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok'));
280 280
 
281 281
 //	$aff_etapes = "<span id='etapes'>";
282 282
 
283
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
284
-
285
-	foreach ($liste as $etape => $fichier) {
286
-		if ($debut < $last) {
287
-			if ($debut == $en_cours && $erreur) {
288
-				$class = "on erreur";
289
-			} else {
290
-				if ($debut == $en_cours) {
291
-					$class = "on";
292
-				} else {
293
-					if ($debut > $en_cours) {
294
-						$class = "prochains";
295
-					} else {
296
-						$class = "valides";
297
-					}
298
-				}
299
-			}
300
-
301
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
302
-			$aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
-			$aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304
-			$aff_etapes .= $intitule_etat["$phase"][$debut];
305
-			$aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306
-			$aff_etapes .= "</div></li>";
307
-		}
308
-		$debut++;
309
-	}
310
-	$aff_etapes .= "</ul>";
311
-	$aff_etapes .= "<br class='nettoyeur' />\n";
312
-
313
-	return $aff_etapes;
283
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
284
+
285
+    foreach ($liste as $etape => $fichier) {
286
+        if ($debut < $last) {
287
+            if ($debut == $en_cours && $erreur) {
288
+                $class = "on erreur";
289
+            } else {
290
+                if ($debut == $en_cours) {
291
+                    $class = "on";
292
+                } else {
293
+                    if ($debut > $en_cours) {
294
+                        $class = "prochains";
295
+                    } else {
296
+                        $class = "valides";
297
+                    }
298
+                }
299
+            }
300
+
301
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
302
+            $aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
+            $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304
+            $aff_etapes .= $intitule_etat["$phase"][$debut];
305
+            $aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306
+            $aff_etapes .= "</div></li>";
307
+        }
308
+        $debut++;
309
+    }
310
+    $aff_etapes .= "</ul>";
311
+    $aff_etapes .= "<br class='nettoyeur' />\n";
312
+
313
+    return $aff_etapes;
314 314
 }
315 315
 
316 316
 
317 317
 // https://code.spip.net/@fieldset
318 318
 function fieldset($legend, $champs = array(), $apres = '', $avant = '') {
319
-	return "<fieldset>\n" .
320
-	$avant .
321
-	($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
-	fieldset_champs($champs) .
323
-	$apres .
324
-	"</fieldset>\n";
319
+    return "<fieldset>\n" .
320
+    $avant .
321
+    ($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
+    fieldset_champs($champs) .
323
+    $apres .
324
+    "</fieldset>\n";
325 325
 }
326 326
 
327 327
 function fieldset_champs($champs = array()) {
328
-	$fieldset = '';
329
-	foreach ($champs as $nom => $contenu) {
330
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332
-		if (isset($contenu['alternatives'])) {
333
-			$fieldset .= $contenu['label'] . "\n";
334
-			foreach ($contenu['alternatives'] as $valeur => $label) {
335
-				$fieldset .= "<input type='radio' name='" . $nom .
336
-					"' id='$nom-$valeur' value='$valeur'"
337
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338
-					. "/>\n";
339
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
340
-			}
341
-			$fieldset .= "<br />\n";
342
-		} else {
343
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
-			$fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
345
-				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346
-				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347
-				. " />\n";
348
-		}
349
-	}
350
-
351
-	return $fieldset;
328
+    $fieldset = '';
329
+    foreach ($champs as $nom => $contenu) {
330
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332
+        if (isset($contenu['alternatives'])) {
333
+            $fieldset .= $contenu['label'] . "\n";
334
+            foreach ($contenu['alternatives'] as $valeur => $label) {
335
+                $fieldset .= "<input type='radio' name='" . $nom .
336
+                    "' id='$nom-$valeur' value='$valeur'"
337
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338
+                    . "/>\n";
339
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
340
+            }
341
+            $fieldset .= "<br />\n";
342
+        } else {
343
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
+            $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
345
+                . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346
+                . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347
+                . " />\n";
348
+        }
349
+    }
350
+
351
+    return $fieldset;
352 352
 }
353 353
 
354 354
 function install_select_serveur() {
355
-	$options = array();
356
-	$dir = _DIR_RESTREINT . 'req/';
357
-	$d = opendir($dir);
358
-	if (!$d) {
359
-		return array();
360
-	}
361
-	while (($f = readdir($d)) !== false) {
362
-		if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
-			and is_readable($f = $dir . $f)
364
-		) {
365
-			require_once($f);
366
-			$s = $s[1];
367
-			$v = 'spip_versions_' . $s;
368
-			if (function_exists($v) and $v()) {
369
-				$titre = _T("install_select_type_$s");
370
-				// proposer mysql par defaut si dispo
371
-				$checked = ($s == 'mysql' ? " checked='checked'" : "");
372
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
-					. "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
374
-			} else {
375
-				spip_log("$s: portage indisponible");
376
-			}
377
-		}
378
-	}
379
-	sort($options);
380
-
381
-	return $options;
355
+    $options = array();
356
+    $dir = _DIR_RESTREINT . 'req/';
357
+    $d = opendir($dir);
358
+    if (!$d) {
359
+        return array();
360
+    }
361
+    while (($f = readdir($d)) !== false) {
362
+        if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
+            and is_readable($f = $dir . $f)
364
+        ) {
365
+            require_once($f);
366
+            $s = $s[1];
367
+            $v = 'spip_versions_' . $s;
368
+            if (function_exists($v) and $v()) {
369
+                $titre = _T("install_select_type_$s");
370
+                // proposer mysql par defaut si dispo
371
+                $checked = ($s == 'mysql' ? " checked='checked'" : "");
372
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
+                    . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
374
+            } else {
375
+                spip_log("$s: portage indisponible");
376
+            }
377
+        }
378
+    }
379
+    sort($options);
380
+
381
+    return $options;
382 382
 }
383 383
 
384 384
 // https://code.spip.net/@install_connexion_form
385 385
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
386
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
387
-
388
-	return generer_form_ecrire('install', (
389
-		"\n<input type='hidden' name='etape' value='$etape' />"
390
-		. $hidden
391
-		. (_request('echec') ?
392
-			("<p><b>" . _T('avis_connexion_echec_1') .
393
-				"</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
394
-			: "")
395
-
396
-		. ($jquery ? http_script('', 'jquery.js') : '')
397
-		. http_script('
386
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
387
+
388
+    return generer_form_ecrire('install', (
389
+        "\n<input type='hidden' name='etape' value='$etape' />"
390
+        . $hidden
391
+        . (_request('echec') ?
392
+            ("<p><b>" . _T('avis_connexion_echec_1') .
393
+                "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
394
+            : "")
395
+
396
+        . ($jquery ? http_script('', 'jquery.js') : '')
397
+        . http_script('
398 398
 		jQuery(function($) {
399 399
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
400 400
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -427,67 +427,67 @@  discard block
 block discarded – undo
427 427
 			});
428 428
 		});')
429 429
 
430
-		. ($server_db
431
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
432
-			. (($predef[0])
433
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
434
-				: '')
435
-			: ('<fieldset><legend>'
436
-				. _T('install_select_type_db')
437
-				. "</legend>"
438
-				. '<p class="explication">'
439
-				. _T('install_types_db_connus')
440
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
441
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
442
-				. '</p>'
443
-				. "\n<div class='p'>\n<ul>\n"
444
-				. join("\n", install_select_serveur())
445
-				. "\n</ul>\n</div></fieldset>")
446
-		)
447
-		. '<div id="install_adresse_base_hebergeur">'
448
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
449
-		. ($predef[1]
450
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
451
-			: fieldset(_T('entree_base_donnee_1'),
452
-				array(
453
-					'adresse_db' => array(
454
-						'label' => $db[1],
455
-						'valeur' => $db[0]
456
-					),
457
-				)
458
-			)
459
-		)
460
-		. '</div>'
461
-
462
-		. '<div id="install_login_base_hebergeur">'
463
-		. ($predef[2]
464
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
465
-			: fieldset(_T('entree_login_connexion_1'),
466
-				array(
467
-					'login_db' => array(
468
-						'label' => $login[1],
469
-						'valeur' => $login[0]
470
-					),
471
-				)
472
-			)
473
-		)
474
-		. '</div>'
475
-
476
-		. '<div id="install_pass_base_hebergeur">'
477
-		. ($predef[3]
478
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
479
-			: fieldset(_T('entree_mot_passe_1'),
480
-				array(
481
-					'pass_db' => array(
482
-						'label' => $pass[1],
483
-						'valeur' => $pass[0]
484
-					),
485
-				)
486
-			)
487
-		)
488
-		. '</div>'
489
-
490
-		. bouton_suivant()));
430
+        . ($server_db
431
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
432
+            . (($predef[0])
433
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
434
+                : '')
435
+            : ('<fieldset><legend>'
436
+                . _T('install_select_type_db')
437
+                . "</legend>"
438
+                . '<p class="explication">'
439
+                . _T('install_types_db_connus')
440
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
441
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
442
+                . '</p>'
443
+                . "\n<div class='p'>\n<ul>\n"
444
+                . join("\n", install_select_serveur())
445
+                . "\n</ul>\n</div></fieldset>")
446
+        )
447
+        . '<div id="install_adresse_base_hebergeur">'
448
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
449
+        . ($predef[1]
450
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
451
+            : fieldset(_T('entree_base_donnee_1'),
452
+                array(
453
+                    'adresse_db' => array(
454
+                        'label' => $db[1],
455
+                        'valeur' => $db[0]
456
+                    ),
457
+                )
458
+            )
459
+        )
460
+        . '</div>'
461
+
462
+        . '<div id="install_login_base_hebergeur">'
463
+        . ($predef[2]
464
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
465
+            : fieldset(_T('entree_login_connexion_1'),
466
+                array(
467
+                    'login_db' => array(
468
+                        'label' => $login[1],
469
+                        'valeur' => $login[0]
470
+                    ),
471
+                )
472
+            )
473
+        )
474
+        . '</div>'
475
+
476
+        . '<div id="install_pass_base_hebergeur">'
477
+        . ($predef[3]
478
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
479
+            : fieldset(_T('entree_mot_passe_1'),
480
+                array(
481
+                    'pass_db' => array(
482
+                        'label' => $pass[1],
483
+                        'valeur' => $pass[0]
484
+                    ),
485
+                )
486
+            )
487
+        )
488
+        . '</div>'
489
+
490
+        . bouton_suivant()));
491 491
 
492 492
 }
493 493
 
@@ -496,75 +496,75 @@  discard block
 block discarded – undo
496 496
 
497 497
 // https://code.spip.net/@predef_ou_cache
498 498
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
499
-	return ((defined('_INSTALL_HOST_DB'))
500
-		? ''
501
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
502
-	)
503
-	. ((defined('_INSTALL_USER_DB'))
504
-		? ''
505
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
506
-	)
507
-	. ((defined('_INSTALL_PASS_DB'))
508
-		? ''
509
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
510
-	)
511
-
512
-	. ((defined('_INSTALL_SERVER_DB'))
513
-		? ''
514
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
515
-	);
499
+    return ((defined('_INSTALL_HOST_DB'))
500
+        ? ''
501
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
502
+    )
503
+    . ((defined('_INSTALL_USER_DB'))
504
+        ? ''
505
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
506
+    )
507
+    . ((defined('_INSTALL_PASS_DB'))
508
+        ? ''
509
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
510
+    )
511
+
512
+    . ((defined('_INSTALL_SERVER_DB'))
513
+        ? ''
514
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
515
+    );
516 516
 }
517 517
 
518 518
 // presentation des bases existantes
519 519
 
520 520
 // https://code.spip.net/@install_etape_liste_bases
521 521
 function install_etape_liste_bases($server_db, $login_db, $disabled = array()) {
522
-	$bases = $checked = array();
523
-	$noms = sql_listdbs($server_db);
524
-	if (!$noms) {
525
-		return '';
526
-	}
527
-
528
-	foreach ($noms as $nom) {
529
-		$id = spip_htmlspecialchars($nom);
530
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
531
-		$base = " name=\"choix_db\" value=\""
532
-			. $nom
533
-			. '"'
534
-			. $dis
535
-			. " type='radio' id='$id'";
536
-		$label = "<label for='$id'>"
537
-			. ($dis ? "<i>$nom</i>" : $nom)
538
-			. "</label>";
539
-
540
-		if (!$checked and !$dis and
541
-			(($nom == $login_db) or
542
-				($GLOBALS['table_prefix'] == $nom))
543
-		) {
544
-			$checked = "<input$base checked='checked' />\n$label";
545
-		} else {
546
-			$bases[] = "<input$base />\n$label";
547
-		}
548
-	}
549
-
550
-	if (!$bases && !$checked) {
551
-		return false;
552
-	}
553
-
554
-	if ($checked) {
555
-		array_unshift($bases, $checked);
556
-		$checked = true;
557
-	}
558
-
559
-	return array($checked, $bases);
522
+    $bases = $checked = array();
523
+    $noms = sql_listdbs($server_db);
524
+    if (!$noms) {
525
+        return '';
526
+    }
527
+
528
+    foreach ($noms as $nom) {
529
+        $id = spip_htmlspecialchars($nom);
530
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
531
+        $base = " name=\"choix_db\" value=\""
532
+            . $nom
533
+            . '"'
534
+            . $dis
535
+            . " type='radio' id='$id'";
536
+        $label = "<label for='$id'>"
537
+            . ($dis ? "<i>$nom</i>" : $nom)
538
+            . "</label>";
539
+
540
+        if (!$checked and !$dis and
541
+            (($nom == $login_db) or
542
+                ($GLOBALS['table_prefix'] == $nom))
543
+        ) {
544
+            $checked = "<input$base checked='checked' />\n$label";
545
+        } else {
546
+            $bases[] = "<input$base />\n$label";
547
+        }
548
+    }
549
+
550
+    if (!$bases && !$checked) {
551
+        return false;
552
+    }
553
+
554
+    if ($checked) {
555
+        array_unshift($bases, $checked);
556
+        $checked = true;
557
+    }
558
+
559
+    return array($checked, $bases);
560 560
 }
561 561
 
562 562
 function install_propager($hidden) {
563
-	$res = '';
564
-	foreach ($hidden as $k) {
565
-		$v = spip_htmlentities(_request($k));
566
-		$res .= "<input type='hidden' name='$k' value='$v' />";
567
-	}
563
+    $res = '';
564
+    foreach ($hidden as $k) {
565
+        $v = spip_htmlentities(_request($k));
566
+        $res .= "<input type='hidden' name='$k' value='$v' />";
567
+    }
568 568
 
569
-	return $res;
569
+    return $res;
570 570
 }
Please login to merge, or discard this patch.
ecrire/inc/genie.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -75,24 +75,24 @@  discard block
 block discarded – undo
75 75
  * @return
76 76
  **/
77 77
 function inc_genie_dist($taches = array()) {
78
-	include_spip('inc/queue');
79
-
80
-	if (_request('exec') == 'job_queue') {
81
-		return false;
82
-	}
83
-
84
-	$force_jobs = array();
85
-	// l'ancienne facon de lancer une tache cron immediatement
86
-	// etait de la passer en parametre a ing_genie_dist
87
-	// on reroute en ajoutant simplement le job a la queue, ASAP
88
-	foreach ($taches as $function => $period) {
89
-		$force_jobs[] = queue_add_job($function, _T('tache_cron_asap', array('function' => $function)),
90
-			array(time() - abs($period)), "genie/");
91
-	}
92
-
93
-	// et on passe la main a la gestion de la queue !
94
-	// en forcant eventuellement les jobs ajoute a l'instant
95
-	return queue_schedule(count($force_jobs) ? $force_jobs : null);
78
+    include_spip('inc/queue');
79
+
80
+    if (_request('exec') == 'job_queue') {
81
+        return false;
82
+    }
83
+
84
+    $force_jobs = array();
85
+    // l'ancienne facon de lancer une tache cron immediatement
86
+    // etait de la passer en parametre a ing_genie_dist
87
+    // on reroute en ajoutant simplement le job a la queue, ASAP
88
+    foreach ($taches as $function => $period) {
89
+        $force_jobs[] = queue_add_job($function, _T('tache_cron_asap', array('function' => $function)),
90
+            array(time() - abs($period)), "genie/");
91
+    }
92
+
93
+    // et on passe la main a la gestion de la queue !
94
+    // en forcant eventuellement les jobs ajoute a l'instant
95
+    return queue_schedule(count($force_jobs) ? $force_jobs : null);
96 96
 }
97 97
 
98 98
 //
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
 // https://code.spip.net/@taches_generales
107 107
 function taches_generales($taches_generales = array()) {
108 108
 
109
-	// verifier que toutes les taches cron sont planifiees
110
-	// c'est une tache cron !
111
-	$taches_generales['queue_watch'] = 3600 * 24;
109
+    // verifier que toutes les taches cron sont planifiees
110
+    // c'est une tache cron !
111
+    $taches_generales['queue_watch'] = 3600 * 24;
112 112
 
113
-	// MAJ des rubriques publiques (cas de la publication post-datee)
114
-	// est fait au coup par coup a present
115
-	//	$taches_generales['rubriques'] = 3600;
113
+    // MAJ des rubriques publiques (cas de la publication post-datee)
114
+    // est fait au coup par coup a present
115
+    //	$taches_generales['rubriques'] = 3600;
116 116
 
117
-	// Optimisation de la base
118
-	$taches_generales['optimiser'] = 3600 * 48;
117
+    // Optimisation de la base
118
+    $taches_generales['optimiser'] = 3600 * 48;
119 119
 
120
-	// nouveautes
121
-	if (isset($GLOBALS['meta']['adresse_neuf']) and $GLOBALS['meta']['adresse_neuf']
122
-		and $GLOBALS['meta']['jours_neuf']
123
-		and ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')
124
-	) {
125
-		$taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf'];
126
-	}
120
+    // nouveautes
121
+    if (isset($GLOBALS['meta']['adresse_neuf']) and $GLOBALS['meta']['adresse_neuf']
122
+        and $GLOBALS['meta']['jours_neuf']
123
+        and ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')
124
+    ) {
125
+        $taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf'];
126
+    }
127 127
 
128
-	// maintenance (ajax, verifications diverses)
129
-	$taches_generales['maintenance'] = 3600 * 2;
128
+    // maintenance (ajax, verifications diverses)
129
+    $taches_generales['maintenance'] = 3600 * 2;
130 130
 
131
-	// verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
132
-	$taches_generales['mise_a_jour'] = 3 * 24 * 3600;
131
+    // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
132
+    $taches_generales['mise_a_jour'] = 3 * 24 * 3600;
133 133
 
134
-	return pipeline('taches_generales_cron', $taches_generales);
134
+    return pipeline('taches_generales_cron', $taches_generales);
135 135
 }
136 136
 
137 137
 /**
@@ -147,22 +147,22 @@  discard block
 block discarded – undo
147 147
  * @return int
148 148
  */
149 149
 function genie_queue_watch_dist() {
150
-	static $deja_la = false;
151
-	if ($deja_la) {
152
-		return;
153
-	} // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple)
154
-	$deja_la = true;
155
-	$taches = taches_generales();
156
-	$programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches)));
157
-	$programmees = array_column($programmees, 'fonction');
158
-	foreach ($taches as $tache => $periode) {
159
-		if (!in_array($tache, $programmees)) {
160
-			queue_genie_replan_job($tache, $periode, time() - round(rand(1, $periode)), 0);
161
-		}
162
-	}
163
-	$deja_la = false;
164
-
165
-	return 1;
150
+    static $deja_la = false;
151
+    if ($deja_la) {
152
+        return;
153
+    } // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple)
154
+    $deja_la = true;
155
+    $taches = taches_generales();
156
+    $programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches)));
157
+    $programmees = array_column($programmees, 'fonction');
158
+    foreach ($taches as $tache => $periode) {
159
+        if (!in_array($tache, $programmees)) {
160
+            queue_genie_replan_job($tache, $periode, time() - round(rand(1, $periode)), 0);
161
+        }
162
+    }
163
+    $deja_la = false;
164
+
165
+    return 1;
166 166
 }
167 167
 
168 168
 /**
@@ -183,25 +183,25 @@  discard block
 block discarded – undo
183 183
  * @return void
184 184
  */
185 185
 function queue_genie_replan_job($function, $period, $last = 0, $time = null, $priority = 0) {
186
-	static $done = array();
187
-	if (isset($done[$function])) {
188
-		return;
189
-	}
190
-	$done[$function] = true;
191
-	if (is_null($time)) {
192
-		$time = time();
193
-		if ($last) {
194
-			$time = max($last + $period, $time);
195
-		}
196
-	}
197
-	if (!$last) {
198
-		$last = $time - $period;
199
-	}
200
-	spip_log("replan_job $function $period $last $time $priority", 'queue');
201
-	include_spip('inc/queue');
202
-	// on replanifie un job cron
203
-	// uniquement si il n'y en a pas deja un avec le meme nom
204
-	// independament de l'argument
205
-	queue_add_job($function, _T('tache_cron_secondes', array('function' => $function, 'nb' => $period)), array($last),
206
-		"genie/", 'function_only', $time, $priority);
186
+    static $done = array();
187
+    if (isset($done[$function])) {
188
+        return;
189
+    }
190
+    $done[$function] = true;
191
+    if (is_null($time)) {
192
+        $time = time();
193
+        if ($last) {
194
+            $time = max($last + $period, $time);
195
+        }
196
+    }
197
+    if (!$last) {
198
+        $last = $time - $period;
199
+    }
200
+    spip_log("replan_job $function $period $last $time $priority", 'queue');
201
+    include_spip('inc/queue');
202
+    // on replanifie un job cron
203
+    // uniquement si il n'y en a pas deja un avec le meme nom
204
+    // independament de l'argument
205
+    queue_add_job($function, _T('tache_cron_secondes', array('function' => $function, 'nb' => $period)), array($last),
206
+        "genie/", 'function_only', $time, $priority);
207 207
 }
Please login to merge, or discard this patch.
ecrire/inc/presentation.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Presentation
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/presentation_mini');
@@ -31,44 +31,44 @@  discard block
 block discarded – undo
31 31
 
32 32
 // https://code.spip.net/@debut_cadre
33 33
 function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id = "", $class = "", $padding = true) {
34
-	$style_mapping = array(
35
-		'r' => 'simple',
36
-		'e' => 'raccourcis',
37
-		'couleur' => 'basic highlight',
38
-		'couleur-foncee' => 'basic highlight',
39
-		'trait-couleur' => 'important',
40
-		'alerte' => 'notice',
41
-		'info' => 'info',
42
-		'sous_rub' => 'simple sous-rub'
43
-	);
44
-	$style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45
-	$c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
-	$class = $c . ($class ? " $class" : "");
47
-	if (!$padding) {
48
-		$class .= ($class ? " " : "") . "no-padding";
49
-	}
50
-
51
-	//($id?"id='$id' ":"")
52
-	if (strlen($icone) > 1) {
53
-		if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
54
-			list($fond, $fonction) = $icone_renommer($icone, $fonction);
55
-		}
56
-		$size = 24;
57
-		if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
58
-			$size = $match[1];
59
-		}
60
-		if ($fonction) {
61
-			// 2 images pour composer l'icone : le fond (article) en background,
62
-			// la fonction (new) en image
63
-			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
64
-				http_style_background($fond, "no-repeat center center", $size));
65
-		} else {
66
-			$icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67
-		}
68
-		$titre = $icone . $titre;
69
-	}
70
-
71
-	return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
34
+    $style_mapping = array(
35
+        'r' => 'simple',
36
+        'e' => 'raccourcis',
37
+        'couleur' => 'basic highlight',
38
+        'couleur-foncee' => 'basic highlight',
39
+        'trait-couleur' => 'important',
40
+        'alerte' => 'notice',
41
+        'info' => 'info',
42
+        'sous_rub' => 'simple sous-rub'
43
+    );
44
+    $style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45
+    $c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
+    $class = $c . ($class ? " $class" : "");
47
+    if (!$padding) {
48
+        $class .= ($class ? " " : "") . "no-padding";
49
+    }
50
+
51
+    //($id?"id='$id' ":"")
52
+    if (strlen($icone) > 1) {
53
+        if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
54
+            list($fond, $fonction) = $icone_renommer($icone, $fonction);
55
+        }
56
+        $size = 24;
57
+        if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
58
+            $size = $match[1];
59
+        }
60
+        if ($fonction) {
61
+            // 2 images pour composer l'icone : le fond (article) en background,
62
+            // la fonction (new) en image
63
+            $icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
64
+                http_style_background($fond, "no-repeat center center", $size));
65
+        } else {
66
+            $icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67
+        }
68
+        $titre = $icone . $titre;
69
+    }
70
+
71
+    return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
72 72
 }
73 73
 
74 74
 // https://code.spip.net/@fin_cadre
@@ -76,66 +76,66 @@  discard block
 block discarded – undo
76 76
 
77 77
 
78 78
 function debut_cadre_relief(
79
-	$icone = '',
80
-	$dummy = '',
81
-	$fonction = '',
82
-	$titre = '',
83
-	$id = "",
84
-	$class = ""
79
+    $icone = '',
80
+    $dummy = '',
81
+    $fonction = '',
82
+    $titre = '',
83
+    $id = "",
84
+    $class = ""
85 85
 ) {
86
-	return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
86
+    return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
87 87
 }
88 88
 
89 89
 function fin_cadre_relief() { return fin_cadre('r'); }
90 90
 
91 91
 function debut_cadre_enfonce(
92
-	$icone = '',
93
-	$dummy = '',
94
-	$fonction = '',
95
-	$titre = '',
96
-	$id = "",
97
-	$class = ""
92
+    $icone = '',
93
+    $dummy = '',
94
+    $fonction = '',
95
+    $titre = '',
96
+    $id = "",
97
+    $class = ""
98 98
 ) {
99
-	return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
99
+    return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
100 100
 }
101 101
 
102 102
 function fin_cadre_enfonce() { return fin_cadre('e'); }
103 103
 
104 104
 function debut_cadre_sous_rub(
105
-	$icone = '',
106
-	$dummy = '',
107
-	$fonction = '',
108
-	$titre = '',
109
-	$id = "",
110
-	$class = ""
105
+    $icone = '',
106
+    $dummy = '',
107
+    $fonction = '',
108
+    $titre = '',
109
+    $id = "",
110
+    $class = ""
111 111
 ) {
112
-	return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
112
+    return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
113 113
 }
114 114
 
115 115
 function fin_cadre_sous_rub() { return fin_cadre('sous_rub'); }
116 116
 
117 117
 function debut_cadre_couleur(
118
-	$icone = '',
119
-	$dummy = '',
120
-	$fonction = '',
121
-	$titre = '',
122
-	$id = "",
123
-	$class = ""
118
+    $icone = '',
119
+    $dummy = '',
120
+    $fonction = '',
121
+    $titre = '',
122
+    $id = "",
123
+    $class = ""
124 124
 ) {
125
-	return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
125
+    return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
126 126
 }
127 127
 
128 128
 function fin_cadre_couleur() { return fin_cadre('couleur'); }
129 129
 
130 130
 function debut_cadre_trait_couleur(
131
-	$icone = '',
132
-	$dummy = '',
133
-	$fonction = '',
134
-	$titre = '',
135
-	$id = "",
136
-	$class = ""
131
+    $icone = '',
132
+    $dummy = '',
133
+    $fonction = '',
134
+    $titre = '',
135
+    $id = "",
136
+    $class = ""
137 137
 ) {
138
-	return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
138
+    return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
139 139
 }
140 140
 
141 141
 function fin_cadre_trait_couleur() { return fin_cadre('trait-couleur'); }
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
  * @return string Code PHP.
157 157
  **/
158 158
 function gros_titre(
159
-	$titre,
160
-	$ze_logo = ''
159
+    $titre,
160
+    $ze_logo = ''
161 161
 ) {
162
-	return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
162
+    return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
163 163
 }
164 164
 
165 165
 // La boite des raccourcis
166 166
 // Se place a droite si l'ecran est en mode panoramique.
167 167
 // https://code.spip.net/@bloc_des_raccourcis
168 168
 function bloc_des_raccourcis($bloc) {
169
-	return creer_colonne_droite()
170
-	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
169
+    return creer_colonne_droite()
170
+    . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
171 171
 }
172 172
 
173 173
 //
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 
185 185
 // https://code.spip.net/@onglet
186 186
 function onglet($texte, $lien, $onglet_ref, $onglet, $icone = "") {
187
-	return "<li>"
188
-	. ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
189
-	. lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
190
-	. "</li>";
187
+    return "<li>"
188
+    . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
189
+    . lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
190
+    . "</li>";
191 191
 }
192 192
 
193 193
 /**
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
  *     Code HTML du lien
220 220
  **/
221 221
 function icone_verticale($texte, $lien, $fond, $fonction = "", $align = "", $javascript = "") {
222
-	// cas d'ajax_action_auteur: faut defaire le boulot
223
-	// (il faudrait fusionner avec le cas $javascript)
224
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
225
-		list($x, $lien, $atts, $texte) = $r;
226
-		$javascript .= $atts;
227
-	}
228
-
229
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
222
+    // cas d'ajax_action_auteur: faut defaire le boulot
223
+    // (il faudrait fusionner avec le cas $javascript)
224
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
225
+        list($x, $lien, $atts, $texte) = $r;
226
+        $javascript .= $atts;
227
+    }
228
+
229
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
230 230
 }
231 231
 
232 232
 /**
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
  *     Code HTML du lien
252 252
  **/
253 253
 function icone_horizontale($texte, $lien, $fond, $fonction = "", $dummy = "", $javascript = "") {
254
-	$retour = '';
255
-	// cas d'ajax_action_auteur: faut defaire le boulot
256
-	// (il faudrait fusionner avec le cas $javascript)
257
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
258
-		list($x, $lien, $atts, $texte) = $r;
259
-		$javascript .= $atts;
260
-	}
254
+    $retour = '';
255
+    // cas d'ajax_action_auteur: faut defaire le boulot
256
+    // (il faudrait fusionner avec le cas $javascript)
257
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
258
+        list($x, $lien, $atts, $texte) = $r;
259
+        $javascript .= $atts;
260
+    }
261 261
 
262
-	$retour = icone_base($lien, $texte, $fond, $fonction, "horizontale", $javascript);
262
+    $retour = icone_base($lien, $texte, $fond, $fonction, "horizontale", $javascript);
263 263
 
264
-	return $retour;
264
+    return $retour;
265 265
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_liste.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 
@@ -28,88 +28,88 @@  discard block
 block discarded – undo
28 28
  * @return string
29 29
  */
30 30
 function plugins_afficher_liste_dist(
31
-	$url_page,
32
-	$liste_plugins,
33
-	$liste_plugins_checked,
34
-	$liste_plugins_actifs,
35
-	$dir_plugins = _DIR_PLUGINS,
36
-	$afficher_un = 'afficher_plugin'
31
+    $url_page,
32
+    $liste_plugins,
33
+    $liste_plugins_checked,
34
+    $liste_plugins_actifs,
35
+    $dir_plugins = _DIR_PLUGINS,
36
+    $afficher_un = 'afficher_plugin'
37 37
 ) {
38
-	$get_infos = charger_fonction('get_infos', 'plugins');
39
-	$ligne_plug = charger_fonction($afficher_un, 'plugins');
38
+    $get_infos = charger_fonction('get_infos', 'plugins');
39
+    $ligne_plug = charger_fonction($afficher_un, 'plugins');
40 40
 
41
-	$all_infos = $get_infos($liste_plugins, false, $dir_plugins);
41
+    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
42 42
 
43
-	$all_infos = pipeline('filtrer_liste_plugins',
44
-		array(
45
-			'args' => array(
46
-				'liste_plugins' => $liste_plugins,
47
-				'liste_plugins_checked' => $liste_plugins_checked,
48
-				'liste_plugins_actifs' => $liste_plugins_actifs,
49
-				'dir_plugins' => $dir_plugins
50
-			),
51
-			'data' => $all_infos
52
-		)
53
-	);
43
+    $all_infos = pipeline('filtrer_liste_plugins',
44
+        array(
45
+            'args' => array(
46
+                'liste_plugins' => $liste_plugins,
47
+                'liste_plugins_checked' => $liste_plugins_checked,
48
+                'liste_plugins_actifs' => $liste_plugins_actifs,
49
+                'dir_plugins' => $dir_plugins
50
+            ),
51
+            'data' => $all_infos
52
+        )
53
+    );
54 54
 
55
-	$liste_plugins = array_flip($liste_plugins);
56
-	foreach ($liste_plugins as $chemin => $v) {
57
-		// des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
-		if (isset($all_infos[$chemin])) {
59
-			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
-		} else {
61
-			unset($liste_plugins[$chemin]);
62
-		}
63
-	}
64
-	asort($liste_plugins);
65
-	$exposed = urldecode(_request('plugin'));
55
+    $liste_plugins = array_flip($liste_plugins);
56
+    foreach ($liste_plugins as $chemin => $v) {
57
+        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
+        if (isset($all_infos[$chemin])) {
59
+            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
+        } else {
61
+            unset($liste_plugins[$chemin]);
62
+        }
63
+    }
64
+    asort($liste_plugins);
65
+    $exposed = urldecode(_request('plugin'));
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
68
-	$fast_liste_plugins_actifs = array();
69
-	$fast_liste_plugins_checked = array();
70
-	if (is_array($liste_plugins_actifs)) {
71
-		$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
-	}
73
-	if (is_array($liste_plugins_checked)) {
74
-		$fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
-	}
67
+    $block_par_lettre = false;//count($liste_plugins)>10;
68
+    $fast_liste_plugins_actifs = array();
69
+    $fast_liste_plugins_checked = array();
70
+    if (is_array($liste_plugins_actifs)) {
71
+        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
+    }
73
+    if (is_array($liste_plugins_checked)) {
74
+        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
+    }
76 76
 
77
-	$res = '';
78
-	$block = '';
79
-	$initiale = '';
80
-	$block_actif = false;
81
-	foreach ($liste_plugins as $plug => $nom) {
82
-		if (($i = substr($nom, 0, 1)) !== $initiale) {
83
-			$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
-			$initiale = $i;
85
-			$block = '';
86
-			$block_actif = false;
87
-		}
88
-		// le rep suivant
89
-		$actif = isset($fast_liste_plugins_actifs[$plug]);
90
-		$checked = isset($fast_liste_plugins_checked[$plug]);
91
-		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins,
93
-					strlen(_DIR_RACINE)) . $plug));
94
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
95
-	}
96
-	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
97
-	$class = basename($dir_plugins);
77
+    $res = '';
78
+    $block = '';
79
+    $initiale = '';
80
+    $block_actif = false;
81
+    foreach ($liste_plugins as $plug => $nom) {
82
+        if (($i = substr($nom, 0, 1)) !== $initiale) {
83
+            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
+            $initiale = $i;
85
+            $block = '';
86
+            $block_actif = false;
87
+        }
88
+        // le rep suivant
89
+        $actif = isset($fast_liste_plugins_actifs[$plug]);
90
+        $checked = isset($fast_liste_plugins_checked[$plug]);
91
+        $block_actif = $block_actif | $actif;
92
+        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins,
93
+                    strlen(_DIR_RACINE)) . $plug));
94
+        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
95
+    }
96
+    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
97
+    $class = basename($dir_plugins);
98 98
 
99
-	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : "";
99
+    return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : "";
100 100
 }
101 101
 
102 102
 
103 103
 // https://code.spip.net/@affiche_block_initiale
104 104
 function affiche_block_initiale($initiale, $block, $block_actif) {
105
-	if (strlen($block)) {
106
-		return "<li class='item'>"
107
-		. bouton_block_depliable($initiale, $block_actif ? true : false)
108
-		. debut_block_depliable($block_actif)
109
-		. "<ul>$block</ul>"
110
-		. fin_block()
111
-		. "</li>";
112
-	}
105
+    if (strlen($block)) {
106
+        return "<li class='item'>"
107
+        . bouton_block_depliable($initiale, $block_actif ? true : false)
108
+        . debut_block_depliable($block_actif)
109
+        . "<ul>$block</ul>"
110
+        . fin_block()
111
+        . "</li>";
112
+    }
113 113
 
114
-	return "";
114
+    return "";
115 115
 }
Please login to merge, or discard this patch.