Updates.
[AOOS.git] / AOOSCore.php
blob12205e97fb3e999680c7c5180ce5498bf505b68c
1 <?php
3 require_once("AOOSException.php");
5 /**
6 * AOOSCore
8 * The core class of AOOS
10 * @author Sebastian Skejø
13 class AOOSCore
15 private $_exceptions = array();
16 private $_loadedModules = array();
17 private $_settings = array();
18 private $_transStrings = array();
20 public function __construct()
22 require_once("config.php");
23 $this->_settings = $settings;
25 $l = $this->getSetting("lang");
26 require_once("lang.php");
27 if (!in_array($l, array_keys($lang)))
29 throw new AOOSException($this, "Language not found in lang.php. You will not be able to translate strings","",true, 1);
31 else
33 $this->_transStrings = $lang[$l];
37 /**
38 * Sets an exception
39 * @param AOOSException $e The exception
41 public function setException($e)
43 $this->_exceptions[$e->getName()] = $e;
44 if ($e->getEcode() == 0)
46 exit($e);
49 return true;
52 public function printExceptions()
54 $str = "<div class=\"Exceptions\">";
55 foreach ($this->_exceptions as $e)
57 $str .= $e;
59 $str .= "</div>";
60 print $str;
63 public function getSetting($name)
65 if (!in_array($name, array_keys($this->_settings)))
67 throw new AOOSException($this, "Settingkey not found", "", true, 2);
68 return false;
70 return $this->_settings[$name];
73 public function getTranslatedString($string)
75 if (!in_array($string, array_keys($this->_transStrings)))
77 throw new AOOSException($this, "Translated string not found", "String name: ".$string, true, 2);
78 return $string;
80 return $this->_transStrings[$string];