Completed
Push — master ( 4fa0dc...b74578 )
by cam
01:19
created
ecrire/inc/bandeau.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 include_spip('inc/boutons');
@@ -38,33 +38,33 @@  discard block
 block discarded – undo
38 38
  *     contexte
39 39
  **/
40 40
 function definir_barre_contexte($contexte = null) {
41
-	if (is_null($contexte)) {
42
-		$contexte = $_GET;
43
-	} elseif (is_string($contexte)) {
44
-		$contexte = unserialize($contexte);
45
-	}
46
-	if (!isset($contexte['id_rubrique']) && isset($contexte['exec'])) {
47
-		if (!function_exists('trouver_objet_exec')) {
48
-			include_spip('inc/pipelines_ecrire');
49
-		}
50
-		if ($e = trouver_objet_exec($contexte['exec'])) {
51
-			$_id = $e['id_table_objet'];
52
-			if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) {
53
-				$table = $e['table_objet_sql'];
54
-				$row = sql_fetsel('*', $table, "$_id=" . (int) $id);
55
-				if (isset($row['id_rubrique'])) {
56
-					$contexte['id_rubrique'] = $row['id_rubrique'];
57
-					if (isset($row['id_secteur'])) {
58
-						$contexte['id_secteur'] = $row['id_secteur'];
59
-					}
60
-				} elseif (isset($row['id_groupe'])) {
61
-					// TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
62
-					$contexte['id_groupe'] = $row['id_groupe'];
63
-				}
64
-			}
65
-		}
66
-	}
67
-	return $contexte;
41
+    if (is_null($contexte)) {
42
+        $contexte = $_GET;
43
+    } elseif (is_string($contexte)) {
44
+        $contexte = unserialize($contexte);
45
+    }
46
+    if (!isset($contexte['id_rubrique']) && isset($contexte['exec'])) {
47
+        if (!function_exists('trouver_objet_exec')) {
48
+            include_spip('inc/pipelines_ecrire');
49
+        }
50
+        if ($e = trouver_objet_exec($contexte['exec'])) {
51
+            $_id = $e['id_table_objet'];
52
+            if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) {
53
+                $table = $e['table_objet_sql'];
54
+                $row = sql_fetsel('*', $table, "$_id=" . (int) $id);
55
+                if (isset($row['id_rubrique'])) {
56
+                    $contexte['id_rubrique'] = $row['id_rubrique'];
57
+                    if (isset($row['id_secteur'])) {
58
+                        $contexte['id_secteur'] = $row['id_secteur'];
59
+                    }
60
+                } elseif (isset($row['id_groupe'])) {
61
+                    // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
62
+                    $contexte['id_groupe'] = $row['id_groupe'];
63
+                }
64
+            }
65
+        }
66
+    }
67
+    return $contexte;
68 68
 }
69 69
 
70 70
 /**
@@ -80,89 +80,89 @@  discard block
 block discarded – undo
80 80
  * @return array
81 81
  */
