[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / noiZetier / noizetier_ieconfig.php
1 <?php
2 if (!defined("_ECRIRE_INC_VERSION")) return;
3
4 /**
5 * Pipeline ieconfig pour l'import/export de configuration
6 *
7 * @param array $flux
8 * @return array
9 */
10 function noizetier_ieconfig($flux){
11 $action = $flux['args']['action'];
12
13 // Formulaire d'export
14 if ($action=='form_export') {
15 $saisies = array(
16 array(
17 'saisie' => 'fieldset',
18 'options' => array(
19 'nom' => 'noizetier_export',
20 'label' => '<:noizetier:editer_noizetier_titre:>',
21 'icone' => 'img/noizetier-24.png'
22 ),
23 'saisies' => array(
24 array(
25 'saisie' => 'explication',
26 'options' => array(
27 'nom' => 'noizetier_export_explication',
28 'texte' => '<:noizetier:ieconfig_noizetier_export_explication:>'
29 )
30 ),
31 array(
32 'saisie' => 'oui_non',
33 'options' => array(
34 'nom' => 'noizetier_export_option',
35 'label' => '<:noizetier:ieconfig_noizetier_export_option:>',
36 'defaut' => ''
37 )
38 )
39 )
40 )
41 );
42 $flux['data'] = array_merge($flux['data'],$saisies);
43 }
44
45 // Tableau d'export
46 if ($action=='export' && _request('noizetier_export_option')=='on') {
47 include_spip('inc/noizetier');
48 $flux['data']['noizetier'] = noizetier_tableau_export();
49 }
50
51 // Formulaire d'import
52 if ($action=='form_import' && isset($flux['args']['config']['noizetier'])) {
53 $texte_explication = '';
54 if (isset($flux['args']['config']['noizetier']['noisettes'])) {
55 $texte_explication .= _T('noizetier:formulaire_liste_pages_config');
56 $pages = array();
57 foreach($flux['args']['config']['noizetier']['noisettes'] as $noisette)
58 $pages[] = $noisette['type'].'-'.$noisette['composition'];
59 $pages = array_unique($pages);
60 foreach ($pages as $page)
61 $texte_explication .= '<br />&raquo; '.rtrim($page,'-');
62 }
63 if (isset($flux['args']['config']['noizetier']['noizetier_compositions'])) {
64 $texte_explication .= '<br />'._T('noizetier:formulaire_liste_compos_config');
65 foreach($flux['args']['config']['noizetier']['noizetier_compositions'] as $type => $compositions)
66 foreach ($compositions as $composition => $compo)
67 $texte_explication .= '<br />&raquo; '.$type.'-'.$composition;
68 }
69 if (isset($flux['args']['config']['noizetier']['noizetier_compositions'])) {
70 $saisies = array(
71 array(
72 'saisie' => 'fieldset',
73 'options' => array(
74 'nom' => 'noizetier_export',
75 'label' => '<:noizetier:editer_noizetier_titre:>',
76 'icone' => 'img/noizetier-24.png'
77 ),
78 'saisies' => array(
79 array(
80 'saisie' => 'explication',
81 'options' => array(
82 'nom' => 'noizetier_export_explication',
83 'texte' => $texte_explication
84 )
85 ),
86 array(
87 'saisie' => 'selection',
88 'options' => array(
89 'nom' => 'noizetier_type_import',
90 'label' => '<:noizetier:formulaire_type_import:>',
91 'explication' => '<:noizetier:formulaire_type_import_explication:>',
92 'defaut' => '',
93 'option_intro' => '<:noizetier:ieconfig_ne_pas_importer:>',
94 'datas' => array(
95 'fusion' => '<:noizetier:formulaire_import_fusion:>',
96 'remplacer' => '<:noizetier:formulaire_import_remplacer:>'
97 )
98 )
99 ),
100 array(
101 'saisie' => 'selection',
102 'options' => array(
103 'nom' => 'noizetier_import_compos',
104 'label' => '<:noizetier:formulaire_import_compos:>',
105 'defaut' => 'oui',
106 'cacher_option_intro' => 'oui',
107 'datas' => array(
108 'oui' => '<:noizetier:oui:>',
109 'non' => '<:noizetier:non:>'
110 )
111 )
112 )
113 )
114 )
115 );
116 } else {
117 $saisies = array(
118 array(
119 'saisie' => 'fieldset',
120 'options' => array(
121 'nom' => 'noizetier_export',
122 'label' => '<:noizetier:editer_noizetier_titre:>',
123 'icone' => 'img/noizetier-24.png'
124 ),
125 'saisies' => array(
126 array(
127 'saisie' => 'explication',
128 'options' => array(
129 'nom' => 'noizetier_export_explication',
130 'texte' => $texte_explication
131 )
132 ),
133 array(
134 'saisie' => 'selection',
135 'options' => array(
136 'nom' => 'noizetier_type_import',
137 'label' => '<:noizetier:formulaire_type_import:>',
138 'explication' => '<:noizetier:formulaire_type_import_explication:>',
139 'defaut' => '',
140 'option_intro' => '<:noizetier:ieconfig_ne_pas_importer:>',
141 'datas' => array(
142 'fusion' => '<:noizetier:formulaire_import_fusion:>',
143 'remplacer' => '<:noizetier:formulaire_import_remplacer:>'
144 )
145 )
146 ),
147 array(
148 'saisie' => 'hidden',
149 'options' => array(
150 'nom' => 'noizetier_import_compos',
151 'defaut' => 'non',
152 )
153 )
154 )
155 )
156 );
157 }
158 $flux['data'] = array_merge($flux['data'],$saisies);
159 }
160
161 // Import de la configuration
162 if ($action=='import' && isset($flux['args']['config']['noizetier']) && _request('noizetier_type_import')!='') {
163 include_spip('inc/noizetier');
164 if (!noizetier_importer_configuration(_request('noizetier_type_import'),_request('noizetier_import_compos'),$flux['args']['config']['noizetier']))
165 $flux['data'] .= _T('noizetier:ieconfig_probleme_import_config').'<br />';
166 }
167
168 return($flux);
169 }
170
171 ?>