[go: up one dir, main page]

Menu

[r7]: / trunk / core / core.class.php  Maximize  Restore  History

Download this file

122 lines (101 with data), 2.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
// +--------------------------------------------+
// | Twiggi web-based groupware. |
// | |
// | For copyright and license information |
// | please read the COPYRIGHT file. |
// +--------------------------------------------+
class core
{
static $instance = false;
private $major_version = 2;
private $minor_version = 0;
private $state_version = "ALPHA";
private $root = NULL;
private $slash = NULL;
private $config = array();
private $debug = true;
private $loaded_files = array();
private function __construct()
{
$this->root = realpath(".");
$this->slash = DIRECTORY_SEPARATOR;
$this->load_config();
}
public function get_instance()
{
if (!core::$instance)
{
core::$instance = new core();
}
return core::$instance;
}
private function load_config()
{
$config_file = $this->root.$this->slash."config".$this->slash."config.inc.php";
if (!file_exists($config_file))
{
core_print(__FILE__,__LINE__,ERROR,$config_file." is missing");
return;
}
include_once($config_file);
$this->config = $cfg;
}
public function load_file($file)
{
if (!in_array($file, $this->loaded_files))
{
if (!file_exists($file))
{
core_print(__FILE__,__LINE__,ERROR,$file." is missing!");
return false;
}
require_once($file);
$this->loaded_files[] = $file;
return true;
}
return false;
}
public function get_config_option($option)
{
if (array_key_exists($option,$this->config))
{
if (($this->config[$option] == NULL) && ($this->debug))
{
core_print(__FILE__,__LINE__,WARNING,$option." is NULL");
}
return $this->config[$option];
}
if ($this->debug)
{
core_print(__FILE__,__LINE__,WARNING,$option." is not a known configuration option");
}
return NULL;
}
public function get_root()
{
return $this->root;
}
public function get_slash()
{
return $this->slash;
}
public function get_version()
{
return $this->major_version.".".$this->minor_version." (".$this->state_version.")";
}
public function show_page()
{
print "Twiggi web-based groupware core module is up and running. Version ";
}
public function get_debug_mode()
{
return $this->debug;
}
public function get_module()
{
// For now we just return core until the module class is working...
return "core";
}
}
?>