82 82
 function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) {
83
-	include_spip('inc/autoriser');
84
-	$boutons_admin = [];
83
+    include_spip('inc/autoriser');
84
+    $boutons_admin = [];
85 85
 
86
-	// les boutons du core, issus de ecrire/paquet.xml
87
-	$liste_boutons = [];
86
+    // les boutons du core, issus de ecrire/paquet.xml
87
+    $liste_boutons = [];
88 88
 
89
-	// ajouter les boutons issus des plugin via paquet.xml
90
-	if (
91
-		function_exists('boutons_plugins')
92
-		&& is_array($liste_boutons_plugins = boutons_plugins())
93
-	) {
94
-		$liste_boutons = &$liste_boutons_plugins;
95
-	}
89
+    // ajouter les boutons issus des plugin via paquet.xml
90
+    if (
91
+        function_exists('boutons_plugins')
92
+        && is_array($liste_boutons_plugins = boutons_plugins())
93
+    ) {
94
+        $liste_boutons = &$liste_boutons_plugins;
95
+    }
96 96
 
97
-	foreach ($liste_boutons as $id => $infos) {
98
-		$parent = '';
99
-		// les boutons principaux ne sont pas soumis a autorisation
100
-		if (
101
-			!isset($infos['parent'])
102
-			|| !($parent = $infos['parent'])
103
-			|| !$autorise
104
-			|| autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
105
-		) {
106
-			if (
107
-				$parent
108
-				&& ($parent = preg_replace(',^bando_,', 'menu_', $parent))
109
-				&& isset($boutons_admin[$parent])
110
-			) {
111
-				$position = (isset($infos['position']) && strlen($infos['position'])) ? (int) $infos['position'] : count($boutons_admin[$parent]->sousmenu);
112
-				if ($position < 0) {
113
-					$position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
114
-				}
115
-				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
116
-					+ [
117
-						$id => new Bouton(
118
-							($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
119
-							$infos['titre'],  // titre
120
-							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
121
-							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
122
-						)
123
-					]
124
-					+ array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
125
-			}
126
-			if (
127
-				!$parent
128
-				// provisoire, eviter les vieux boutons
129
-				&& !in_array($id, ['forum', 'statistiques_visites'])
130
-				&& (!$autorise || autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
131
-			) {
132
-				$position = (isset($infos['position']) && $infos['position']) ? $infos['position'] : count($boutons_admin);
133
-				$boutons_admin = array_slice($boutons_admin, 0, $position)
134
-					+ [
135
-						$id => new Bouton(
136
-							($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
137
-							$infos['titre'],  // titre
138
-							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
139
-							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
140
-						)
141
-					]
142
-					+ array_slice($boutons_admin, $position, 100);
143
-			}
144
-		}
145
-	}
146
-	$boutons_admin = pipeline('ajouter_menus', $boutons_admin);
97
+    foreach ($liste_boutons as $id => $infos) {
98
+        $parent = '';
99
+        // les boutons principaux ne sont pas soumis a autorisation
100
+        if (
101
+            !isset($infos['parent'])
102
+            || !($parent = $infos['parent'])
103
+            || !$autorise
104
+            || autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
105
+        ) {
106
+            if (
107
+                $parent
108
+                && ($parent = preg_replace(',^bando_,', 'menu_', $parent))
109
+                && isset($boutons_admin[$parent])
110
+            ) {
111
+                $position = (isset($infos['position']) && strlen($infos['position'])) ? (int) $infos['position'] : count($boutons_admin[$parent]->sousmenu);
112
+                if ($position < 0) {
113
+                    $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
114
+                }
115
+                $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
116
+                    + [
117
+                        $id => new Bouton(
118
+                            ($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
119
+                            $infos['titre'],  // titre
120
+                            (isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
121
+                            (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
122
+                        )
123
+                    ]
124
+                    + array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
125
+            }
126
+            if (
127
+                !$parent
128
+                // provisoire, eviter les vieux boutons
129
+                && !in_array($id, ['forum', 'statistiques_visites'])
130
+                && (!$autorise || autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
131
+            ) {
132
+                $position = (isset($infos['position']) && $infos['position']) ? $infos['position'] : count($boutons_admin);
133
+                $boutons_admin = array_slice($boutons_admin, 0, $position)
134
+                    + [
135
+                        $id => new Bouton(
136
+                            ($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
137
+                            $infos['titre'],  // titre
138
+                            (isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
139
+                            (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
140
+                        )
141
+                    ]
142
+                    + array_slice($boutons_admin, $position, 100);
143
+            }
144
+        }
145
+    }
146
+    $boutons_admin = pipeline('ajouter_menus', $boutons_admin);
147 147
 
148
-	// définir les favoris et positions d’origine
149
-	if ($boutons_admin) {
150
-		$menus_favoris = obtenir_menus_favoris();
151
-		$i = 1;
152
-		foreach ($boutons_admin as $key => $menu) {
153
-			$menu->favori = (int) table_valeur($menus_favoris, $key, false);
154
-			$menu->position = $i++;
155
-			if ($menu->sousmenu) {
156
-				$j = 1;
157
-				foreach ($menu->sousmenu as $key => $bouton) {
158
-					$bouton->favori = (int) table_valeur($menus_favoris, $key, false);
159
-					$bouton->position = $j++;
160
-				}
161
-			}
162
-		}
163
-	}
148
+    // définir les favoris et positions d’origine
149
+    if ($boutons_admin) {
150
+        $menus_favoris = obtenir_menus_favoris();
151
+        $i = 1;
152
+        foreach ($boutons_admin as $key => $menu) {
153
+            $menu->favori = (int) table_valeur($menus_favoris, $key, false);
154
+            $menu->position = $i++;
155
+            if ($menu->sousmenu) {
156
+                $j = 1;
157
+                foreach ($menu->sousmenu as $key => $bouton) {
158
+                    $bouton->favori = (int) table_valeur($menus_favoris, $key, false);
159
+                    $bouton->position = $j++;
160
+                }
161
+            }
162
+        }
163
+    }
164 164
 
165
-	return $boutons_admin;
165
+    return $boutons_admin;
166 166
 }
167 167
 
168 168
 /**
@@ -174,22 +174,22 @@  discard block
 block discarded – undo
174 174
  * @return Bouton[]
175 175
  */
176 176
 function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) {
177
-	foreach ($menus as $menu) {
178
-		if ($menu->sousmenu) {
179
-			$libelles = $isfavoris = $favoris = [];
180
-			foreach ($menu->sousmenu as $key => $item) {
181
-				$libelles[$key] = strtolower(translitteration(_T($item->libelle)));
182
-				$isfavoris[$key] = (bool) $item->favori;
183
-				$favoris[$key] = $item->favori;
184
-			}
185
-			if ($avec_favoris) {
186
-				array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
187
-			} else {
188
-				array_multisort($libelles, SORT_ASC, $menu->sousmenu);
189
-			}
190
-		}
191
-	}
192
-	return $menus;
177
+    foreach ($menus as $menu) {
178
+        if ($menu->sousmenu) {
179
+            $libelles = $isfavoris = $favoris = [];
180
+            foreach ($menu->sousmenu as $key => $item) {
181
+                $libelles[$key] = strtolower(translitteration(_T($item->libelle)));
182
+                $isfavoris[$key] = (bool) $item->favori;
183
+                $favoris[$key] = $item->favori;
184
+            }
185
+            if ($avec_favoris) {
186
+                array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
187
+            } else {
188
+                array_multisort($libelles, SORT_ASC, $menu->sousmenu);
189
+            }
190
+        }
191
+    }
192
+    return $menus;
193 193
 }
194 194
 
195 195
 /**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
  * @return Bouton[]
201 201
  */
202 202
 function trier_boutons_enfants_par_favoris_alpha($menus) {
203
-	return trier_boutons_enfants_par_alpha($menus, true);
203
+    return trier_boutons_enfants_par_alpha($menus, true);
204 204
 }
205 205
 
206 206
 
@@ -213,23 +213,23 @@  discard block
 block discarded – undo
213 213
  * @return string
214 214
  */
215 215
 function bandeau_creer_url($url, $args = '', $contexte = null) {
216
-	if (!preg_match(',[\/\?],', $url)) {
217
-		$url = generer_url_ecrire($url, $args, true);
218
-		// recuperer les parametres du contexte demande par l'url sous la forme
219
-		// &truc=@machin@
220
-		// @machin@ etant remplace par _request('machin')
221
-		$url = str_replace('&amp;', '&', $url);
222
-		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
223
-			if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) {
224
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']);
225
-			}
226
-			$val = _request($matches[2], $contexte);
227
-			$url = parametre_url($url, $matches[1], $val ?: '', '&');
228
-		}
229
-		$url = str_replace('&', '&amp;', $url);
230
-	}
216
+    if (!preg_match(',[\/\?],', $url)) {
217
+        $url = generer_url_ecrire($url, $args, true);
218
+        // recuperer les parametres du contexte demande par l'url sous la forme
219
+        // &truc=@machin@
220
+        // @machin@ etant remplace par _request('machin')
221
+        $url = str_replace('&amp;', '&', $url);
222
+        while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
223
+            if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) {
224
+                $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']);
225
+            }
226
+            $val = _request($matches[2], $contexte);
227
+            $url = parametre_url($url, $matches[1], $val ?: '', '&');
228
+        }
229
+        $url = str_replace('&', '&amp;', $url);
230
+    }
231 231
 
232
-	return $url;
232
+    return $url;
233 233
 }
234 234
 
235 235
 /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
  *     Code HTML du bandeau
240 240
  */
241 241
 function inc_bandeau_dist() {
242
-	return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
242
+    return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
243 243
 }
244 244
 
245 245
 
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
  * @return array
249 249
  */
250 250
 function obtenir_menus_favoris() {
251
-	if (
252
-		isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
253
-		&& is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
254
-		&& $GLOBALS['visiteur_session']['prefs']['menus_favoris']
255
-	) {
256
-		return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
257
-	}
258
-	$definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
259
-	return $definir_menus_favoris();
251
+    if (
252
+        isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
253
+        && is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
254
+        && $GLOBALS['visiteur_session']['prefs']['menus_favoris']
255
+    ) {
256
+        return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
257
+    }
258
+    $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
259
+    return $definir_menus_favoris();
260 260
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			$_id = $e['id_table_objet'];
52 52
 			if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) {
53 53
 				$table = $e['table_objet_sql'];
54
-				$row = sql_fetsel('*', $table, "$_id=" . (int) $id);
54
+				$row = sql_fetsel('*', $table, "$_id=".(int) $id);
55 55
 				if (isset($row['id_rubrique'])) {
56 56
 					$contexte['id_rubrique'] = $row['id_rubrique'];
57 57
 					if (isset($row['id_secteur'])) {
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
116 116
 					+ [
117 117
 						$id => new Bouton(
118
-							($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
119
-							$infos['titre'],  // titre
118
+							($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone
119
+							$infos['titre'], // titre
120 120
 							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
121 121
 							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
122 122
 						)
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 				$boutons_admin = array_slice($boutons_admin, 0, $position)
134 134
 					+ [
135 135
 						$id => new Bouton(
136
-							($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
137
-							$infos['titre'],  // titre
136
+							($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone
137
+							$infos['titre'], // titre
138 138
 							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
139 139
 							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
140 140
 						)
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		$url = str_replace('&amp;', '&', $url);
222 222
 		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
223 223
 			if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) {
224
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']);
224
+				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.(int) $contexte['id_rubrique']);
225 225
 			}
226 226
 			$val = _request($matches[2], $contexte);
227 227
 			$url = parametre_url($url, $matches[1], $val ?: '', '&');
Please login to merge, or discard this patch.
ecrire/inc/cvt_autosave.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @return string
27 27
  */
28 28
 function autosave_clean_value($val) {
29
-	return stripslashes(urldecode($val));
29
+    return stripslashes(urldecode($val));
30 30
 }
31 31
 
32 32
 /**
@@ -37,58 +37,58 @@  discard block
 block discarded – undo
37 37
  * @return array
38 38
  */
39 39
 function cvtautosave_formulaire_charger($flux) {
40
-	if (
41
-		is_array($flux['data'])
42
-		&& isset($flux['data']['_autosave_id'])
43
-		&& ($cle_autosave = $flux['data']['_autosave_id'])
44
-	) {
45
-		$form = $flux['args']['form'];
46
-		$je_suis_poste = $flux['args']['je_suis_poste'];
40
+    if (
41
+        is_array($flux['data'])
42
+        && isset($flux['data']['_autosave_id'])
43
+        && ($cle_autosave = $flux['data']['_autosave_id'])
44
+    ) {
45
+        $form = $flux['args']['form'];
46
+        $je_suis_poste = $flux['args']['je_suis_poste'];
47 47
 
48
-		$cle_autosave = serialize($cle_autosave);
49
-		$cle_autosave = $form . '_' . md5($cle_autosave);
48
+        $cle_autosave = serialize($cle_autosave);
49
+        $cle_autosave = $form . '_' . md5($cle_autosave);
50 50
 
51
-		// si on a un backup en session et qu'on est au premier chargement, non poste
52
-		// on restitue les donnees
53
-		if (
54
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
-			&& !$je_suis_poste
56
-		) {
57
-			parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
-			foreach ($vars as $key => $val) {
59
-				if (isset($flux['data'][$key])) {
60
-					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
61
-						'autosave_clean_value',
62
-						$val
63
-					));
64
-				}
65
-			}
66
-		}
51
+        // si on a un backup en session et qu'on est au premier chargement, non poste
52
+        // on restitue les donnees
53
+        if (
54
+            isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
+            && !$je_suis_poste
56
+        ) {
57
+            parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
+            foreach ($vars as $key => $val) {
59
+                if (isset($flux['data'][$key])) {
60
+                    $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
61
+                        'autosave_clean_value',
62
+                        $val
63
+                    ));
64
+                }
65
+            }
66
+        }
67 67
 
68
-		// si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
69
-		// mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
70
-		if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71
-			terminer_actualiser_sessions();
72
-			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
-				session_set('session_autosave_' . $cle_autosave, null);
75
-				// en court sleep pour etre certain que la concurrence est finie
76
-				sleep(1);
77
-				terminer_actualiser_sessions();
78
-			}
79
-		}
68
+        // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
69
+        // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
70
+        if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71
+            terminer_actualiser_sessions();
72
+            // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
+            if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
+                session_set('session_autosave_' . $cle_autosave, null);
75
+                // en court sleep pour etre certain que la concurrence est finie
76
+                sleep(1);
77
+                terminer_actualiser_sessions();
78
+            }
79
+        }
80 80
 
81 81
 
82
-		/**
83
-		 * Envoyer le input hidden et le bout de js qui l'utilisera
84
-		 */
85
-		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86
-			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
82
+        /**
83
+         * Envoyer le input hidden et le bout de js qui l'utilisera
84
+         */
85
+        $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86
+            . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
87 87
 		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
88 88
 			});/*]]>*/</script>';
89
-	}
89
+    }
90 90
 
91
-	return $flux;
91
+    return $flux;
92 92
 }
93 93
 
94 94
 /**
@@ -102,33 +102,33 @@  discard block
 block discarded – undo
102 102
  * @return array
103 103
  */
104 104
 function cvtautosave_formulaire_traiter($flux) {
105
-	// si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
106
-	// on elimine les donnees de la session
107
-	if ($cle_autosave = _request('autosave')) {
108
-		include_spip('inc/session');
109
-		session_set('session_autosave_' . $cle_autosave, null);
110
-	}
105
+    // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
106
+    // on elimine les donnees de la session
107
+    if ($cle_autosave = _request('autosave')) {
108
+        include_spip('inc/session');
109
+        session_set('session_autosave_' . $cle_autosave, null);
110
+    }
111 111
 
112
-	if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
113
-		// delai par defaut avant purge d'un backup de form : 72H
114
-		if (!defined('_AUTOSAVE_GB_DELAY')) {
115
-			define('_AUTOSAVE_GB_DELAY', 72 * 3600);
116
-		}
117
-		$time_too_old = time() - _AUTOSAVE_GB_DELAY;
118
-		// purger aussi toutes les vieilles autosave
119
-		$session = $GLOBALS['visiteur_session'];
120
-		foreach ($session as $k => $v) {
121
-			if (str_starts_with($k, 'session_autosave_')) {
122
-				$timestamp = 0;
123
-				if (preg_match(',&__timestamp=(\d+)$,', $v, $m)) {
124
-					$timestamp = (int) $m[1];
125
-				}
126
-				if ($timestamp < $time_too_old) {
127
-					session_set($k, null);
128
-				}
129
-			}
130
-		}
131
-	}
112
+    if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
113
+        // delai par defaut avant purge d'un backup de form : 72H
114
+        if (!defined('_AUTOSAVE_GB_DELAY')) {
115
+            define('_AUTOSAVE_GB_DELAY', 72 * 3600);
116
+        }
117
+        $time_too_old = time() - _AUTOSAVE_GB_DELAY;
118
+        // purger aussi toutes les vieilles autosave
119
+        $session = $GLOBALS['visiteur_session'];
120
+        foreach ($session as $k => $v) {
121
+            if (str_starts_with($k, 'session_autosave_')) {
122
+                $timestamp = 0;
123
+                if (preg_match(',&__timestamp=(\d+)$,', $v, $m)) {
124
+                    $timestamp = (int) $m[1];
125
+                }
126
+                if ($timestamp < $time_too_old) {
127
+                    session_set($k, null);
128
+                }
129
+            }
130
+        }
131
+    }
132 132
 
133
-	return $flux;
133
+    return $flux;
134 134
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 		$je_suis_poste = $flux['args']['je_suis_poste'];
47 47
 
48 48
 		$cle_autosave = serialize($cle_autosave);
49
-		$cle_autosave = $form . '_' . md5($cle_autosave);
49
+		$cle_autosave = $form.'_'.md5($cle_autosave);
50 50
 
51 51
 		// si on a un backup en session et qu'on est au premier chargement, non poste
52 52
 		// on restitue les donnees
53 53
 		if (
54
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
54
+			isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])
55 55
 			&& !$je_suis_poste
56 56
 		) {
57
-			parse_str($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
57
+			parse_str($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave], $vars);
58 58
 			foreach ($vars as $key => $val) {
59 59
 				if (isset($flux['data'][$key])) {
60 60
 					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 		if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71 71
 			terminer_actualiser_sessions();
72 72
 			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
-				session_set('session_autosave_' . $cle_autosave, null);
73
+			if (isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])) {
74
+				session_set('session_autosave_'.$cle_autosave, null);
75 75
 				// en court sleep pour etre certain que la concurrence est finie
76 76
 				sleep(1);
77 77
 				terminer_actualiser_sessions();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		 */
85 85
 		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86 86
 			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
87
-		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
87
+		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'].'/"}).addClass("autosaveon");
88 88
 			});/*]]>*/</script>';
89 89
 	}
90 90
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	// on elimine les donnees de la session
107 107
 	if ($cle_autosave = _request('autosave')) {
108 108
 		include_spip('inc/session');
109
-		session_set('session_autosave_' . $cle_autosave, null);
109
+		session_set('session_autosave_'.$cle_autosave, null);
110 110
 	}
111 111
 
112 112
 	if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
Please login to merge, or discard this patch.
ecrire/inc/cookie.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -51,64 +51,64 @@  discard block
 block discarded – undo
51 51
  *     cookie sécurisé ou non ?
52 52
  **/
