23c1c345b7d43b02c5848a824b4135fc86e59b6a
[platal.git] / include / platal / globals.inc.php.in
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2006 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., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22 require_once('diogenes/diogenes.core.globals.inc.php');
23 require_once('diogenes/diogenes.database.inc.php');
24 require_once('platal/iterator.inc.php');
25 require_once dirname(__FILE__).'/../../classes/XDB.php';
26
27 class CoreConfig
28 {
29 var $locale = 'fr_FR';
30 }
31
32 class PlatalGlobals extends DiogenesCoreGlobals
33 {
34 var $page = 'XorgPage';
35 var $session;
36 var $menu;
37 var $hook;
38
39 /** The x.org version */
40 var $version = '@VERSION@';
41 var $debug = 0;
42
43 /** db params */
44 var $dbdb = 'x4dat';
45 var $dbhost = 'localhost';
46 var $dbuser = 'x4dat';
47 var $dbpwd = 'x4dat';
48
49 var $table_auth = 'auth_user_md5';
50 var $table_log_actions = 'logger.actions';
51 var $table_log_sessions = 'logger.sessions';
52 var $table_log_events = 'logger.events';
53
54 /** logger */
55 var $tauth = array('native'=>'auth_user_md5');
56 var $tlabel = array('native'=>'X.Org');
57
58 /** paths */
59 var $baseurl;
60 var $spoolroot;
61
62 function PlatalGlobals($sess)
63 {
64 $this->session = $sess;
65
66 $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
67 $this->baseurl = trim($base.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
68 $this->spoolroot = dirname(dirname(dirname(__FILE__)));
69 }
70
71 function read_config()
72 {
73 $array = parse_ini_file($this->spoolroot.'/configs/platal.conf', true);
74 if (!is_array($array)) {
75 return;
76 }
77
78 foreach ($array as $cat=>$conf) {
79 $c = strtolower($cat);
80 foreach ($conf as $key=>$val) {
81 if ($c == 'core' && isset($this->$key)) {
82 $this->$key=$val;
83 } else {
84 $this->$c->$key = $val;
85 }
86 }
87 }
88 }
89
90 function setlocale()
91 {
92 global $globals;
93 setlocale(LC_MESSAGES, $globals->core->locale);
94 setlocale(LC_TIME, $globals->core->locale);
95 setlocale(LC_CTYPE, $globals->core->locale);
96 }
97 }
98
99 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
100 ?>