source: trunk/spip/esqueleto-redcta/plugins/sktheme/1_9_2/sktheme_options.php @ 501

Last change on this file since 501 was 30, checked in by sebas, 17 years ago

nueva importacion del codigo del esqueleto de redcta con los plugins

File size: 3.7 KB
Line 
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  // cache desactivation
18  $_SERVER['REQUEST_METHOD']='POST';
19
20include_spip("inc/meta");
21include_spip('inc/sktheme_balises');
22
23// Set a default configuration - each values can be modify
24// in the private area
25if (!isset($GLOBALS['meta']['sktheme_squelettes_public_dir'])){
26  ecrire_meta('sktheme_squelettes_public_dir',"themes");
27  ecrire_meta('sktheme_habillages_public_dir',"themes");
28  ecrire_meta('sktheme_squelette_public_name',"dist");
29  ecrire_meta('sktheme_habillage_public_name',"");
30  ecrire_meta('sktheme_theme_switcher_style',"font-size: 10px;background-color: #FFF;color: #0C479D;border-top: 1px solid #CECECE; border-bottom: 2px solid #4A4A4A; border-left: 1px solid #CECECE; border-right: 1px solid #CECECE;margin:2px .5em;");
31  ecrire_meta('sktheme_habillage_switcher_style',"font-size: 10px;background-color: #FFF;color: #0C479D;border-top: 1px solid #CECECE; border-bottom: 2px solid #4A4A4A; border-left: 1px solid #CECECE; border-right: 1px solid #CECECE;margin:2px .5em;");
32  ecrire_meta('sktheme_switcher_activated',"no");
33  ecrire_meta('sktheme_switcher_admin_only',"yes");
34  ecrire_metas();
35} 
36
37// Set default user choice
38$s_dir = $GLOBALS['meta']['sktheme_squelettes_public_dir'].'/'.$GLOBALS['meta']['sktheme_squelette_public_name'];
39$h_dir = $GLOBALS['meta']['sktheme_habillages_public_dir'].'/'.$GLOBALS['meta']['sktheme_habillage_public_name'];
40
41//
42// SWITCHER THEME
43//
44// Contrib de Fil : voir http://trac.rezo.net/trac/spip-zone/browser/_contribs_/switcher/switcher.php
45// --------------------------------------------------------------------------------------------------
46// Ask sktheme
47if (isset($_GET['var_sktheme'])) {
48 
49  // sktheme format :
50  // for theme           = squelette_name::habillage_name
51  // for habillage only  = __current::habillage_name
52  //
53  list($squelette,$habillage)= split ("::", $_GET['sktheme']);
54   
55  // For habillage only
56  if ($squelette == "__current") {
57    $squelette = $GLOBALS['meta']['sktheme_squelette_public_name'];
58  }
59   
60  $s_dir = $GLOBALS['meta']['sktheme_squelettes_public_dir'].'/'.$squelette;
61  $h_dir = $GLOBALS['meta']['sktheme_habillages_public_dir'].'/'.$habillage;
62  if (is_dir(_DIR_RACINE.$s_dir)) {
63    // theme exist put a cookie
64    setcookie('spip_sktheme', $_COOKIE['spip_sktheme'] = $_GET['var_sktheme'], NULL, '/');
65  } else {
66    // not valid remove cookie
67    setcookie('spip_sktheme', $_COOKIE['spip_sktheme'] = '', -24*3600, '/');
68  }
69}
70
71if (isset($_COOKIE['spip_sktheme'])) {
72  list($squelette,$habillage)= split ("::", $_COOKIE['spip_sktheme']);
73  // For habillage only
74  if ($squelette == "__current") {
75    $squelette = $GLOBALS['meta']['sktheme_squelette_public_name'];
76  }
77  $s_dir_new = $GLOBALS['meta']['sktheme_squelettes_public_dir'].'/'.$squelette;
78  $h_dir_new = $GLOBALS['meta']['sktheme_habillages_public_dir'].'/'.$habillage;
79 
80  if (is_dir(_DIR_RACINE.$s_dir_new)) {
81    $s_dir = $s_dir_new;
82  }
83  if (is_dir(_DIR_RACINE.$h_dir_new)) {
84    $h_dir = $h_dir_new;
85  }
86} 
87
88// So set only the 'dossier_squelettes' to the corresponding user choice
89$dossier_squelettes = $h_dir.':'.$s_dir;
90?>
Note: See TracBrowser for help on using the repository browser.