53 53
 function spip_setcookie($name = '', $value = '', $options = []) {
54
-	static $to_secure_list = ['spip_session'];
55
-	if (defined('_COOKIE_SECURE_LIST') && is_array(_COOKIE_SECURE_LIST)) {
56
-		$to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST);
57
-	}
58
-
59
-	if (!is_array($options)) {
60
-		// anciens paramètres :
61
-		# spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '')
62
-		$opt = func_get_args();
63
-		$opt = array_slice($opt, 2);
64
-		$options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !);
65
-		if (isset($opt[0])) {
66
-			$options['expires'] = $opt[0];
67
-		}
68
-		if (isset($opt[1])) {
69
-			$options['path'] = $opt[1];
70
-		}
71
-		if (isset($opt[2])) {
72
-			$options['domain'] = $opt[2];
73
-		}
74
-		if (isset($opt[3])) {
75
-			$options['secure'] = $opt[3];
76
-		}
77
-	}
78
-
79
-	// expires
80
-	if (!isset($options['expires'])) {
81
-		$options['expires'] = 0;
82
-	}
83
-	if (!isset($options['path']) || $options['path'] === 'AUTO') {
84
-		$options['path'] = defined('_COOKIE_PATH') ? _COOKIE_PATH : preg_replace(',^\w+://[^/]*,', '', url_de_base());
85
-	}
86
-	if (empty($options['domain']) && defined('_COOKIE_DOMAIN') && _COOKIE_DOMAIN) {
87
-		$options['domain'] = _COOKIE_DOMAIN;
88
-	}
89
-	if (in_array($name, $to_secure_list)) {
90
-		if (empty($options['secure']) && defined('_COOKIE_SECURE') && _COOKIE_SECURE) {
91
-			$options['secure'] = true;
92
-		}
93
-		if (empty($options['httponly'])) {
94
-			$options['httponly'] = true;
95
-		}
96
-	}
97
-	if (empty($options['samesite'])) {
98
-		$options['samesite'] = 'Lax';
99
-	}
100
-
101
-	// in fine renommer le prefixe si besoin
102
-	if (str_starts_with($name, 'spip_')) {
103
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
104
-	}
105
-
106
-	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
107
-	$a = @setcookie($name, $value, $options);
108
-
109
-	spip_cookie_envoye(true);
110
-
111
-	return $a;
54
+    static $to_secure_list = ['spip_session'];
55
+    if (defined('_COOKIE_SECURE_LIST') && is_array(_COOKIE_SECURE_LIST)) {
56
+        $to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST);
57
+    }
58
+
59
+    if (!is_array($options)) {
60
+        // anciens paramètres :
61
+        # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '')
62
+        $opt = func_get_args();
63
+        $opt = array_slice($opt, 2);
64
+        $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !);
65
+        if (isset($opt[0])) {
66
+            $options['expires'] = $opt[0];
67
+        }
68
+        if (isset($opt[1])) {
69
+            $options['path'] = $opt[1];
70
+        }
71
+        if (isset($opt[2])) {
72
+            $options['domain'] = $opt[2];
73
+        }
74
+        if (isset($opt[3])) {
75
+            $options['secure'] = $opt[3];
76
+        }
77
+    }
78
+
79
+    // expires
80
+    if (!isset($options['expires'])) {
81
+        $options['expires'] = 0;
82
+    }
83
+    if (!isset($options['path']) || $options['path'] === 'AUTO') {
84
+        $options['path'] = defined('_COOKIE_PATH') ? _COOKIE_PATH : preg_replace(',^\w+://[^/]*,', '', url_de_base());
85
+    }
86
+    if (empty($options['domain']) && defined('_COOKIE_DOMAIN') && _COOKIE_DOMAIN) {
87
+        $options['domain'] = _COOKIE_DOMAIN;
88
+    }
89
+    if (in_array($name, $to_secure_list)) {
90
+        if (empty($options['secure']) && defined('_COOKIE_SECURE') && _COOKIE_SECURE) {
91
+            $options['secure'] = true;
92
+        }
93
+        if (empty($options['httponly'])) {
94
+            $options['httponly'] = true;
95
+        }
96
+    }
97
+    if (empty($options['samesite'])) {
98
+        $options['samesite'] = 'Lax';
99
+    }
100
+
101
+    // in fine renommer le prefixe si besoin
102
+    if (str_starts_with($name, 'spip_')) {
103
+        $name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
104
+    }
105
+
106
+    #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
107
+    $a = @setcookie($name, $value, $options);
108
+
109
+    spip_cookie_envoye(true);
110
+
111
+    return $a;
112 112
 }
113 113
 
114 114
 /**
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
  * @return bool
125 125
  **/
126 126
 function spip_cookie_envoye($set = '') {
127
-	static $envoye = false;
128
-	if ($set) {
129
-		$envoye = true;
130
-	}
127
+    static $envoye = false;
128
+    if ($set) {
129
+        $envoye = true;
130
+    }
131 131
 
132
-	return $envoye;
132
+    return $envoye;
133 133
 }
134 134
 
135 135
 /**
@@ -148,21 +148,21 @@  discard block
 block discarded – undo
148 148
  *     Préfixe des cookies de SPIP
149 149
  **/
150 150
 function recuperer_cookies_spip($cookie_prefix) {
151
-	$prefix_long = strlen($cookie_prefix);
152
-
153
-	foreach (array_keys($_COOKIE) as $name) {
154
-		if (str_starts_with($name, 'spip_') && substr($name, 0, $prefix_long) != $cookie_prefix) {
155
-			unset($_COOKIE[$name]);
156
-			unset($GLOBALS[$name]);
157
-		}
158
-	}
159
-	foreach ($_COOKIE as $name => $value) {
160
-		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
162
-			$_COOKIE[$spipname] = $value;
163
-			$GLOBALS[$spipname] = $value;
164
-		}
165
-	}
151
+    $prefix_long = strlen($cookie_prefix);
152
+
153
+    foreach (array_keys($_COOKIE) as $name) {
154
+        if (str_starts_with($name, 'spip_') && substr($name, 0, $prefix_long) != $cookie_prefix) {
155
+            unset($_COOKIE[$name]);
156
+            unset($GLOBALS[$name]);
157
+        }
158
+    }
159
+    foreach ($_COOKIE as $name => $value) {
160
+        if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
+            $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
162
+            $_COOKIE[$spipname] = $value;
163
+            $GLOBALS[$spipname] = $value;
164
+        }
165
+    }
166 166
 }
167 167
 
168 168
 
@@ -181,18 +181,18 @@  discard block
 block discarded – undo
181 181
  *
182 182
  **/
183 183
 function exec_test_ajax_dist() {
184
-	switch (_request('js')) {
185
-		// on est appele par <noscript>
186
-		case -1:
187
-			spip_setcookie('spip_accepte_ajax', -1);
188
-			include_spip('inc/headers');
189
-			redirige_par_entete(chemin_image('erreur-xx.svg'));
190
-			break;
191
-
192
-		// ou par ajax
193
-		case 1:
194
-		default:
195
-			spip_setcookie('spip_accepte_ajax', 1);
196
-			break;
197
-	}
184
+    switch (_request('js')) {
185
+        // on est appele par <noscript>
186
+        case -1:
187
+            spip_setcookie('spip_accepte_ajax', -1);
188
+            include_spip('inc/headers');
189
+            redirige_par_entete(chemin_image('erreur-xx.svg'));
190
+            break;
191
+
192
+        // ou par ajax
193
+        case 1:
194
+        default:
195
+            spip_setcookie('spip_accepte_ajax', 1);
196
+            break;
197
+    }
198 198
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
 	// in fine renommer le prefixe si besoin
102 102
 	if (str_starts_with($name, 'spip_')) {
103
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
103
+		$name = $GLOBALS['cookie_prefix'].'_'.substr($name, 5);
104 104
 	}
105 105
 
106 106
 	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	}
159 159
 	foreach ($_COOKIE as $name => $value) {
160 160
 		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
161
+			$spipname = preg_replace('/^'.$cookie_prefix.'_/', 'spip_', $name);
162 162
 			$_COOKIE[$spipname] = $value;
163 163
 			$GLOBALS[$spipname] = $value;
164 164
 		}
Please login to merge, or discard this patch.
ecrire/inc/selectionner.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/filtres');
@@ -45,56 +45,56 @@  discard block
 block discarded – undo
45 45
  **/
46 46
 function inc_selectionner_dist($sel, $idom = '', $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') {
47 47
 
48
-	if ($recur) {
49
-		$recur = mini_hier($sel);
50
-	} else {
51
-		$sel = 0;
52
-	}
53
-
54
-	if ($aff_racine) {
55
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
-		$idom3 = $idom . '_selection';
57
-
58
-		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59
-
60
-		$ondbClick = strtr(
61
-			str_replace(
62
-				"'",
63
-				'&#8217;',
64
-				str_replace(
65
-					'"',
66
-					'&#34;',
67
-					textebrut(_T('info_racine_site'))
68
-				)
69
-			),
70
-			"\n\r",
71
-			'  '
72
-		);
73
-
74
-		$js_func = $do . '_selection_titre';
75
-		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76
-
77
-		$aff_racine = "<div class='petit-item petite-racine item'>"
78
-			. "<a href='#'"
79
-			. 'onclick="'
80
-			. $onClick
81
-			. "\"\nondbclick=\""
82
-			. $ondbClick
83
-			. $onClick
84
-			. '">'
85
-			. _T('info_racine_site')
86
-			. '</a></div>';
87
-	}
88
-
89
-	$url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
90
-
91
-	$plonger = charger_fonction('plonger', 'inc');
92
-	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
93
-
94
-	// url completee par la fonction JS onkeypress_rechercher
95
-	$url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
96
-
97
-	return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
48
+    if ($recur) {
49
+        $recur = mini_hier($sel);
50
+    } else {
51
+        $sel = 0;
52
+    }
53
+
54
+    if ($aff_racine) {
55
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
+        $idom3 = $idom . '_selection';
57
+
58
+        $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59
+
60
+        $ondbClick = strtr(
61
+            str_replace(
62
+                "'",
63
+                '&#8217;',
64
+                str_replace(
65
+                    '"',
66
+                    '&#34;',
67
+                    textebrut(_T('info_racine_site'))
68
+                )
69
+            ),
70
+            "\n\r",
71
+            '  '
72
+        );
73
+
74
+        $js_func = $do . '_selection_titre';
75
+        $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76
+
77
+        $aff_racine = "<div class='petit-item petite-racine item'>"
78
+            . "<a href='#'"
79
+            . 'onclick="'
80
+            . $onClick
81
+            . "\"\nondbclick=\""
82
+            . $ondbClick
83
+            . $onClick
84
+            . '">'
85
+            . _T('info_racine_site')
86
+            . '</a></div>';
87
+    }
88
+
89
+    $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
90
+
91
+    $plonger = charger_fonction('plonger', 'inc');
92
+    $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
93
+
94
+    // url completee par la fonction JS onkeypress_rechercher
95
+    $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
96
+
97
+    return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
98 98
 }
99 99
 
100 100
 /**
@@ -112,58 +112,58 @@  discard block
 block discarded – undo
112 112
  **/
113 113
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
114 114
 
