[30] | 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 | echo "<small><a href='?exec=sktheme_config'>Configuration</a> | <a href='?exec=sktheme_doc'>Documentation</a></small><br />"; |
---|
| 46 | |
---|
| 47 | // Include 'onglets' |
---|
| 48 | sktheme_public_choice_onglets(); |
---|
| 49 | |
---|
| 50 | debut_gauche(); |
---|
| 51 | |
---|
| 52 | // download a squelette distribution |
---|
| 53 | // debut_cadre_gris_clair(); |
---|
| 54 | // echo '<form action="' . generer_url_action("sktheme_install") .'" method="post">'; |
---|
| 55 | // echo '<strong>'._T('sktheme:zip_squelette_url').' : </strong>'; |
---|
| 56 | // echo '<input type="text" name="zip_url" size="25" value="http://">'; |
---|
| 57 | // echo '<input type="hidden" name="zip_type" value="squelette" />'; |
---|
| 58 | // echo '<input type="submit" value="Download" />'; |
---|
| 59 | // echo '</form>'; |
---|
| 60 | // fin_cadre_gris_clair(); |
---|
| 61 | |
---|
| 62 | // download a habillage distribution |
---|
| 63 | // debut_cadre_gris_clair(); |
---|
| 64 | // echo '<form action="' . generer_url_action("sktheme_install") .'" method="post">'; |
---|
| 65 | // echo '<strong>'._T('sktheme:zip_habillage_url').' : </strong>'; |
---|
| 66 | // echo '<input type="text" name="zip_url" size="25" value="http://">'; |
---|
| 67 | // echo '<input type="hidden" name="zip_type" value="habillage" />'; |
---|
| 68 | // echo '<input type="submit" value="Download" />'; |
---|
| 69 | // echo '</form>'; |
---|
| 70 | // fin_cadre_gris_clair(); |
---|
| 71 | |
---|
| 72 | // Include 'raccourcis' |
---|
| 73 | sktheme_public_theme_doc_box(); |
---|
| 74 | |
---|
| 75 | debut_droite(); |
---|
| 76 | |
---|
| 77 | // |
---|
| 78 | // Choose Squelette |
---|
| 79 | $s_dir = _DIR_RACINE.$GLOBALS['meta']['sktheme_squelettes_public_dir']; |
---|
| 80 | debut_cadre_trait_couleur('', false, "sktheme_public_squelette_list", |
---|
| 81 | _T('sktheme:available_squelette_list')." : ".$GLOBALS['meta']['sktheme_squelettes_public_dir']); |
---|
| 82 | |
---|
| 83 | $squelettes_list = array('dist' => '' ); |
---|
| 84 | if (is_dir($s_dir)) { |
---|
| 85 | if ($dh = opendir($s_dir)) { |
---|
| 86 | while (($dir = readdir($dh)) !== false) { |
---|
| 87 | if ( (is_dir($s_dir."/".$dir)) AND ($dir[0]!=".") ) { |
---|
| 88 | // Check if a theme.xml exists and if the type is squelettes |
---|
| 89 | if (is_file($s_dir."/".$dir."/theme.xml")) { |
---|
| 90 | $s_info = sktheme_xml_get_infos($s_dir."/".$dir,"theme"); |
---|
| 91 | $type = (isset($s_info['type'])) ? propre($s_info['type']) : ""; |
---|
| 92 | if ($type == 'squelettes') { |
---|
| 93 | $squelettes_list[$dir]=$s_dir."/".$dir; |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | closedir($dh); |
---|
| 99 | } |
---|
| 100 | } else { |
---|
| 101 | echo _T('sktheme:no_available_squelette'); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | // Save if needed |
---|
| 105 | if ($sktheme_action=="set_squelette") { |
---|
| 106 | echo _T('sktheme:update_squelette_to') . $squelette_public_name. "<br />"; |
---|
| 107 | ecrire_meta('sktheme_squelette_public_name',$squelette_public_name); |
---|
| 108 | // Set habillage to the original one when squelette is changed |
---|
| 109 | ecrire_meta('sktheme_habillage_public_name',$original); |
---|
| 110 | ecrire_metas(); |
---|
| 111 | } else { |
---|
| 112 | $squelette_public_name = $GLOBALS['meta']['sktheme_squelette_public_name']; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | echo '<br />'; |
---|
| 116 | echo '<form action="'.generer_url_ecrire("sktheme_public_choice", "sktheme_action=set_squelette").'" method="post">'; |
---|
| 117 | foreach( $squelettes_list as $key => $value) { |
---|
| 118 | $s_info = sktheme_xml_get_infos($value,"theme"); |
---|
| 119 | echo debut_cadre('gris_clair'); |
---|
| 120 | echo $s_info['extra_img_puce']; |
---|
| 121 | if ($squelette_public_name==$key) { |
---|
| 122 | echo '<input type="radio" name="squelette_public_name" value="'.$key.'" checked="checked" />'; |
---|
| 123 | $o_info = $s_info; |
---|
| 124 | } else { |
---|
| 125 | echo '<input type="radio" name="squelette_public_name" value="'.$key.'" />'; |
---|
| 126 | } |
---|
| 127 | echo bouton_block_invisible("$key"); |
---|
| 128 | echo "<strong>$key</strong>"; |
---|
| 129 | echo debut_block_invisible("$key"); |
---|
| 130 | echo _T('version') .' '. $s_info['version'] . " | <strong>".$s_info['extra_titre_etat']."</strong><br />"; |
---|
| 131 | if (isset($s_info['description'])) |
---|
| 132 | echo "<hr />" . propre($s_info['description']) . "<br />"; |
---|
| 133 | if (isset($s_info['auteur'])) |
---|
| 134 | echo "<hr />" . _T('auteur') .' '. propre($s_info['auteur']) . "<br />"; |
---|
| 135 | if (isset($s_info['lien'])) |
---|
| 136 | echo "<hr />" . _T('info_url') .' '. propre($s_info['lien']) . "<br />"; |
---|
| 137 | echo fin_block(); |
---|
| 138 | echo fin_cadre('gris_clair'); |
---|
| 139 | } |
---|
| 140 | echo '<br />'; |
---|
| 141 | echo '<div><div style="text-align:right"><input type="submit" value="'._T('sktheme:save_squelette').'"></div></div>'; |
---|
| 142 | echo '</form>'; |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | fin_cadre_trait_couleur(); |
---|
| 146 | |
---|
| 147 | // |
---|
| 148 | // Choose Habillage |
---|
| 149 | $h_dir = _DIR_RACINE.$GLOBALS['meta']['sktheme_habillages_public_dir']; |
---|
| 150 | debut_cadre_trait_couleur('', false, "sktheme_public_habillage_list", |
---|
| 151 | _T('sktheme:available_habillage_list')." : ".$GLOBALS['meta']['sktheme_habillages_public_dir']); |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | $habillages_list = array($original => ''); |
---|
| 155 | if (is_dir($h_dir)) { |
---|
| 156 | if ($dh = opendir($h_dir)) { |
---|
| 157 | while (($dir = readdir($dh)) !== false) { |
---|
| 158 | if ( (is_dir($h_dir."/".$dir)) AND ($dir[0]!=".") ) { |
---|
| 159 | // Check if a theme.xml exists and if the type is themes |
---|
| 160 | if (is_file($h_dir."/".$dir."/theme.xml")) { |
---|
| 161 | $h_info = sktheme_xml_get_infos($h_dir."/".$dir,"theme"); |
---|
| 162 | $type = (isset($h_info['type'])) ? propre($h_info['type']) : ""; |
---|
| 163 | if ($type == 'themes') { |
---|
| 164 | $habillages_list[$dir]=$h_dir."/".$dir; |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | closedir($dh); |
---|
| 170 | } |
---|
| 171 | } else { |
---|
| 172 | echo _T('sktheme:no_available_habillage'); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | // Save habillage if needed |
---|
| 176 | if ($sktheme_action=="set_habillage") { |
---|
| 177 | echo _T('sktheme:update_habillage_to') . $habillage_public_name . "<br />"; |
---|
| 178 | ecrire_meta('sktheme_habillage_public_name',$habillage_public_name); |
---|
| 179 | ecrire_metas(); |
---|
| 180 | } else { |
---|
| 181 | $habillage_public_name = $GLOBALS['meta']['sktheme_habillage_public_name']; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | echo '<br />'; |
---|
| 185 | echo '<form action="'.generer_url_ecrire("sktheme_public_choice", "sktheme_action=set_habillage").'" method="post">'; |
---|
| 186 | foreach( $habillages_list as $key => $value) { |
---|
| 187 | $h_info = sktheme_xml_get_infos($value,"theme"); |
---|
| 188 | |
---|
| 189 | // Check if habillage is available for this squelette selection |
---|
| 190 | // probably better way to do it in php (such grep perl function ? but its |
---|
| 191 | // works anyway) |
---|
| 192 | $squelette_ok = false; |
---|
| 193 | if (is_array($h_info['squelettes'])) { |
---|
| 194 | foreach ($h_info['squelettes'] as $sq){ |
---|
| 195 | $sq = trim($sq); |
---|
| 196 | if ($sq == $squelette_public_name) { |
---|
| 197 | $squelette_ok = true; |
---|
| 198 | } |
---|
| 199 | } |
---|
| 200 | } else { |
---|
| 201 | if ($h_info['squelettes'] == $squelette_public_name) { |
---|
| 202 | $squelette_ok = true; |
---|
| 203 | } |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | if (($key == $original)||($squelette_ok)) { |
---|
| 207 | echo debut_cadre('gris_clair'); |
---|
| 208 | if ($key == $original) { |
---|
| 209 | echo $o_info['extra_img_puce']; |
---|
| 210 | } else { |
---|
| 211 | echo $h_info['extra_img_puce']; |
---|
| 212 | } |
---|
| 213 | if ($habillage_public_name==$key) { |
---|
| 214 | echo '<input type=radio name="habillage_public_name" value="'.$key.'" checked="checked" />'; |
---|
| 215 | } else { |
---|
| 216 | echo '<input type=radio name="habillage_public_name" value="'.$key.'" />'; |
---|
| 217 | } |
---|
| 218 | echo bouton_block_invisible("$key"); |
---|
| 219 | if ($key == $original) { |
---|
| 220 | echo "<strong><i>$key (".$o_info['nom'].")</i></strong>"; |
---|
| 221 | echo debut_block_invisible("$key"); |
---|
| 222 | echo _T('version') .' '. $o_info['version'] . " | <strong>".$o_info['extra_titre_etat']."</strong><br />"; |
---|
| 223 | if (isset($o_info['description'])) |
---|
| 224 | echo "<hr />" . propre($o_info['description']) . "<br />"; |
---|
| 225 | if (isset($o_info['auteur'])) |
---|
| 226 | echo "<hr />" . _T('auteur') .' '. propre($o_info['auteur']) . "<br />"; |
---|
| 227 | if (isset($o_info['lien'])) |
---|
| 228 | echo "<hr />" . _T('info_url') .' '. propre($o_info['lien']) . "<br />"; |
---|
| 229 | |
---|
| 230 | } else { |
---|
| 231 | echo "<strong>$key</strong>"; |
---|
| 232 | echo debut_block_invisible("$key"); |
---|
| 233 | echo _T('version') .' '. $h_info['version'] . " | <strong>".$h_info['extra_titre_etat']."</strong><br />"; |
---|
| 234 | if (isset($h_info['description'])) |
---|
| 235 | echo "<hr />" . propre($h_info['description']) . "<br />"; |
---|
| 236 | if (isset($h_info['auteur'])) |
---|
| 237 | echo "<hr />" . _T('auteur') .' '. propre($h_info['auteur']) . "<br />"; |
---|
| 238 | if (isset($h_info['lien'])) |
---|
| 239 | echo "<hr />" . _T('info_url') .' '. propre($h_info['lien']) . "<br />"; |
---|
| 240 | } |
---|
| 241 | echo fin_block(); |
---|
| 242 | echo fin_cadre('gris_clair'); |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | echo '<br />'; |
---|
| 247 | echo '<div><div align="right"><input type="submit" value="'._t('sktheme:save_habillage').'"></div></div>'; |
---|
| 248 | echo '</form>'; |
---|
| 249 | |
---|
| 250 | fin_cadre_trait_couleur(); |
---|
| 251 | |
---|
| 252 | |
---|
| 253 | |
---|
| 254 | |
---|
| 255 | fin_page(); |
---|
| 256 | |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | |
---|
| 260 | ?> |
---|