forked from fossar/selfoss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Items.php
83 lines (71 loc) · 2.03 KB
/
Items.php
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
<?PHP
namespace daos;
/**
* Class for accessing persistent saved items
*
* @package daos
* @copyright Copyright (c) Tobias Zeising (http://www.aditu.de)
* @license GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html)
* @author Harald Lapp <harald.lapp@gmail.com>
* @author Tobias Zeising <tobias.zeising@aditu.de>
*/
class Items extends Database {
/**
* Instance of backend specific items class
*
* @var object
*/
private $backend = null;
/**
* Constructor.
*
* @return void
*/
public function __construct() {
$class = 'daos\\' . \F3::get('db_type') . '\\Items';
$this->backend = new $class();
parent::__construct();
}
/**
* pass any method call to the backend.
*
* @return methods return value
* @param string $name name of the function
* @param array $args arguments
*/
public function __call($name, $args) {
if(method_exists($this->backend, $name))
return call_user_func_array(array($this->backend, $name), $args);
else
\F3::get('logger')->log('Unimplemented method for ' . \F3::get('db_type') . ': ' . $name, \ERROR);
}
/**
* cleanup old items
*
* @return void
* @param int $days delete all items older than this value
*/
public function cleanup($days) {
$minDate = new \DateTime();
$minDate->sub(new \DateInterval('P'.$days.'D'));
$this->backend->cleanup($minDate);
}
/**
* returns items
*
* @return mixed items as array
* @param mixed $options search, offset and filter params
*/
public function get($options = array()) {
$options = array_merge(
array(
'starred' => false,
'offset' => 0,
'search' => false,
'items' => \F3::get('items_perpage')
),
$options
);
return $this->backend->get($options);
}
}