115
-	$idom1 = $idom . '_champ_recherche';
116
-	$idom2 = $idom . '_principal';
117
-	$idom3 = $idom . '_selection';
118
-	$idom4 = $idom . '_col_1';
119
-	$idom5 = 'img_' . $idom4;
120
-	$idom6 = $idom . '_fonc';
121
-
122
-	return "<div id='$idom'>"
123
-	. "<a id='$idom6' style='visibility: hidden;'"
124
-	. ($url_init ? "\nhref='$url_init'" : '')
125
-	. '></a>'
126
-	. "<div class='recherche_rapide_parent formulaire_recherche'>"
127
-	. http_img_pack(
128
-		'loader.svg',
129
-		'',
130
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
131
-	)
132
-	. ''
133
-	. "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
134
-	// eliminer Return car il provoque la soumission (balise unique)
135
-	// et eliminer Tab pour la navigation au clavier
136
-	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
137
-	// resultats retournes par la recherche
138
-	. "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
139
-	// lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
140
-	. "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
141
-	// la destination de la recherche
142
-	. "'$idom4'"
115
+    $idom1 = $idom . '_champ_recherche';
116
+    $idom2 = $idom . '_principal';
117
+    $idom3 = $idom . '_selection';
118
+    $idom4 = $idom . '_col_1';
119
+    $idom5 = 'img_' . $idom4;
120
+    $idom6 = $idom . '_fonc';
121
+
122
+    return "<div id='$idom'>"
123
+    . "<a id='$idom6' style='visibility: hidden;'"
124
+    . ($url_init ? "\nhref='$url_init'" : '')
125
+    . '></a>'
126
+    . "<div class='recherche_rapide_parent formulaire_recherche'>"
127
+    . http_img_pack(
128
+        'loader.svg',
129
+        '',
130
+        "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
131
+    )
132
+    . ''
133
+    . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
134
+    // eliminer Return car il provoque la soumission (balise unique)
135
+    // et eliminer Tab pour la navigation au clavier
136
+    // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
137
+    // resultats retournes par la recherche
138
+    . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
139
+    // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
140
+    . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
141
+    // la destination de la recherche
142
+    . "'$idom4'"
143 143
 #	. "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
144
-	. ",'"
145
-	// l'url effectuant la recherche
146
-	. $url
147
-	. "',"
148
-	// le noeud contenant un gif anime
149
-	// . "'idom5'"
150
-	. 'this.parentNode.previousSibling.firstChild'
151
-	. ",'"
152
-	// la valeur de l'attribut Name a remplir
153
-	. $name
154
-	. "','"
155
-	// noeud invisible memorisant l'URL initiale (pour re-initialisation)
156
-	. $idom6
157
-	. "')\""
158
-	. ' />'
159
-	. "\n</div>"
160
-	. ($racine ? "<div>$racine</div>" : '')
161
-	. "<div id='"
162
-	. $idom2
163
-	. "'><div id='$idom4'"
164
-	. " class=''>"
165
-	. $liste
166
-	. "</div></div>\n<div id='$idom3'></div></div>\n";
144
+    . ",'"
145
+    // l'url effectuant la recherche
146
+    . $url
147
+    . "',"
148
+    // le noeud contenant un gif anime
149
+    // . "'idom5'"
150
+    . 'this.parentNode.previousSibling.firstChild'
151
+    . ",'"
152
+    // la valeur de l'attribut Name a remplir
153
+    . $name
154
+    . "','"
155
+    // noeud invisible memorisant l'URL initiale (pour re-initialisation)
156
+    . $idom6
157
+    . "')\""
158
+    . ' />'
159
+    . "\n</div>"
160
+    . ($racine ? "<div>$racine</div>" : '')
161
+    . "<div id='"
162
+    . $idom2
163
+    . "'><div id='$idom4'"
164
+    . " class=''>"
165
+    . $liste
166
+    . "</div></div>\n<div id='$idom3'></div></div>\n";
167 167
 }
168 168
 
169 169
 /**
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
  **/
176 176
 function mini_hier($id_rubrique) {
177 177
 
178
-	$liste = $id_rubrique;
179
-	$id_rubrique = (int) $id_rubrique;
180
-	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
-		$liste = $id_rubrique . ",$liste";
182
-	}
178
+    $liste = $id_rubrique;
179
+    $id_rubrique = (int) $id_rubrique;
180
+    while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
+        $liste = $id_rubrique . ",$liste";
182
+    }
183 183
 
184
-	return explode(',', "0,$liste");
184
+    return explode(',', "0,$liste");
185 185
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 	if ($aff_racine) {
55 55
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
-		$idom3 = $idom . '_selection';
56
+		$idom3 = $idom.'_selection';
57 57
 
58 58
 		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59 59
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			'  '
72 72
 		);
73 73
 
74
-		$js_func = $do . '_selection_titre';
74
+		$js_func = $do.'_selection_titre';
75 75
 		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76 76
 
77 77
 		$aff_racine = "<div class='petit-item petite-racine item'>"
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
  **/
113 113
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
114 114
 
115
-	$idom1 = $idom . '_champ_recherche';
116
-	$idom2 = $idom . '_principal';
117
-	$idom3 = $idom . '_selection';
118
-	$idom4 = $idom . '_col_1';
119
-	$idom5 = 'img_' . $idom4;
120
-	$idom6 = $idom . '_fonc';
115
+	$idom1 = $idom.'_champ_recherche';
116
+	$idom2 = $idom.'_principal';
117
+	$idom3 = $idom.'_selection';
118
+	$idom4 = $idom.'_col_1';
119
+	$idom5 = 'img_'.$idom4;
120
+	$idom6 = $idom.'_fonc';
121 121
 
122 122
 	return "<div id='$idom'>"
123 123
 	. "<a id='$idom6' style='visibility: hidden;'"
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	. http_img_pack(
128 128
 		'loader.svg',
129 129
 		'',
130
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
130
+		"class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'"
131 131
 	)
132 132
 	. ''
133
-	. "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
133
+	. "<input style='width: 10em;float:".$GLOBALS['spip_lang_right'].";' type='text' class='text search' id='$idom1' placeholder='"._T('info_rechercher')."'"
134 134
 	// eliminer Return car il provoque la soumission (balise unique)
135 135
 	// et eliminer Tab pour la navigation au clavier
136 136
 	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 
178 178
 	$liste = $id_rubrique;
179 179
 	$id_rubrique = (int) $id_rubrique;
180
-	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
-		$liste = $id_rubrique . ",$liste";
180
+	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = '.$id_rubrique)) {
181
+		$liste = $id_rubrique.",$liste";
182 182
 	}
183 183
 
184 184
 	return explode(',', "0,$liste");
Please login to merge, or discard this patch.
ecrire/inc/simplexml_to_array.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
  * @return array
23 23
  */
24 24
 function inc_simplexml_to_array_dist($u, $utiliser_namespace = false) {
25
-	// decoder la chaine en SimpleXML si pas deja fait
26
-	if (is_string($u)) {
27
-		$u = simplexml_load_string($u);
28
-	}
25
+    // decoder la chaine en SimpleXML si pas deja fait
26
+    if (is_string($u)) {
27
+        $u = simplexml_load_string($u);
28
+    }
29 29
 
30
-	return ['root' => @xmlObjToArr($u, $utiliser_namespace)];
30
+    return ['root' => @xmlObjToArr($u, $utiliser_namespace)];
31 31
 }
32 32
 
33 33
 
@@ -42,67 +42,67 @@  discard block
 block discarded – undo
42 42
  **/
43 43
 function xmlObjToArr($obj, $utiliser_namespace = false) {
44 44
 
45
-	$namespace = [];
46
-	$tableau = [];
45
+    $namespace = [];
46
+    $tableau = [];
47 47
 
48
-	// Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc
49
-	// de l'activer ou pas suivant le contenu supposé du XML
50
-	if (is_object($obj)) {
51
-		if (is_array($utiliser_namespace)) {
52
-			$namespace = $utiliser_namespace;
53
-		} else {
54
-			if ($utiliser_namespace) {
55
-				$namespace = $obj->getDocNamespaces(true);
56
-			}
57
-			$namespace[null] = null;
58
-		}
48
+    // Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc
49
+    // de l'activer ou pas suivant le contenu supposé du XML
50
+    if (is_object($obj)) {
51
+        if (is_array($utiliser_namespace)) {
52
+            $namespace = $utiliser_namespace;
53
+        } else {
54
+            if ($utiliser_namespace) {
55
+                $namespace = $obj->getDocNamespaces(true);
56
+            }
57
+            $namespace[null] = null;
58
+        }
59 59
 
60
-		$name = strtolower((string)$obj->getName());
61
-		$text = trim((string)$obj);
62
-		if (strlen($text) <= 0) {
63
-			$text = null;
64
-		}
60
+        $name = strtolower((string)$obj->getName());
61
+        $text = trim((string)$obj);
62
+        if (strlen($text) <= 0) {
63
+            $text = null;
64
+        }
65 65
 
66
-		$children = [];
67
-		$attributes = [];
66
+        $children = [];
67
+        $attributes = [];
68 68
 
69
-		// get info for all namespaces
70
-		foreach (array_keys($namespace) as $ns) {
71
-			// attributes
72
-			$objAttributes = $obj->attributes($ns, true);
73
-			foreach ($objAttributes as $attributeName => $attributeValue) {
74
-				$attribName = strtolower(trim((string)$attributeName));
75
-				$attribVal = trim((string)$attributeValue);
76
-				if (!empty($ns)) {
77
-					$attribName = $ns . ':' . $attribName;
78
-				}
79
-				$attributes[$attribName] = $attribVal;
80
-			}
69
+        // get info for all namespaces
70
+        foreach (array_keys($namespace) as $ns) {
71
+            // attributes
72
+            $objAttributes = $obj->attributes($ns, true);
73
+            foreach ($objAttributes as $attributeName => $attributeValue) {
74
+                $attribName = strtolower(trim((string)$attributeName));
75
+                $attribVal = trim((string)$attributeValue);
76
+                if (!empty($ns)) {
77
+                    $attribName = $ns . ':' . $attribName;
78
+                }
79
+                $attributes[$attribName] = $attribVal;
80
+            }
81 81
 
82
-			// children
83
-			$objChildren = $obj->children($ns, true);
84
-			foreach ($objChildren as $childName => $child) {
85
-				$childName = strtolower((string)$childName);
86
-				if (!empty($ns)) {
87
-					$childName = $ns . ':' . $childName;
88
-				}
89
-				$children[$childName][] = xmlObjToArr($child, $namespace);
90
-			}
91
-		}
82
+            // children
83
+            $objChildren = $obj->children($ns, true);
84
+            foreach ($objChildren as $childName => $child) {
85
+                $childName = strtolower((string)$childName);
86
+                if (!empty($ns)) {
87
+                    $childName = $ns . ':' . $childName;
88
+                }
89
+                $children[$childName][] = xmlObjToArr($child, $namespace);
90
+            }
91
+        }
92 92
 
93
-		$tableau = [
94
-			'name' => $name,
95
-		];
96
-		if ($text) {
97
-			$tableau['text'] = $text;
98
-		}
99
-		if ($attributes) {
100
-			$tableau['attributes'] = $attributes;
101
-		}
102
-		if ($children) {
103
-			$tableau['children'] = $children;
104
-		}
105
-	}
93
+        $tableau = [
94
+            'name' => $name,
95
+        ];
96
+        if ($text) {
97
+            $tableau['text'] = $text;
98
+        }
99
+        if ($attributes) {
100
+            $tableau['attributes'] = $attributes;
101
+        }
102
+        if ($children) {
103
+            $tableau['children'] = $children;
104
+        }
105
+    }
106 106
 
107
-	return $tableau;
107
+    return $tableau;
108 108
 }
Please login to merge, or discard this patch.
ecrire/inc/icone_renommer.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -10,71 +10,71 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/boutons');
17 17
 include_spip('base/objets');
18 18
 
