blob: 0a0dbd3ca8f0052f0318163f13c7566cc73bb893 (
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
65
66
67
68
69
70
71
72
73
|
<?php
class FreshRSS_Category extends Minz_Model {
private $id = 0;
private $name;
private $nbFeed = -1;
private $nbNotRead = -1;
private $feeds = null;
public function __construct ($name = '', $feeds = null) {
$this->_name ($name);
if (isset ($feeds)) {
$this->_feeds ($feeds);
$this->nbFeed = 0;
$this->nbNotRead = 0;
foreach ($feeds as $feed) {
$this->nbFeed++;
$this->nbNotRead += $feed->nbNotRead ();
}
}
}
public function id () {
return $this->id;
}
public function name () {
return $this->name;
}
public function nbFeed () {
if ($this->nbFeed < 0) {
$catDAO = new FreshRSS_CategoryDAO ();
$this->nbFeed = $catDAO->countFeed ($this->id ());
}
return $this->nbFeed;
}
public function nbNotRead () {
if ($this->nbNotRead < 0) {
$catDAO = new FreshRSS_CategoryDAO ();
$this->nbNotRead = $catDAO->countNotRead ($this->id ());
}
return $this->nbNotRead;
}
public function feeds () {
if ($this->feeds === null) {
$feedDAO = FreshRSS_Factory::createFeedDao();
$this->feeds = $feedDAO->listByCategory ($this->id ());
$this->nbFeed = 0;
$this->nbNotRead = 0;
foreach ($this->feeds as $feed) {
$this->nbFeed++;
$this->nbNotRead += $feed->nbNotRead ();
}
}
return $this->feeds;
}
public function _id ($value) {
$this->id = $value;
}
public function _name ($value) {
$this->name = $value;
}
public function _feeds ($values) {
if (!is_array ($values)) {
$values = array ($values);
}
$this->feeds = $values;
}
}
|