1 | <?php |
---|
2 | // --------------------------------------------------------------------- |
---|
3 | // |
---|
4 | // Sktheme : manage themes under SPIP (squelettes + habillages) |
---|
5 | // |
---|
6 | // Copyright (c) 2006 - Skedus |
---|
7 | // |
---|
8 | // This program is free software; you can redistribute it and/or modify |
---|
9 | // it under the terms of the GNU General Public License as published by |
---|
10 | // the Free Software Foundation; either version 2 of the License, or |
---|
11 | // (at your option) any later version. |
---|
12 | // |
---|
13 | // You should have received a copy of the GNU General Public License |
---|
14 | // along with this program; |
---|
15 | // |
---|
16 | // --------------------------------------------------------------------- |
---|
17 | |
---|
18 | $p=explode(basename(_DIR_PLUGINS)."/",str_replace('\\','/',realpath(dirname(__FILE__)))); |
---|
19 | define('_DIR_PLUGIN_SKTHEME',(_DIR_PLUGINS.end($p))); |
---|
20 | |
---|
21 | include_spip('inc/sktheme_list'); |
---|
22 | |
---|
23 | // Add private area button |
---|
24 | function sktheme_ajouter_boutons($boutons_admin) { |
---|
25 | // administrator only |
---|
26 | if ($GLOBALS['connect_statut'] == "0minirezo" && $GLOBALS["connect_toutes_rubriques"]) { |
---|
27 | |
---|
28 | // See button in the 'configuration' |
---|
29 | $boutons_admin['configuration']->sousmenu["sktheme_public_choice"]= |
---|
30 | new Bouton("../"._DIR_PLUGIN_SKTHEME."/img_pack/sktheme_icon.png", // icon |
---|
31 | _L("sktheme:manage_theme")); // title |
---|
32 | } |
---|
33 | return $boutons_admin; |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | // |
---|
38 | // Include Philippe Drouot switcher functionnality |
---|
39 | // Based on Fil contrib |
---|
40 | function sktheme_affichage_final($texte){ |
---|
41 | |
---|
42 | global $html; |
---|
43 | |
---|
44 | $sktheme_list = sktheme_list(); |
---|
45 | |
---|
46 | // Insertion du Javascript de rechargement de page |
---|
47 | // Always include this script used for #SKTHEME_HABILLAGES_SWITCHER and #SKTHEME_THEMES_SWITCHER |
---|
48 | $code = '<script type="text/javascript"> |
---|
49 | //<![CDATA[ |
---|
50 | function sktheme_gotof(url) { |
---|
51 | window.location=url; |
---|
52 | }//]]> |
---|
53 | </script>'; |
---|
54 | |
---|
55 | if (isset($GLOBALS['meta']['sktheme_switcher_activated']) |
---|
56 | AND ($GLOBALS['meta']['sktheme_switcher_activated']=="yes")) { |
---|
57 | if ($html) { |
---|
58 | |
---|
59 | // Doit-on afficher le selecteur de squelette ? (Fonctionnalite restreinte aux seuls administrateurs ?) |
---|
60 | $afficherSelecteur=TRUE; |
---|
61 | if (isset($GLOBALS['meta']['sktheme_switcher_admin_only']) |
---|
62 | AND ($GLOBALS['meta']['sktheme_switcher_admin_only']=="yes") |
---|
63 | AND (!isset($_COOKIE['spip_admin']))) $afficherSelecteur=FALSE; |
---|
64 | |
---|
65 | if ($afficherSelecteur) { |
---|
66 | |
---|
67 | |
---|
68 | // Insertion du selecteur de squelettes |
---|
69 | $code.='<div id="sktheme_switcher" style="top: 0;left: 20px; position: absolute; background-color: transparent;z-index: 100;">'; |
---|
70 | $code.='<form action="" method="post">'; |
---|
71 | $code.='<fieldset style="margin:0;padding:0;border:0">'; |
---|
72 | $code.='<select name="selecteurTheme" style="'.$GLOBALS['meta']['sktheme_theme_switcher_style'].'" onchange="sktheme_gotof(this.options[this.selectedIndex].value)">'; |
---|
73 | $code.='<option selected="selected" value="">Themes</option>'; |
---|
74 | foreach( $sktheme_list as $value ) $code.='<option value="'.parametre_url(self(),'var_sktheme',$value).'"> -> '.$value.'</option>'; |
---|
75 | $code.='</select>'; |
---|
76 | $code.='</fieldset>'; |
---|
77 | $code.='</form>'; |
---|
78 | $code.='</div>'; |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | } |
---|
83 | } |
---|
84 | // On rajoute le code du selecteur de squelettes avant la balise </body> |
---|
85 | $texte=eregi_replace("</body>","$code</body>",$texte); |
---|
86 | return($texte); |
---|
87 | } |
---|
88 | |
---|
89 | ?> |
---|