19 19
 function inc_icone_renommer_dist($fond, $fonction) {
20
-	$size = 24;
21
-	if (
22
-		preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
23
-		&& (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
-	) {
25
-		if (isset($match[1]) && $match[1]) {
26
-			$size = $match[1];
27
-		}
28
-		$type = substr($fond, 0, -strlen($match[0]));
29
-		if (!isset($match[2]) || !$match[2]) {
30
-			$fond .= '.png';
31
-		}
32
-	} else {
33
-		$type = $fond;
34
-		$fond .= '.png';
35
-	}
20
+    $size = 24;
21
+    if (
22
+        preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
23
+        && (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
+    ) {
25
+        if (isset($match[1]) && $match[1]) {
26
+            $size = $match[1];
27
+        }
28
+        $type = substr($fond, 0, -strlen($match[0]));
29
+        if (!isset($match[2]) || !$match[2]) {
30
+            $fond .= '.png';
31
+        }
32
+    } else {
33
+        $type = $fond;
34
+        $fond .= '.png';
35
+    }
36 36
 
37
-	$rtl = false;
38
-	if (preg_match(',[-_]rtl$,i', $type, $match)) {
39
-		$rtl = true;
40
-		$type = substr($type, 0, -strlen($match[0]));
41
-	}
37
+    $rtl = false;
38
+    if (preg_match(',[-_]rtl$,i', $type, $match)) {
39
+        $rtl = true;
40
+        $type = substr($type, 0, -strlen($match[0]));
41
+    }
42 42
 
43
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
-	// et ne finit pas par un s, sauf si c'est une exception declaree
45
-	$type = objet_type($type, false);
43
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
+    // et ne finit pas par un s, sauf si c'est une exception declaree
45
+    $type = objet_type($type, false);
46 46
 
47
-	$dir = 'images/';
48
-	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
50
-		$dir = dirname($icone);
51
-		$fond = $icone;
47
+    $dir = 'images/';
48
+    $f = "$type-$size.png";
49
+    if ($icone = find_in_theme($dir . $f)) {
50
+        $dir = dirname($icone);
51
+        $fond = $icone;
52 52
 
53
-		if (
54
-			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone)))
56
-			&& file_exists($fr)
57
-		) {
58
-			$fond = $fr;
59
-		}
53
+        if (
54
+            $rtl
55
+            && ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone)))
56
+            && file_exists($fr)
57
+        ) {
58
+            $fond = $fr;
59
+        }
60 60
 
61
-		$action = $fonction;
62
-		if ($action == 'supprimer.gif') {
63
-			$action = 'del';
64
-		} elseif ($action == 'creer.gif') {
65
-			$action = 'new';
66
-		} elseif ($action == 'edit.gif') {
67
-			$action = 'edit';
68
-		}
61
+        $action = $fonction;
62
+        if ($action == 'supprimer.gif') {
63
+            $action = 'del';
64
+        } elseif ($action == 'creer.gif') {
65
+            $action = 'new';
66
+        } elseif ($action == 'edit.gif') {
67
+            $action = 'edit';
68
+        }
69 69
 
70
-		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
-			$fonction = $action;
73
-		}
70
+        $fonction = '';
71
+        if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
+            $fonction = $action;
73
+        }
74 74
 
75
-		// c'est bon !
76
-		return [$fond, $fonction];
77
-	}
75
+        // c'est bon !
76
+        return [$fond, $fonction];
77
+    }
78 78
 
79
-	return [$fond, $fonction];
79
+    return [$fond, $fonction];
80 80
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 
47 47
 	$dir = 'images/';
48 48
 	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
49
+	if ($icone = find_in_theme($dir.$f)) {
50 50
 		$dir = dirname($icone);
51 51
 		$fond = $icone;
52 52
 
53 53
 		if (
54 54
 			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone)))
55
+			&& ($fr = $dir.'/'.str_replace("$type-", "$type-rtl-", basename($icone)))
56 56
 			&& file_exists($fr)
57 57
 		) {
58 58
 			$fond = $fr;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		}
69 69
 
70 70
 		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
71
+		if (in_array($action, ['add', 'del', 'new', 'edit', 'config'])) {
72 72
 			$fonction = $action;
73 73
 		}
74 74
 
Please login to merge, or discard this patch.
ecrire/inc/modifier.php 1 patch
Indentation   +281 added lines, -281 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
  *     Tableau des champs et valeurs collectées
39 39
  */
40 40
 function collecter_requests($include_list, $exclude_list = [], $set = null, $tous = false) {
41
-	$c = $set;
42
-	if (!$c) {
43
-		$c = [];
44
-		foreach ($include_list as $champ) {
45
-			// on ne collecte que les champs reellement envoyes par defaut.
46
-			// le cas d'un envoi de valeur NULL peut du coup poser probleme.
47
-			$val = _request($champ);
48
-			if ($tous or $val !== null) {
49
-				$c[$champ] = $val;
50
-			}
51
-		}
52
-		// on ajoute toujours la lang en saisie possible
53
-		// meme si pas prevu au depart pour l'objet concerne
54
-		if ($l = _request('changer_lang')) {
55
-			$c['lang'] = $l;
56
-		}
57
-	}
58
-	foreach ($exclude_list as $champ) {
59
-		unset($c[$champ]);
60
-	}
61
-
62
-	return $c;
41
+    $c = $set;
42
+    if (!$c) {
43
+        $c = [];
44
+        foreach ($include_list as $champ) {
45
+            // on ne collecte que les champs reellement envoyes par defaut.
46
+            // le cas d'un envoi de valeur NULL peut du coup poser probleme.
47
+            $val = _request($champ);
48
+            if ($tous or $val !== null) {
49
+                $c[$champ] = $val;
50
+            }
51
+        }
52
+        // on ajoute toujours la lang en saisie possible
53
+        // meme si pas prevu au depart pour l'objet concerne
54
+        if ($l = _request('changer_lang')) {
55
+            $c['lang'] = $l;
56
+        }
57
+    }
58
+    foreach ($exclude_list as $champ) {
59
+        unset($c[$champ]);
60
+    }
61
+
62
+    return $c;
63 63
 }
64 64
 
65 65
 /**
@@ -96,262 +96,262 @@  discard block
 block discarded – undo
96 96
  *     - chaîne : texte d'un message d'erreur
97 97
  */
