Commit | Line | Data |
---|---|---|
6855525e JL |
1 | <?php |
2 | /* | |
3 | * Copyright (C) 2003-2004 Polytechnique.org | |
4 | * http://opensource.polytechnique.org/ | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 | */ | |
20 | ||
21 | ||
22 | /** | |
23 | * This class is used to handle the preferences for a barrel. | |
24 | * | |
25 | * Upon construction these preferences are read from database. It is also | |
26 | * possible to update the value of the preferences and write the new value | |
27 | * to database. | |
28 | * | |
29 | * @see Diogenes_Barrel | |
30 | */ | |
31 | class Diogenes_Barrel_Options | |
32 | { | |
33 | /** The barrel we are operating on */ | |
34 | var $barrel; | |
35 | ||
36 | /** The table holding the options */ | |
37 | var $table_option = 'diogenes_option'; | |
38 | ||
39 | /** The site's title */ | |
40 | var $title = ""; | |
41 | ||
42 | /** The site's description */ | |
43 | var $description = ""; | |
44 | ||
45 | /** The relative url to the site's favicon (PNG) */ | |
46 | var $favicon = ""; | |
47 | ||
48 | /** The site's keywords */ | |
49 | var $keywords = ""; | |
50 | ||
51 | /** Hide the Diogenes-generated menu entries */ | |
52 | var $menu_hide_diogenes = 0; | |
53 | ||
54 | /** Minimum menu level (0 means fully expanded) */ | |
55 | var $menu_min_level = 0; | |
56 | ||
57 | /** Menu style (0=classical, 1=phpLayersMenu) */ | |
58 | var $menu_style = 0; | |
59 | ||
60 | /** Menu theme */ | |
61 | var $menu_theme = "gorilla"; | |
62 | ||
63 | /** Site-wide default template */ | |
64 | var $template = ""; | |
65 | ||
66 | /** Directory that hold the site's template */ | |
67 | var $template_dir = ""; | |
a424d15c JL |
68 | |
69 | /** Enable RSS feed */ | |
87eb2169 | 70 | var $feed_enable = 0; |
a424d15c | 71 | |
6855525e JL |
72 | /** The constructor, reads the current preferences from database. |
73 | */ | |
74 | function Diogenes_Barrel_Options($alias) | |
75 | { | |
76 | $this->barrel = $alias; | |
77 | $this->readOptions(); | |
78 | } | |
79 | ||
80 | ||
81 | /** Read options from database. | |
82 | */ | |
83 | function readOptions() { | |
84 | global $globals; | |
85 | ||
86 | // we only accept options which already exist in this class | |
87 | $res = $globals->db->query("select name,value from {$this->table_option} where barrel='{$this->barrel}'"); | |
88 | while (list($key,$value) = mysql_fetch_row($res)) { | |
89 | if (isset($this->$key) && ($key != "table_option")) | |
90 | $this->$key = $value; | |
91 | } | |
92 | mysql_free_result($res); | |
93 | ||
94 | } | |
95 | ||
96 | ||
97 | /** Update an option's value and write the new value to database. | |
98 | */ | |
99 | function updateOption($name, $value) { | |
100 | global $globals; | |
101 | ||
102 | $this->$name = stripslashes($value); | |
103 | $globals->db->query("replace into {$this->table_option} set barrel='{$this->barrel}',name='$name',value='$value'"); | |
104 | } | |
105 | ||
106 | } | |
107 | ||
108 | ?> |