[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / zen-garden / zengarden_options.php
1 <?php
2 /**
3 * Plugin Zen-Garden pour Spip 2.0
4 * Licence GPL (c) 2006-2009 Cedric Morin
5 *
6 */
7
8 if (!defined("_ECRIRE_INC_VERSION")) return;
9
10 if (!defined('_DIR_PLUGIN_THEME')){
11 if (!defined('_DIR_THEMES'))
12 define('_DIR_THEMES',_DIR_RACINE."themes/");
13
14 // si on est en mode apercu, il suffit de repasser dans l'espace prive pour desactiver l'apercu
15 if (test_espace_prive()){
16 if (isset($_COOKIE['spip_zengarden_theme'])){
17 include_spip('inc/cookie');
18 spip_setcookie('spip_zengarden_theme',$_COOKIE['spip_zengarden_theme']='',-1);
19 }
20 }
21 elseif(isset($GLOBALS['meta']['zengarden_switcher']) OR defined('_ZEN_VAR_THEME')){
22 if (!is_null($arg = _request('var_theme'))){
23 include_spip('inc/cookie');
24 if ($arg)
25 spip_setcookie('spip_zengarden_theme',$_COOKIE['spip_zengarden_theme'] = $arg);
26 else
27 spip_setcookie('spip_zengarden_theme',$_COOKIE['spip_zengarden_theme']='',-1);
28 }
29 }
30
31 // ajouter le theme au path
32 if (
33 (
34 // on est en mode apercu
35 (isset($_COOKIE['spip_zengarden_theme']) AND $t = $_COOKIE['spip_zengarden_theme'])
36 // ou avec le cookie du switcher
37 OR
38 // ou un theme est vraiment selectionne
39 (isset($GLOBALS['meta']['zengarden_theme']) AND $t = $GLOBALS['meta']['zengarden_theme'])
40 )
41 AND is_dir(_DIR_THEMES . $t)){
42 _chemin(_DIR_THEMES.$t);
43 $GLOBALS['marqueur'] = (isset($GLOBALS['marqueur'])?$GLOBALS['marqueur']:"").":$t";
44 // @experimental : sauver le nom du repertoire theme utilise
45 // a defaut de connaitre le vrai prefixe
46 if (!defined('NOM_THEME')) { define('NOM_THEME', basename($t));}
47 }
48
49 // @experimental : balise #THEME qui retourne le nom du theme selectionne
50 function balise_THEME_dist($p){
51 $p->code = "(defined('NOM_THEME') ? NOM_THEME : '')";
52 return $p;
53 }
54 }
55
56 // DĂ©claration du pipeline permettant d'ajouter traitements lors de la preview et de l'activiation
57 $GLOBALS['spip_pipeline']['zengarden_activer_theme'] = '';
58
59 function zengarden_affichage_final($texte){
60 if ($GLOBALS['html'] and isset($GLOBALS['meta']['zengarden_switcher'])){
61 include_spip('prive/zengarden_theme_fonctions');
62 // on passe le theme selectionne en js pour ne pas polluer le cache du switcher
63 $code =
64 "<script type='text/javascript'>var theme_selected='".$_COOKIE['spip_zengarden_theme']."'</script>"
65 . recuperer_fond('inclure/zengarden_switcher');
66 // On rajoute le code du selecteur de squelettes avant la balise </body>
67 $texte=str_replace("</body>",$code."</body>",$texte);
68 }
69 return $texte;
70 }
71
72 ?>