98 98
 function objet_modifier_champs($objet, $id_objet, $options, $c = null, $serveur = '') {
99
-	if (!$id_objet = intval($id_objet)) {
100
-		spip_log('Erreur $id_objet non defini', 'warn');
101
-
102
-		return _T('erreur_technique_enregistrement_impossible');
103
-	}
104
-
105
-	include_spip('inc/filtres');
106
-
107
-	$table_objet = table_objet($objet, $serveur);
108
-	$spip_table_objet = table_objet_sql($objet, $serveur);
109
-	$id_table_objet = id_table_objet($objet, $serveur);
110
-	$trouver_table = charger_fonction('trouver_table', 'base');
111
-	$desc = $trouver_table($spip_table_objet, $serveur);
112
-
113
-	// Appels incomplets (sans $c)
114
-	if (!is_array($c)) {
115
-		spip_log('erreur appel objet_modifier_champs(' . $objet . '), manque $c');
116
-
117
-		return _T('erreur_technique_enregistrement_impossible');
118
-	}
119
-
120
-	// Securite : certaines variables ne sont jamais acceptees ici
121
-	// car elles ne relevent pas de autoriser(xxx, modifier) ;
122
-	// il faut passer par instituer_XX()
123
-	// TODO: faut-il passer ces variables interdites
124
-	// dans un fichier de description separe ?
125
-	unset($c['statut']);
126
-	unset($c['id_parent']);
127
-	unset($c['id_rubrique']);
128
-	unset($c['id_secteur']);
129
-
130
-	// Gerer les champs non vides
131
-	if (isset($options['nonvide']) and is_array($options['nonvide'])) {
132
-		foreach ($options['nonvide'] as $champ => $sinon) {
133
-			if (isset($c[$champ]) and $c[$champ] === '') {
134
-				$c[$champ] = $sinon;
135
-			}
136
-		}
137
-	}
138
-
139
-	// N'accepter que les champs qui existent dans la table
140
-	$champs = array_intersect_key($c, $desc['field']);
141
-	// et dont la valeur n'est pas null
142
-	$champs = array_filter($champs, static function ($var) {
143
-		return $var !== null;
144
-	});
145
-	// TODO: ici aussi on peut valider les contenus
146
-	// en fonction du type
147
-
148
-	// Nettoyer les valeurs
149
-	$champs = array_map('corriger_caracteres', $champs);
150
-
151
-	// On récupère l'état avant toute modification
152
-	$row = sql_fetsel('*', $spip_table_objet, $id_table_objet . '=' . $id_objet);
153
-
154
-	// Envoyer aux plugins
155
-	$champs = pipeline(
156
-		'pre_edition',
157
-		[
158
-			'args' => [
159
-				'table' => $spip_table_objet, // compatibilite
160
-				'table_objet' => $table_objet,
161
-				'spip_table_objet' => $spip_table_objet,
162
-				'desc' => $desc,
163
-				'type' => $objet,
164
-				'id_objet' => $id_objet,
165
-				'data' => $options['data'] ?? null,
166
-				'champs' => $options['champs'] ?? [], // [doc] c'est quoi ?
167
-				'champs_anciens' => $row, // état du contenu avant modif
168
-				'serveur' => $serveur,
169
-				'action' => $options['action'] ?? 'modifier'
170
-			],
171
-			'data' => $champs
172
-		]
173
-	);
174
-
175
-	if (!$champs) {
176
-		return false;
177
-	}
178
-
179
-
180
-	// marquer le fait que l'objet est travaille par toto a telle date
181
-	include_spip('inc/config');
182
-	if (lire_config('articles_modif', 'non') !== 'non') {
183
-		include_spip('inc/drapeau_edition');
184
-		signale_edition($id_objet, $GLOBALS['visiteur_session'], $objet);
185
-	}
186
-
187
-	// Verifier si les mises a jour sont pertinentes, datees, en conflit etc
188
-	include_spip('inc/editer');
189
-	if (!isset($options['data']) or is_null($options['data'])) {
190
-		$options['data'] = &$_POST;
191
-	}
192
-	$conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur);
193
-	// cas hypothetique : normalement inc/editer verifie en amont le conflit edition
194
-	// et gere l'interface
195
-	// ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme
196
-	if ($conflits) {
197
-		return _T('titre_conflit_edition');
198
-	}
199
-
200
-	if ($champs) {
201
-		// cas particulier de la langue : passer par instituer_langue_objet
202
-		if (isset($champs['lang'])) {
203
-			if ($changer_lang = $champs['lang']) {
204
-				$id_rubrique = 0;
205
-				if (isset($desc['field']['id_rubrique'])) {
206
-					$parent = ($objet == 'rubrique') ? 'id_parent' : 'id_rubrique';
207
-					$id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=" . intval($id_objet));
208
-				}
209
-				$instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action');
210
-				$champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur);
211
-			}
212
-			// on laisse 'lang' dans $champs,
213
-			// ca permet de passer dans le pipeline post_edition et de journaliser
214
-			// et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir
215
-			// deja pris en compte
216
-		}
217
-
218
-		// la modif peut avoir lieu
219
-
220
-		// faut-il ajouter date_modif ?
221
-		if (
222
-			!empty($options['date_modif'])
223
-			and !isset($champs[$options['date_modif']])
224
-		) {
225
-			$champs[$options['date_modif']] = date('Y-m-d H:i:s');
226
-		}
227
-
228
-		// allez on commit la modif
229
-		sql_updateq($spip_table_objet, $champs, "$id_table_objet=" . intval($id_objet), [], $serveur);
230
-
231
-		// on verifie si elle est bien passee
232
-		$moof = sql_fetsel(
233
-			array_keys($champs),
234
-			$spip_table_objet,
235
-			"$id_table_objet=" . intval($id_objet),
236
-			[],
237
-			[],
238
-			'',
239
-			[],
240
-			$serveur
241
-		);
242
-		// si difference entre les champs, reperer les champs mal enregistres
243
-		if ($moof != $champs) {
244
-			$liste = [];
245
-			foreach ($moof as $k => $v) {
246
-				if (
247
-					$v !== $champs[$k]
248
-					// ne pas alerter si le champ est numerique est que les valeurs sont equivalentes
249
-					and (!is_numeric($v) or intval($v) !== intval($champs[$k]))
250
-					// ne pas alerter si le champ est date, qu'on a envoye une valeur vide et qu'on recupere une date nulle
251
-					and (strlen($champs[$k]) or !in_array($v, ['0000-00-00 00:00:00', '0000-00-00']))
252
-				) {
253
-					$liste[] = $k;
254
-					$conflits[$k]['post'] = $champs[$k];
255
-					$conflits[$k]['save'] = $v;
256
-
257
-					// cas specifique MySQL+emoji : si l'un est la
258
-					// conversion utf8_noplanes de l'autre alors c'est OK
259
-					if (defined('_MYSQL_NOPLANES') && _MYSQL_NOPLANES) {
260
-						include_spip('inc/charsets');
261
-						if ($v == utf8_noplanes($champs[$k])) {
262
-							array_pop($liste);
263
-						}
264
-					}
265
-				}
266
-			}
267
-			// si un champ n'a pas ete correctement enregistre, loger et retourner une erreur
268
-			// c'est un cas exceptionnel
269
-			if (count($liste)) {
270
-				spip_log(
271
-					"Erreur enregistrement en base $objet/$id_objet champs :" . var_export($conflits, true),
272
-					'modifier.' . _LOG_CRITIQUE
273
-				);
274
-
275
-				return _T(
276
-					'erreur_technique_enregistrement_champs',
277
-					['champs' => "<i>'" . implode("'</i>,<i>'", $liste) . "'</i>"]
278
-				);
279
-			}
280
-		}
281
-
282
-		// Invalider les caches
283
-		if (isset($options['invalideur']) and $options['invalideur']) {
284
-			include_spip('inc/invalideur');
285
-			if (is_array($options['invalideur'])) {
286
-				array_map('suivre_invalideur', $options['invalideur']);
287
-			} else {
288
-				suivre_invalideur($options['invalideur']);
289
-			}
290
-		}
291
-
292
-		// Notifications, gestion des revisions...
293
-		// en standard, appelle |nouvelle_revision ci-dessous
294
-		pipeline(
295
-			'post_edition',
296
-			[
297
-				'args' => [
298
-					'table' => $spip_table_objet,
299
-					'table_objet' => $table_objet,
300
-					'spip_table_objet' => $spip_table_objet,
301
-					'desc' => $desc,
302
-					'type' => $objet,
303
-					'id_objet' => $id_objet,
304
-					'champs' => $options['champs'] ?? [], // [doc] kesako ?
305
-					'champs_anciens' => $row, // état du contenu avant modif
306
-					'serveur' => $serveur,
307
-					'action' => $options['action'] ?? 'modifier'
308
-				],
309
-				'data' => $champs
310
-			]
311
-		);
312
-	}
313
-
314
-	// Appeler une notification
315
-	if ($notifications = charger_fonction('notifications', 'inc')) {
316
-		$notifications(
317
-			"{$objet}_modifier",
318
-			$id_objet,
319
-			[
320
-				'champs' => $champs,
321
-			]
322
-		);
323
-		$notifications(
324
-			'objet_modifier',
325
-			$id_objet,
326
-			[
327
-				'objet' => $objet,
328
-				'id_objet' => $id_objet,
329
-				'champs' => $champs,
330
-			]
331
-		);
332
-	}
333
-
334
-	// journaliser l'affaire
335
-	// message a affiner :-)
336
-	include_spip('inc/filtres_mini');
337
-	$qui = '';
338
-	if (!empty($GLOBALS['visiteur_session']['id_auteur'])) {
339
-		$qui .= ' #id_auteur:' . $GLOBALS['visiteur_session']['id_auteur'] . '#';
340
-	}
341
-	if (!empty($GLOBALS['visiteur_session']['nom'])) {
342
-		$qui .= ' #nom:' . $GLOBALS['visiteur_session']['nom'] . '#';
343
-	}
344
-	if ($qui == '') {
345
-		$qui = '#ip:' . $GLOBALS['ip'] . '#';
346
-	}
347
-	journal(_L($qui . ' a édité ' . $objet . ' ' . $id_objet . ' (' . join(
348
-		'+',
349
-		array_diff(array_keys($champs), ['date_modif'])
350
-	) . ')'), [
351
-		'faire' => 'modifier',
352
-		'quoi' => $objet,
353
-		'id' => $id_objet
354
-	]);
355
-
356
-	return '';
99
+    if (!$id_objet = intval($id_objet)) {
100
+        spip_log('Erreur $id_objet non defini', 'warn');
101
+
102
+        return _T('erreur_technique_enregistrement_impossible');
103
+    }
104
+
105
+    include_spip('inc/filtres');
106
+
107
+    $table_objet = table_objet($objet, $serveur);
108
+    $spip_table_objet = table_objet_sql($objet, $serveur);
109
+    $id_table_objet = id_table_objet($objet, $serveur);
110
+    $trouver_table = charger_fonction('trouver_table', 'base');
111
+    $desc = $trouver_table($spip_table_objet, $serveur);
112
+
113
+    // Appels incomplets (sans $c)
114
+    if (!is_array($c)) {
115
+        spip_log('erreur appel objet_modifier_champs(' . $objet . '), manque $c');
116
+
117
+        return _T('erreur_technique_enregistrement_impossible');
118
+    }
119
+
120
+    // Securite : certaines variables ne sont jamais acceptees ici
121
+    // car elles ne relevent pas de autoriser(xxx, modifier) ;
122
+    // il faut passer par instituer_XX()
123
+    // TODO: faut-il passer ces variables interdites
124
+    // dans un fichier de description separe ?
125
+    unset($c['statut']);
126
+    unset($c['id_parent']);
127
+    unset($c['id_rubrique']);
128
+    unset($c['id_secteur']);
129
+
130
+    // Gerer les champs non vides
131
+    if (isset($options['nonvide']) and is_array($options['nonvide'])) {
132
+        foreach ($options['nonvide'] as $champ => $sinon) {
133
+            if (isset($c[$champ]) and $c[$champ] === '') {
134
+                $c[$champ] = $sinon;
135
+            }
136
+        }
137
+    }
138
+
139
+    // N'accepter que les champs qui existent dans la table
140
+    $champs = array_intersect_key($c, $desc['field']);
141
+    // et dont la valeur n'est pas null
142
+    $champs = array_filter($champs, static function ($var) {
143
+        return $var !== null;
144
+    });
145
+    // TODO: ici aussi on peut valider les contenus
146
+    // en fonction du type
147
+
148
+    // Nettoyer les valeurs
149
+    $champs = array_map('corriger_caracteres', $champs);
150
+
151
+    // On récupère l'état avant toute modification
152
+    $row = sql_fetsel('*', $spip_table_objet, $id_table_objet . '=' . $id_objet);
153
+
154
+    // Envoyer aux plugins
155
+    $champs = pipeline(
156
+        'pre_edition',
157
+        [
158
+            'args' => [
159
+                'table' => $spip_table_objet, // compatibilite
160
+                'table_objet' => $table_objet,
161
+                'spip_table_objet' => $spip_table_objet,
162
+                'desc' => $desc,
163
+                'type' => $objet,
164
+                'id_objet' => $id_objet,
165
+                'data' => $options['data'] ?? null,
166
+                'champs' => $options['champs'] ?? [], // [doc] c'est quoi ?
167
+                'champs_anciens' => $row, // état du contenu avant modif
168
+                'serveur' => $serveur,
169
+                'action' => $options['action'] ?? 'modifier'
170
+            ],
171
+            'data' => $champs
172
+        ]
173
+    );
174
+
175
+    if (!$champs) {
176
+        return false;
177
+    }
178
+
179
+
180
+    // marquer le fait que l'objet est travaille par toto a telle date
181
+    include_spip('inc/config');
182
+    if (lire_config('articles_modif', 'non') !== 'non') {
183
+        include_spip('inc/drapeau_edition');
184
+        signale_edition($id_objet, $GLOBALS['visiteur_session'], $objet);
185
+    }
186
+
187
+    // Verifier si les mises a jour sont pertinentes, datees, en conflit etc
188
+    include_spip('inc/editer');
189
+    if (!isset($options['data']) or is_null($options['data'])) {
190
+        $options['data'] = &$_POST;
191
+    }
192
+    $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur);
193
+    // cas hypothetique : normalement inc/editer verifie en amont le conflit edition
194
+    // et gere l'interface
195
+    // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme
196
+    if ($conflits) {
197
+        return _T('titre_conflit_edition');
198
+    }
199
+
200
+    if ($champs) {
201
+        // cas particulier de la langue : passer par instituer_langue_objet
202
+        if (isset($champs['lang'])) {
203
+            if ($changer_lang = $champs['lang']) {
204
+                $id_rubrique = 0;
205
+                if (isset($desc['field']['id_rubrique'])) {
206
+                    $parent = ($objet == 'rubrique') ? 'id_parent' : 'id_rubrique';
207
+                    $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=" . intval($id_objet));
208
+                }
209
+                $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action');
210
+                $champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur);
211
+            }
212
+            // on laisse 'lang' dans $champs,
213
+            // ca permet de passer dans le pipeline post_edition et de journaliser
214
+            // et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir
215
+            // deja pris en compte
216
+        }
217
+
218
+        // la modif peut avoir lieu
219
+
220
+        // faut-il ajouter date_modif ?
221
+        if (
222
+            !empty($options['date_modif'])
223
+            and !isset($champs[$options['date_modif']])
224
+        ) {
225
+            $champs[$options['date_modif']] = date('Y-m-d H:i:s');
226
+        }
227
+
228
+        // allez on commit la modif
229
+        sql_updateq($spip_table_objet, $champs, "$id_table_objet=" . intval($id_objet), [], $serveur);
230
+
231
+        // on verifie si elle est bien passee
232
+        $moof = sql_fetsel(
233
+            array_keys($champs),
234
+            $spip_table_objet,
235
+            "$id_table_objet=" . intval($id_objet),
236
+            [],
237
+            [],
238
+            '',
239
+            [],
240
+            $serveur
241
+        );
242
+        // si difference entre les champs, reperer les champs mal enregistres
243
+        if ($moof != $champs) {
244
+            $liste = [];
245
+            foreach ($moof as $k => $v) {
246
+                if (
247
+                    $v !== $champs[$k]
248
+                    // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes
249
+                    and (!is_numeric($v) or intval($v) !== intval($champs[$k]))
250
+                    // ne pas alerter si le champ est date, qu'on a envoye une valeur vide et qu'on recupere une date nulle
251
+                    and (strlen($champs[$k]) or !in_array($v, ['0000-00-00 00:00:00', '0000-00-00']))
252
+                ) {
253
+                    $liste[] = $k;
254
+                    $conflits[$k]['post'] = $champs[$k];
255
+                    $conflits[$k]['save'] = $v;
256
+
257
+                    // cas specifique MySQL+emoji : si l'un est la
258
+                    // conversion utf8_noplanes de l'autre alors c'est OK
259
+                    if (defined('_MYSQL_NOPLANES') && _MYSQL_NOPLANES) {
260
+                        include_spip('inc/charsets');
261
+                        if ($v == utf8_noplanes($champs[$k])) {
262
+                            array_pop($liste);
263
+                        }
264
+                    }
265
+                }
266
+            }
267
+            // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur
268
+            // c'est un cas exceptionnel
269
+            if (count($liste)) {
270
+                spip_log(
271
+                    "Erreur enregistrement en base $objet/$id_objet champs :" . var_export($conflits, true),
272
+                    'modifier.' . _LOG_CRITIQUE
273
+                );
274
+
275
+                return _T(
276
+                    'erreur_technique_enregistrement_champs',
277
+                    ['champs' => "<i>'" . implode("'</i>,<i>'", $liste) . "'</i>"]
278
+                );
279
+            }
280
+        }
281
+
282
+        // Invalider les caches
283
+        if (isset($options['invalideur']) and $options['invalideur']) {
284
+            include_spip('inc/invalideur');
285
+            if (is_array($options['invalideur'])) {
286
+                array_map('suivre_invalideur', $options['invalideur']);
287
+            } else {
288
+                suivre_invalideur($options['invalideur']);
289
+            }
290
+        }
291
+
292
+        // Notifications, gestion des revisions...
293
+        // en standard, appelle |nouvelle_revision ci-dessous
294
+        pipeline(
295
+            'post_edition',
296
+            [
297
+                'args' => [
298
+                    'table' => $spip_table_objet,
299
+                    'table_objet' => $table_objet,
300
+                    'spip_table_objet' => $spip_table_objet,
301
+                    'desc' => $desc,
302
+                    'type' => $objet,
303
+                    'id_objet' => $id_objet,
304
+                    'champs' => $options['champs'] ?? [], // [doc] kesako ?
305
+                    'champs_anciens' => $row, // état du contenu avant modif
306
+                    'serveur' => $serveur,
307
+                    'action' => $options['action'] ?? 'modifier'
308
+                ],
309
+                'data' => $champs
310
+            ]
311
+        );
312
+    }
313
+
314
+    // Appeler une notification
315
+    if ($notifications = charger_fonction('notifications', 'inc')) {
316
+        $notifications(
317
+            "{$objet}_modifier",
318
+            $id_objet,
319
+            [
320
+                'champs' => $champs,
321
+            ]
322
+        );
323
+        $notifications(
324
+            'objet_modifier',
325
+            $id_objet,
326
+            [
327
+                'objet' => $objet,
328
+                'id_objet' => $id_objet,
329
+                'champs' => $champs,
330
+            ]
331
+        );
332
+    }
333
+
334
+    // journaliser l'affaire
335
+    // message a affiner :-)
336
+    include_spip('inc/filtres_mini');
337
+    $qui = '';
338
+    if (!empty($GLOBALS['visiteur_session']['id_auteur'])) {
339
+        $qui .= ' #id_auteur:' . $GLOBALS['visiteur_session']['id_auteur'] . '#';
340
+    }
341
+    if (!empty($GLOBALS['visiteur_session']['nom'])) {
342
+        $qui .= ' #nom:' . $GLOBALS['visiteur_session']['nom'] . '#';
343
+    }
344
+    if ($qui == '') {
345
+        $qui = '#ip:' . $GLOBALS['ip'] . '#';
346
+    }
347
+    journal(_L($qui . ' a édité ' . $objet . ' ' . $id_objet . ' (' . join(
348
+        '+',
349
+        array_diff(array_keys($champs), ['date_modif'])
350
+    ) . ')'), [
351
+        'faire' => 'modifier',
352
+        'quoi' => $objet,
353
+        'id' => $id_objet
354
+    ]);
355
+
356
+    return '';
357 357
 }
