blob: 65e353d3518dd7f9f5a1eab44983117f457aee4c (
plain)
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
|
<?php
namespace bdrem;
class Config
{
public $source;
public $date;
public $daysPrev = 3;
public $daysNext = 7;
public $locale;
public $stopOnEmpty = false;
public $cfgFileExists;
public function load()
{
$f = __DIR__ . '/../../data/bdrem.config.php';
if (file_exists($f)) {
$this->cfgFileExists = true;
return $this->loadFile($f);
}
$this->cfgFileExists = false;
}
protected function loadFile($filename)
{
include $filename;
$vars = get_defined_vars();
foreach ($vars as $k => $value) {
$this->$k = $value;
}
}
public function loadSource()
{
if ($this->source === null) {
throw new \Exception('No source defined');
}
$settings = $this->source;
$class = '\\bdrem\\Source_' . array_shift($settings);
return new $class($settings[0]);
}
public function setDate($date)
{
if ($date === null) {
$this->date = date('Y-m-d');
} else {
$dt = new \DateTime($date);
$this->date = $dt->format('Y-m-d');
}
}
public function get($varname, $default = '')
{
if (!isset($this->$varname) || $this->$varname == '') {
return $default;
}
return $this->$varname;
}
}
?>
|