html renderer, console renderer uses pear's Console_Table
[bdrem.git] / src / bdrem / Config.php
1 <?php
2 namespace bdrem;
3
4 class Config
5 {
6     public $source;
7     public $daysBefore;
8     public $daysAfter;
9     public $locale;
10
11     public function load()
12     {
13         $f = __DIR__ . '/../../data/bdrem.config.php';
14         if (file_exists($f)) {
15             return $this->loadFile($f);
16         }
17
18         throw new \Exception('No config file found');
19     }
20
21     protected function loadFile($filename)
22     {
23         include $filename;
24         $this->source = $source;
25         $this->daysBefore = $daysBefore;
26         $this->daysAfter = $daysAfter;
27         if (isset($locale)) {
28             $this->locale = $locale;
29         }
30     }
31
32     public function loadSource()
33     {
34         if ($this->source === null) {
35             throw new \Exception('No source defined');
36         }
37
38         $settings = $this->source;
39         $class = '\\bdrem\\Source_' . array_shift($settings);
40
41         return new $class($settings[0]);
42     }
43 }
44 ?>