Please login to merge, or discard this patch.
ecrire/inc/chercher_rubrique.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  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
 if (!defined('_SPIP_SELECT_RUBRIQUES')) {
24
-	/**
25
-	 * @var int Nombre de rubriques maximum du sélecteur de rubriques.
26
-	 * Au delà, on bascule sur un sélecteur ajax.
27
-	 * mettre 100000 pour desactiver ajax
28
-	 */
29
-	define('_SPIP_SELECT_RUBRIQUES', 20);
24
+    /**
25
+     * @var int Nombre de rubriques maximum du sélecteur de rubriques.
26
+     * Au delà, on bascule sur un sélecteur ajax.
27
+     * mettre 100000 pour desactiver ajax
28
+     */
29
+    define('_SPIP_SELECT_RUBRIQUES', 20);
30 30
 }
31 31
 
32 32
 /**
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
  *     Code HTML du sélecteur
55 55
  **/
56 56
 function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
57
-	if (sql_countsel('spip_rubriques') < 1) {
58
-		return '';
59
-	}
60
-
61
-	// Mode sans Ajax :
62
-	// - soit parce que le cookie ajax n'est pas la
63
-	// - soit parce qu'il y a peu de rubriques
64
-	if (
65
-		_SPIP_AJAX < 1
66
-		|| $type == 'breve'
67
-		|| sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
68
-	) {
69
-		return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
70
-	} else {
71
-		return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
72
-	}
57
+    if (sql_countsel('spip_rubriques') < 1) {
58
+        return '';
59
+    }
60
+
61
+    // Mode sans Ajax :
62
+    // - soit parce que le cookie ajax n'est pas la
63
+    // - soit parce qu'il y a peu de rubriques
64
+    if (
65
+        _SPIP_AJAX < 1
66
+        || $type == 'breve'
67
+        || sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
68
+    ) {
69
+        return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
70
+    } else {
71
+        return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
72
+    }
73 73
 }
74 74
 
75 75
 // compatibilite pour extensions qui utilisaient l'ancien nom
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
  **/
87 87
 function style_menu_rubriques($i) {
88 88
 
89
-	$espace = '';
90
-	$style = '';
91
-	for ($count = 1; $count <= $i; $count++) {
92
-		$espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
93
-	}
94
-	if ($i == 1) {
95
-		$espace = '';
96
-	}
97
-	$class = "niveau_$i";
98
-
99
-	return [$class, $style, $espace];
89
+    $espace = '';
90
+    $style = '';
91
+    for ($count = 1; $count <= $i; $count++) {
92
+        $espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
93
+    }
94
+    if ($i == 1) {
95
+        $espace = '';
96
+    }
97
+    $class = "niveau_$i";
98
+
99
+    return [$class, $style, $espace];
100 100
 }
101 101
 
102 102
 /**
@@ -120,57 +120,57 @@  discard block
 block discarded – undo
120 120
  *     Code HTML du sélecteur
121 121
  **/
122 122
 function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) {
123
-	static $decalage_secteur;
124
-
125
-	// Si on a demande l'exclusion ne pas descendre dans la rubrique courante
126
-	if ($exclus > 0 && $root == $exclus) {
127
-		return '';
128
-	}
129
-
130
-	// en fonction du niveau faire un affichage plus ou moins kikoo
131
-
132
-	// selected ?
133
-	$selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
134
-
135
-	// le style en fonction de la profondeur
136
-	[$class, $style, $espace] = style_menu_rubriques($niv);
137
-
138
-	$class .= ' selec_rub';
139
-
140
-	// creer l'<option> pour la rubrique $root
141
-
142
-	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143
-	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144
-			. $data[$root]
145
-			. '</option>' . "\n";
146
-	} else {
147
-		$r = '';
148
-	}
149
-
150
-	// et le sous-menu pour ses enfants
151
-	$sous = '';
152
-	if (isset($enfants[$root])) {
153
-		foreach ($enfants[$root] as $sousrub) {
154
-			$sous .= sous_menu_rubriques(
155
-				$id_rubrique,
156
-				$sousrub,
157
-				$niv + 1,
158
-				$data,
159
-				$enfants,
160
-				$exclus,
161
-				$restreint,
162
-				$type
163
-			);
164
-		}
165
-	}
166
-
167
-	// si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
168
-	if ($restreint && $root != $id_rubrique && !autoriser('publierdans', 'rubrique', $root)) {
169
-		return $sous;
170
-	}
171
-
172
-	// et voila le travail
173
-	return $r . $sous;
123
+    static $decalage_secteur;
124
+
125
+    // Si on a demande l'exclusion ne pas descendre dans la rubrique courante
126
+    if ($exclus > 0 && $root == $exclus) {
127
+        return '';
128
+    }
129
+
130
+    // en fonction du niveau faire un affichage plus ou moins kikoo
131
+
132
+    // selected ?
133
+    $selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
134
+
135
+    // le style en fonction de la profondeur
136
+    [$class, $style, $espace] = style_menu_rubriques($niv);
137
+
138
+    $class .= ' selec_rub';
139
+
140
+    // creer l'<option> pour la rubrique $root
141
+
142
+    if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143
+    $r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144
+            . $data[$root]
145
+            . '</option>' . "\n";
146
+    } else {
147
+        $r = '';
148
+    }
149
+
150
+    // et le sous-menu pour ses enfants
151
+    $sous = '';
152
+    if (isset($enfants[$root])) {
153
+        foreach ($enfants[$root] as $sousrub) {
154
+            $sous .= sous_menu_rubriques(
155
+                $id_rubrique,
156
+                $sousrub,
157
+                $niv + 1,
158
+                $data,
159
+                $enfants,
160
+                $exclus,
161
+                $restreint,
162
+                $type
163
+            );
164
+        }
165
+    }
166
+
167
+    // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
168
+    if ($restreint && $root != $id_rubrique && !autoriser('publierdans', 'rubrique', $root)) {
169
+        return $sous;
170
+    }
171
+
172
+    // et voila le travail
173
+    return $r . $sous;
174 174
 }
175 175
 
176 176
 /**
@@ -191,75 +191,75 @@  discard block
 block discarded – undo
191 191
  *     Code HTML du sélecteur
192 192
  **/
