<?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";
}
}
?>