1 | <?php |
---|
2 | |
---|
3 | include_spip('inc/config'); |
---|
4 | include_spip('inc/texte'); |
---|
5 | |
---|
6 | function nettoyer_structure ($structure) { |
---|
7 | $resultat = array(); |
---|
8 | foreach ($structure as $item) { |
---|
9 | $pas_vide = False; |
---|
10 | foreach ($item as $cle => $val) { |
---|
11 | if ($val !== '') { |
---|
12 | $pas_vide = True; |
---|
13 | if (($cle == 'titre') || ($cle == 'texte_ancre')) { |
---|
14 | $item[$cle] = typo($val); |
---|
15 | } else if (($cle == 'cible') || ($cle == 'class')) { |
---|
16 | $item[$cle] = preg_replace('/[#.]/', '', $val); |
---|
17 | } |
---|
18 | } |
---|
19 | } |
---|
20 | if ($pas_vide) { |
---|
21 | $resultat[] = $item; |
---|
22 | } |
---|
23 | } |
---|
24 | return $resultat; |
---|
25 | } |
---|
26 | |
---|
27 | function permuter_structure ($structure, $permutation) { |
---|
28 | |
---|
29 | if ($permutation == '') { |
---|
30 | $permutation = implode(',', range(0, count($structure))); |
---|
31 | } |
---|
32 | |
---|
33 | $permutation = explode(',', $permutation); |
---|
34 | $resultat = array(); |
---|
35 | foreach ($permutation as $val) { |
---|
36 | $resultat[] = $structure[$val]; |
---|
37 | } |
---|
38 | return $resultat; |
---|
39 | } |
---|
40 | |
---|
41 | function formulaires_configurer_menu_evitement_charger () { |
---|
42 | |
---|
43 | return lire_config('menu_evitement'); |
---|
44 | } |
---|
45 | |
---|
46 | function formulaires_configurer_menu_evitement_traiter () { |
---|
47 | |
---|
48 | $post = array( |
---|
49 | 'lien_vers_menu_admin' => _request('lien_vers_menu_admin'), |
---|
50 | 'cacher_menu_quand_pas_focus' => _request('cacher_menu_quand_pas_focus'), |
---|
51 | 'cacher_ancres_quand_pas_focus' => _request('cacher_ancres_quand_pas_focus'), |
---|
52 | 'structure' => nettoyer_structure( |
---|
53 | permuter_structure( |
---|
54 | _request('structure'), |
---|
55 | _request('permutation-structures')) |
---|
56 | ), |
---|
57 | ); |
---|
58 | |
---|
59 | ecrire_config('menu_evitement', $post); |
---|
60 | |
---|
61 | return array( |
---|
62 | 'editable' => true, |
---|
63 | 'message_ok' => 'Donnees Enregistrees', |
---|
64 | ); |
---|
65 | } |
---|
66 | |
---|
67 | ?> |
---|