more work on the plugins system
[diogenes.git] / include / diogenes / diogenes.core.globals.inc.php
... / ...
CommitLineData
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 */
24class 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 die("Could not connect to database (".mysql_error().")");
63 $this->db = $db;
64 }
65
66 /** Add some automatic hyperlinks to a text.
67 *
68 * @param in the text to beautify
69 */
70 function urlise($in)
71 {
72 $out = str_replace("Polytechnique.org","<a href=\"http://www.polytechnique.org/\">Polytechnique.org</a>",$in);
73 $out = str_replace("Diogenes","<a href=\"http://opensource.polytechnique.org/diogenes/\">Diogenes</a>",$out);
74 return $out;
75 }
76
77}
78
79
80/** Translation function.
81 *
82 * @param msg the message to translate
83 */
84function __($msg)
85{
86 global $globals;
87 $func = $globals->gettext;
88
89 if (function_exists($func))
90 return $func($msg);
91 else
92 return $msg;
93}
94
95
96?>