merge changes from diogenes-0.9.19 branch back into trunk
[diogenes.git] / include / diogenes / diogenes.core.globals.inc.php
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 /** This class describes Diogenes' global settings.
23 */
24 class DiogenesCoreGlobals {
25 /** Absolute directory location of the Diogenes library */
26 var $libroot;
27 /** Absolute directory location of Diogenes root. */
28 var $root;
29 /** The Diogenes root URL */
30 var $rooturl;
31
32 /** The database handler. */
33 var $db;
34
35 /** The database. */
36 var $dbdb = "diogenes";
37 /** The database server. */
38 var $dbhost = "localhost";
39 /** The user to access the database. */
40 var $dbuser = "diogenes";
41 /** The password to connect to the database. */
42 var $dbpwd;
43
44 /** The database table holding the logger actions */
45 var $table_log_actions = "diogenes_logactions";
46 /** The database table holding the logger events */
47 var $table_log_events = "diogenes_logevents";
48 /** The database table holding the logger sessions */
49 var $table_log_sessions = "diogenes_logsessions";
50 /** The class to use for session handling. */
51 var $session = 'DiogenesCoreSession';
52 /** The function to call for translation. */
53 var $gettext = 'gettext';
54
55
56 /** Connect to the database server.
57 */
58 function dbconnect()
59 {
60 $db = new DiogenesDatabase($this->dbdb, $this->dbhost, $this->dbuser, $this->dbpwd);
61 if (!$db->connect_id)
62 {
63 if (!headers_sent())
64 header("HTTP/1.0 500 Internal Server Error");
65 die("Could not connect to database (".mysql_error().")");
66 }
67 $this->db = $db;
68 }
69
70 /** Add some automatic hyperlinks to a text.
71 *
72 * @param in the text to beautify
73 */
74 function urlise($in)
75 {
76 $out = str_replace("Polytechnique.org","<a href=\"http://www.polytechnique.org/\">Polytechnique.org</a>",$in);
77 $out = str_replace("Diogenes","<a href=\"http://opensource.polytechnique.org/diogenes/\">Diogenes</a>",$out);
78 return $out;
79 }
80
81 }
82
83
84 /** Translation function.
85 *
86 * @param msg the message to translate
87 */
88 function __($msg)
89 {
90 global $globals;
91 $func = $globals->gettext;
92
93 if (function_exists($func))
94 return $func($msg);
95 else
96 return $msg;
97 }
98
99
100 ?>