1 | <?php |
---|
2 | |
---|
3 | // --------------------------------------------------------------------- |
---|
4 | // |
---|
5 | // Sktheme : manage themes under SPIP (squelettes + habillages) |
---|
6 | // |
---|
7 | // Copyright (c) 2006 - Skedus |
---|
8 | // |
---|
9 | // This program is free software; you can redistribute it and/or modify |
---|
10 | // it under the terms of the GNU General Public License as published by |
---|
11 | // the Free Software Foundation; either version 2 of the License, or |
---|
12 | // (at your option) any later version. |
---|
13 | // |
---|
14 | // You should have received a copy of the GNU General Public License |
---|
15 | // along with this program; |
---|
16 | // |
---|
17 | // --------------------------------------------------------------------- |
---|
18 | |
---|
19 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
20 | |
---|
21 | include_spip('inc/presentation'); // for spip presentation functions |
---|
22 | include_spip('inc/layer'); // for spip layer functions |
---|
23 | include_spip('inc/utils'); // for _request function |
---|
24 | include_spip('inc/plugin'); // xml function |
---|
25 | include_spip('inc/sktheme_util'); // for sktheme_* functions |
---|
26 | include_spip('inc/sktheme_xml'); // for sktheme_* functions |
---|
27 | |
---|
28 | |
---|
29 | // |
---|
30 | // Public page choice definition |
---|
31 | // |
---|
32 | function exec_sktheme_public_choice() { |
---|
33 | |
---|
34 | global $squelette_public_name; // parameter |
---|
35 | global $habillage_public_name; // parameter |
---|
36 | |
---|
37 | // Get the specific action to do if some |
---|
38 | $sktheme_action = _request('sktheme_action'); |
---|
39 | $original = _T('sktheme:original'); |
---|
40 | |
---|
41 | debut_page(_T('sktheme:public_theme_choice'),'configuration','sktheme_public_choice'); |
---|
42 | |
---|
43 | echo "<br />"; |
---|
44 | gros_titre(_T('sktheme:public_theme_choice')); |
---|
45 | |
---|
46 | // Include 'onglets' |
---|
47 | sktheme_public_choice_onglets(); |
---|
48 | |
---|
49 | debut_gauche(); |
---|
50 | |
---|
51 | // download a squelette distribution |
---|
52 | // debut_cadre_gris_clair(); |
---|
53 | // echo '<form action="' . generer_url_action("sktheme_install") .'" method="post">'; |
---|
54 | // echo '<strong>'._T('sktheme:zip_squelette_url').' : </strong>'; |
---|
55 | // echo '<input type="text" name="zip_url" size="25" value="http://">'; |
---|
56 | // echo '<input type="hidden" name="zip_type" value="squelette" />'; |
---|
57 | // echo '<input type="submit" value="Download" />'; |
---|
58 | // echo '</form>'; |
---|
59 | // fin_cadre_gris_clair(); |
---|
60 | |
---|
61 | // download a habillage distribution |
---|
62 | // debut_cadre_gris_clair(); |
---|
63 | // echo '<form action="' . generer_url_action("sktheme_install") .'" method="post">'; |
---|
64 | // echo '<strong>'._T('sktheme:zip_habillage_url').' : </strong>'; |
---|
65 | // echo '<input type="text" name="zip_url" size="25" value="http://">'; |
---|
66 | // echo '<input type="hidden" name="zip_type" value="habillage" />'; |
---|
67 | // echo '<input type="submit" value="Download" />'; |
---|
68 | // echo '</form>'; |
---|
69 | // fin_cadre_gris_clair(); |
---|
70 | |
---|
71 | // Include 'raccourcis' |
---|
72 | sktheme_public_theme_doc_box(); |
---|
73 | |
---|
74 | debut_droite(); |
---|
75 | |
---|
76 | // |
---|
77 | // Choose Squelette |
---|
78 | $s_dir = _DIR_RACINE.$GLOBALS['meta']['sktheme_squelettes_public_dir']; |
---|
79 | debut_cadre_trait_couleur('', false, "sktheme_public_squelette_list", |
---|
80 | _T('sktheme:available_squelette_list')." : ".$GLOBALS['meta']['sktheme_squelettes_public_dir']); |
---|
81 | |
---|
82 | $squelettes_list = array('dist' => '' ); |
---|
83 | if (is_dir($s_dir)) { |
---|
84 | if ($dh = opendir($s_dir)) { |
---|
85 | while (($dir = readdir($dh)) !== false) { |
---|
86 | if ( (is_dir($s_dir."/".$dir)) AND ($dir[0]!=".") ) { |
---|
87 | // Check if a theme.xml exists and if the type is squelettes |
---|
88 | if (is_file($s_dir."/".$dir."/theme.xml")) { |
---|
89 | $s_info = sktheme_xml_get_infos($s_dir."/".$dir,"theme"); |
---|
90 | $type = (isset($s_info['type'])) ? propre($s_info['type']) : ""; |
---|
91 | if ($type == 'squelettes') { |
---|
92 | $squelettes_list[$dir]=$s_dir."/".$dir; |
---|
93 | } |
---|
94 | } |
---|
95 | } |
---|
96 | } |
---|
97 | closedir($dh); |
---|
98 | } |
---|
99 | } else { |
---|
100 | echo _T('sktheme:no_available_squelette'); |
---|
101 | } |
---|
102 | |
---|
103 | // Save if needed |
---|
104 | if ($sktheme_action=="set_squelette") { |
---|
105 | echo _T('sktheme:update_squelette_to') . $squelette_public_name. "<br />"; |
---|
106 | ecrire_meta('sktheme_squelette_public_name',$squelette_public_name); |
---|
107 | // Set habillage to the original one when squelette is changed |
---|
108 | ecrire_meta('sktheme_habillage_public_name',$original); |
---|
109 | ecrire_metas(); |
---|
110 | } else { |
---|
111 | $squelette_public_name = $GLOBALS['meta']['sktheme_squelette_public_name']; |
---|
112 | } |
---|
113 | |
---|
114 | echo '<br />'; |
---|
115 | echo '<form action="'.generer_url_ecrire("sktheme_public_choice", "sktheme_action=set_squelette").'" method="post">'; |
---|
116 | foreach( $squelettes_list as $key => $value) { |
---|
117 | $s_info = sktheme_xml_get_infos($value,"theme"); |
---|
118 | echo debut_cadre_gris_clair(); |
---|
119 | echo $s_info['extra_img_puce']; |
---|
120 | if ($squelette_public_name==$key) { |
---|
121 | echo '<input type="radio" name="squelette_public_name" value="'.$key.'" checked="checked" />'; |
---|
122 | $o_info = $s_info; |
---|
123 | } else { |
---|
124 | echo '<input type="radio" name="squelette_public_name" value="'.$key.'" />'; |
---|
125 | } |
---|
126 | echo bouton_block_invisible("$key"); |
---|
127 | echo "<strong>$key</strong>"; |
---|
128 | echo debut_block_invisible("$key"); |
---|
129 | echo _T('version') .' '. $s_info['version'] . " | <strong>".$s_info['extra_titre_etat']."</strong><br />"; |
---|
130 | if (isset($s_info['description'])) |
---|
131 | echo "<hr />" . propre($s_info['description']) . "<br />"; |
---|
132 | if (isset($s_info['auteur'])) |
---|
133 | echo "<hr />" . _T('auteur') .' '. propre($s_info['auteur']) . "<br />"; |
---|
134 | if (isset($s_info['lien'])) |
---|
135 | echo "<hr />" . _T('info_url') .' '. propre($s_info['lien']) . "<br />"; |
---|
136 | echo fin_block(); |
---|
137 | echo fin_cadre_gris_clair(); |
---|
138 | } |
---|
139 | echo '<br />'; |
---|
140 | echo '<div><div style="text-align:right"><input type="submit" value="'._T('sktheme:save_squelette').'"></div></div>'; |
---|
141 | echo '</form>'; |
---|
142 | |
---|
143 | |
---|
144 | fin_cadre_trait_couleur(); |
---|
145 | |
---|
146 | // |
---|
147 | // Choose Habillage |
---|
148 | $h_dir = _DIR_RACINE.$GLOBALS['meta']['sktheme_habillages_public_dir']; |
---|
149 | debut_cadre_trait_couleur('', false, "sktheme_public_habillage_list", |
---|
150 | _T('sktheme:available_habillage_list')." : ".$GLOBALS['meta']['sktheme_habillages_public_dir']); |
---|
151 | |
---|
152 | |
---|
153 | $habillages_list = array($original => ''); |
---|
154 | if (is_dir($h_dir)) { |
---|
155 | if ($dh = opendir($h_dir)) { |
---|
156 | while (($dir = readdir($dh)) !== false) { |
---|
157 | if ( (is_dir($h_dir."/".$dir)) AND ($dir[0]!=".") ) { |
---|
158 | // Check if a theme.xml exists and if the type is themes |
---|
159 | if (is_file($h_dir."/".$dir."/theme.xml")) { |
---|
160 | $h_info = sktheme_xml_get_infos($h_dir."/".$dir,"theme"); |
---|
161 | $type = (isset($h_info['type'])) ? propre($h_info['type']) : ""; |
---|
162 | if ($type == 'themes') { |
---|
163 | $habillages_list[$dir]=$h_dir."/".$dir; |
---|
164 | } |
---|
165 | } |
---|
166 | } |
---|
167 | } |
---|
168 | closedir($dh); |
---|
169 | } |
---|
170 | } else { |
---|
171 | echo _T('sktheme:no_available_habillage'); |
---|
172 | } |
---|
173 | |
---|
174 | // Save habillage if needed |
---|
175 | if ($sktheme_action=="set_habillage") { |
---|
176 | echo _T('sktheme:update_habillage_to') . $habillage_public_name . "<br />"; |
---|
177 | ecrire_meta('sktheme_habillage_public_name',$habillage_public_name); |
---|
178 | ecrire_metas(); |
---|
179 | } else { |
---|
180 | $habillage_public_name = $GLOBALS['meta']['sktheme_habillage_public_name']; |
---|
181 | } |
---|
182 | |
---|
183 | echo '<br />'; |
---|
184 | echo '<form action="'.generer_url_ecrire("sktheme_public_choice", "sktheme_action=set_habillage").'" method="post">'; |
---|
185 | foreach( $habillages_list as $key => $value) { |
---|
186 | $h_info = sktheme_xml_get_infos($value,"theme"); |
---|
187 | |
---|
188 | // Check if habillage is available for this squelette selection |
---|
189 | // probably better way to do it in php (such grep perl function ? but its |
---|
190 | // works anyway) |
---|
191 | $squelette_ok = false; |
---|
192 | if (is_array($h_info['squelettes'])) { |
---|
193 | foreach ($h_info['squelettes'] as $sq){ |
---|
194 | $sq = trim($sq); |
---|
195 | if ($sq == $squelette_public_name) { |
---|
196 | $squelette_ok = true; |
---|
197 | } |
---|
198 | } |
---|
199 | } else { |
---|
200 | if ($h_info['squelettes'] == $squelette_public_name) { |
---|
201 | $squelette_ok = true; |
---|
202 | } |
---|
203 | } |
---|
204 | |
---|
205 | if (($key == $original)||($squelette_ok)) { |
---|
206 | echo debut_cadre_gris_clair(); |
---|
207 | if ($key == $original) { |
---|
208 | echo $o_info['extra_img_puce']; |
---|
209 | } else { |
---|
210 | echo $h_info['extra_img_puce']; |
---|
211 | } |
---|
212 | if ($habillage_public_name==$key) { |
---|
213 | echo '<input type=radio name="habillage_public_name" value="'.$key.'" checked="checked" />'; |
---|
214 | } else { |
---|
215 | echo '<input type=radio name="habillage_public_name" value="'.$key.'" />'; |
---|
216 | } |
---|
217 | echo bouton_block_invisible("$key"); |
---|
218 | if ($key == $original) { |
---|
219 | echo "<strong><i>$key (".$o_info['nom'].")</i></strong>"; |
---|
220 | echo debut_block_invisible("$key"); |
---|
221 | echo _T('version') .' '. $o_info['version'] . " | <strong>".$o_info['extra_titre_etat']."</strong><br />"; |
---|
222 | if (isset($o_info['description'])) |
---|
223 | echo "<hr />" . propre($o_info['description']) . "<br />"; |
---|
224 | if (isset($o_info['auteur'])) |
---|
225 | echo "<hr />" . _T('auteur') .' '. propre($o_info['auteur']) . "<br />"; |
---|
226 | if (isset($o_info['lien'])) |
---|
227 | echo "<hr />" . _T('info_url') .' '. propre($o_info['lien']) . "<br />"; |
---|
228 | |
---|
229 | } else { |
---|
230 | echo "<strong>$key</strong>"; |
---|
231 | echo debut_block_invisible("$key"); |
---|
232 | echo _T('version') .' '. $h_info['version'] . " | <strong>".$h_info['extra_titre_etat']."</strong><br />"; |
---|
233 | if (isset($h_info['description'])) |
---|
234 | echo "<hr />" . propre($h_info['description']) . "<br />"; |
---|
235 | if (isset($h_info['auteur'])) |
---|
236 | echo "<hr />" . _T('auteur') .' '. propre($h_info['auteur']) . "<br />"; |
---|
237 | if (isset($h_info['lien'])) |
---|
238 | echo "<hr />" . _T('info_url') .' '. propre($h_info['lien']) . "<br />"; |
---|
239 | } |
---|
240 | echo fin_block(); |
---|
241 | echo fin_cadre_gris_clair(); |
---|
242 | } |
---|
243 | } |
---|
244 | |
---|
245 | echo '<br />'; |
---|
246 | echo '<div><div align="right"><input type="submit" value="'._t('sktheme:save_habillage').'"></div></div>'; |
---|
247 | echo '</form>'; |
---|
248 | |
---|
249 | fin_cadre_trait_couleur(); |
---|
250 | |
---|
251 | |
---|
252 | |
---|
253 | |
---|
254 | fin_page(); |
---|
255 | |
---|
256 | } |
---|
257 | |
---|
258 | |
---|
259 | ?> |
---|