193 193
 function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) {
194
-	$enfants = [];
195
-	$data = [];
196
-	if ($type == 'rubrique' && autoriser('publierdans', 'rubrique', 0)) {
197
-		$data[0] = _T('info_racine_site');
198
-	}
199
-	# premier choix = neant
200
-	# si auteur (rubriques restreintes)
201
-	# ou si creation avec id_rubrique=0
202
-	elseif ($type == 'auteur' || !$id_rubrique) {
203
-		$data[0] = '&nbsp;';
204
-	}
205
-
206
-	//
207
-	// creer une structure contenant toute l'arborescence
208
-	//
209
-
210
-	include_spip('base/abstract_sql');
211
-	$q = sql_select(
212
-		'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
213
-		'spip_rubriques',
214
-		($type == 'breve' ? ' id_parent=0 ' : ''),
215
-		'',
216
-		'0+titre,titre'
217
-	);
218
-	while ($r = sql_fetch($q)) {
219
-		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220
-			// titre largeur maxi a 50
221
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
222
-			if (
223
-				$GLOBALS['meta']['multi_rubriques'] == 'oui'
224
-				&& ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225
-			) {
226
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
227
-			}
228
-			$data[$r['id_rubrique']] = $titre;
229
-			$enfants[$r['id_parent']][] = $r['id_rubrique'];
230
-			if ($id_rubrique == $r['id_rubrique']) {
231
-				$id_parent = $r['id_parent'];
232
-			}
233
-		}
234
-	}
235
-
236
-	// si une seule rubrique comme choix possible,
237
-	// inutile de mettre le selecteur sur un choix vide par defaut
238
-	// sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
239
-	if (
240
-		count($data) == 2
241
-		&& isset($data[0])
242
-		&& !in_array($type, ['auteur', 'rubrique'])
243
-		&& !$id_rubrique
244
-	) {
245
-		unset($data[0]);
246
-	}
247
-
248
-
249
-	$opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
250
-	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251
-
252
-	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
254
-	} else {
255
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
256
-	}
257
-
258
-	# message pour neuneus (a supprimer ?)
194
+    $enfants = [];
195
+    $data = [];
196
+    if ($type == 'rubrique' && autoriser('publierdans', 'rubrique', 0)) {
197
+        $data[0] = _T('info_racine_site');
198
+    }
199
+    # premier choix = neant
200
+    # si auteur (rubriques restreintes)
201
+    # ou si creation avec id_rubrique=0
202
+    elseif ($type == 'auteur' || !$id_rubrique) {
203
+        $data[0] = '&nbsp;';
204
+    }
205
+
206
+    //
207
+    // creer une structure contenant toute l'arborescence
208
+    //
209
+
210
+    include_spip('base/abstract_sql');
211
+    $q = sql_select(
212
+        'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
213
+        'spip_rubriques',
214
+        ($type == 'breve' ? ' id_parent=0 ' : ''),
215
+        '',
216
+        '0+titre,titre'
217
+    );
218
+    while ($r = sql_fetch($q)) {
219
+        if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220
+            // titre largeur maxi a 50
221
+            $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
222
+            if (
223
+                $GLOBALS['meta']['multi_rubriques'] == 'oui'
224
+                && ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225
+            ) {
226
+                $titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
227
+            }
228
+            $data[$r['id_rubrique']] = $titre;
229
+            $enfants[$r['id_parent']][] = $r['id_rubrique'];
230
+            if ($id_rubrique == $r['id_rubrique']) {
231
+                $id_parent = $r['id_parent'];
232
+            }
233
+        }
234
+    }
235
+
236
+    // si une seule rubrique comme choix possible,
237
+    // inutile de mettre le selecteur sur un choix vide par defaut
238
+    // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
239
+    if (
240
+        count($data) == 2
241
+        && isset($data[0])
242
+        && !in_array($type, ['auteur', 'rubrique'])
243
+        && !$id_rubrique
244
+    ) {
245
+        unset($data[0]);
246
+    }
247
+
248
+
249
+    $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
250
+    $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251
+
252
+    if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
+        $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
254
+    } else {
255
+        $r = '<select' . $att . " size='1'>\n$opt</select>\n";
256
+    }
257
+
258
+    # message pour neuneus (a supprimer ?)
259 259
 #	if ($type != 'auteur' AND $type != 'breve')
260 260
 #		$r .= "\n<br />"._T('texte_rappel_selection_champs');
261 261
 
262
-	return $r;
262
+    return $r;
263 263
 }
264 264
 
265 265
 /**
@@ -293,22 +293,22 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
295 295
 
296
-	if ($id_rubrique) {
297
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
298
-	} else {
299
-		$titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300
-	}
296
+    if ($id_rubrique) {
297
+        $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
298
+    } else {
299
+        $titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300
+    }
301 301
 
302
-	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
303
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
302
+    $titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
303
+    $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
304 304
 
305
-	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306
-		. ($idem ? "&exclus=$idem" : '')
307
-		. ($restreint ? '' : '&racine=oui')
308
-		. (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
305
+    $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306
+        . ($idem ? "&exclus=$idem" : '')
307
+        . ($restreint ? '' : '&racine=oui')
308
+        . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
309 309
 
310 310
 
311
-	return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
311
+    return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
312 312
 }
313 313
 
314 314
 /**
@@ -338,30 +338,30 @@  discard block
 block discarded – undo
338 338
  *     Code HTML du sélecteur de rubrique AJAX
339 339
  **/
340 340
 function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) {
341
-	$icone = (str_contains($idom, 'auteur')) ? 'auteur-24.png' : 'rechercher-20.png';
342
-	// si icone de recherche on embed le svg
343
-	$balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
344
-	$img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur'));
345
-
346
-	return
347
-		"<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
348
-		. $js
349
-		. " jQuery(this).toggleClass('toggled'); "
350
-		. "return charger_node_url_si_vide('"
351
-		. $url
352
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
353
-		. $img_icone
354
-		. "</a><img src='"
355
-		. chemin_image('loader.svg')
356
-		. "' class='loader' id='img_"
357
-		. $idom
358
-		. "'\nstyle='visibility: hidden;' alt='*' />"
359
-		. "<input id='titreparent' name='titreparent' class='text'"
360
-		. $init
361
-		. ' />'
362
-		. "<input type='hidden' id='$name' name='$name' value='"
363
-		. $id
364
-		. "' /><div class='nettoyeur'></div></div><div id='"
365
-		. $idom
366
-		. "'\nstyle='display: none;'></div>";
341
+    $icone = (str_contains($idom, 'auteur')) ? 'auteur-24.png' : 'rechercher-20.png';
342
+    // si icone de recherche on embed le svg
343
+    $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
344
+    $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur'));
345
+
346
+    return
347
+        "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
348
+        . $js
349
+        . " jQuery(this).toggleClass('toggled'); "
350
+        . "return charger_node_url_si_vide('"
351
+        . $url
352
+        . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
353
+        . $img_icone
354
+        . "</a><img src='"
355
+        . chemin_image('loader.svg')
356
+        . "' class='loader' id='img_"
357
+        . $idom
358
+        . "'\nstyle='visibility: hidden;' alt='*' />"
359
+        . "<input id='titreparent' name='titreparent' class='text'"
360
+        . $init
361
+        . ' />'
362
+        . "<input type='hidden' id='$name' name='$name' value='"
363
+        . $id
364
+        . "' /><div class='nettoyeur'></div></div><div id='"
365
+        . $idom
366
+        . "'\nstyle='display: none;'></div>";
367 367
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143 143
 	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144 144
 			. $data[$root]
145
-			. '</option>' . "\n";
145
+			. '</option>'."\n";
146 146
 	} else {
147 147
 		$r = '';
148 148
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	// et voila le travail
173
-	return $r . $sous;
173
+	return $r.$sous;
174 174
 }
175 175
 
176 176
 /**
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 	while ($r = sql_fetch($q)) {
219 219
 		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220 220
 			// titre largeur maxi a 50
221
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
221
+			$titre = couper(supprimer_tags(typo($r['titre'])).' ', 50);
222 222
 			if (
223 223
 				$GLOBALS['meta']['multi_rubriques'] == 'oui'
224 224
 				&& ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225 225
 			) {
226
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
226
+				$titre .= ' ['.traduire_nom_langue($r['lang']).']';
227 227
 			}
228 228
 			$data[$r['id_rubrique']] = $titre;
229 229
 			$enfants[$r['id_parent']][] = $r['id_rubrique'];
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251 251
 
252 252
 	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
253
+		$r = "<input$att type='hidden' value='".$r[1]."' />".$r[2];
254 254
 	} else {
255
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
255
+		$r = '<select'.$att." size='1'>\n$opt</select>\n";
256 256
 	}
257 257
 
258 258
 	# message pour neuneus (a supprimer ?)
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
295 295
 
296 296
 	if ($id_rubrique) {
297
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
297
+		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique='.(int) $id_rubrique);
298 298
 	} else {
299 299
 		$titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300 300
 	}
301 301
 
302 302
 	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
303
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
303
+	$init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'";
304 304
 
305 305
 	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306 306
 		. ($idem ? "&exclus=$idem" : '')
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 		. " jQuery(this).toggleClass('toggled'); "
350 350
 		. "return charger_node_url_si_vide('"
351 351
 		. $url
352
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
352
+		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>"
353 353
 		. $img_icone
354 354
 		. "</a><img src='"
355 355
 		. chemin_image('loader.svg')
Please login to merge, or discard this patch.
ecrire/inc/completer_traduction.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -28,51 +28,51 @@  discard block
 block discarded – undo
28 28
  * @return string Erreur éventuelle
29 29
  */
30 30
 function inc_completer_traduction_dist($objet, $id_objet, $id_trad) {
31
-	// dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit
32
-	// cf API editer_liens
33
-	include_spip('action/editer_liens');
34
-	objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']);
35
-	$_id_table = id_table_objet($objet);
31
+    // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit
32
+    // cf API editer_liens
33
+    include_spip('action/editer_liens');
34
+    objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']);
35
+    $_id_table = id_table_objet($objet);
36 36
 
37
-	// recuperer le logo
38
-	$chercher_logo = charger_fonction('chercher_logo', 'inc');
39
-	include_spip('action/editer_logo');
40
-	foreach (['on', 'off'] as $etat) {
41
-		$logo = $chercher_logo($id_trad, $_id_table, $etat);
42
-		if ($logo && ($file = reset($logo))) {
43
-			logo_modifier($objet, $id_objet, $etat, $file);
44
-		}
45
-	}
37
+    // recuperer le logo
38
+    $chercher_logo = charger_fonction('chercher_logo', 'inc');
39
+    include_spip('action/editer_logo');
40
+    foreach (['on', 'off'] as $etat) {
41
+        $logo = $chercher_logo($id_trad, $_id_table, $etat);
42
+        if ($logo && ($file = reset($logo))) {
43
+            logo_modifier($objet, $id_objet, $etat, $file);
44
+        }
45
+    }
46 46
 
47
-	// dupliquer certains champs
48
-	$trouver_table = charger_fonction('trouver_table', 'base');
49
-	$desc = $trouver_table(table_objet_sql($objet));
50
-	$champs = $set = [];
47
+    // dupliquer certains champs
48
+    $trouver_table = charger_fonction('trouver_table', 'base');
49
+    $desc = $trouver_table(table_objet_sql($objet));
50
+    $champs = $set = [];
51 51
 
52
-	// un éventuel champ 'virtuel' (redirections)
53
-	if (!empty($desc['field']['virtuel'])) {
54
-		$champs[] = 'virtuel';
55
-	}
52
+    // un éventuel champ 'virtuel' (redirections)
53
+    if (!empty($desc['field']['virtuel'])) {
54
+        $champs[] = 'virtuel';
55
+    }
56 56
 
57
-	$data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
57
+    $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
58 58
 
59
-	foreach ($champs as $c) {
60
-		$set[$c] = $data[$c];
61
-	}
59
+    foreach ($champs as $c) {
60
+        $set[$c] = $data[$c];
61
+    }
62 62
 
63
-	/*
63
+    /*
64 64
 	 * Le pipeline 'pre_edition' sera appelé avec l'action 'completer_traduction'.
65 65
 	 * Des plugins pourront ainsi compléter les champs d'un objet traduit lors d'une nouvelle traduction.
66 66
 	 */
67
-	$err = objet_modifier_champs(
68
-		$objet,
69
-		$id_objet,
70
-		[
71
-			'data' => $data,
72
-			'action' => 'completer_traduction',
73
-		],
74
-		$set
75
-	);
67
+    $err = objet_modifier_champs(
68
+        $objet,
69
+        $id_objet,
70
+        [
71
+            'data' => $data,
72
+            'action' => 'completer_traduction',
73
+        ],
74
+        $set
75
+    );
76 76
 
77
-	return $err;
77
+    return $err;
78 78
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 		$champs[] = 'virtuel';
55 55
 	}
56 56
 
57
-	$data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
57
+	$data = sql_fetsel('*', $desc['table'], $_id_table.'='.(int) $id_trad);
58 58
 
59 59
 	foreach ($champs as $c) {
60 60
 		$set[$c] = $data[$c];
Please login to merge, or discard this patch.