aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Category.php
diff options
context:
space:
mode:
authorGravatar Clément <clement@selfhost.fr> 2017-02-15 14:14:03 +0100
committerGravatar Clément <clement@selfhost.fr> 2017-02-15 14:14:03 +0100
commit5a1bb1393b4496eb35a2ffb3cc63d41c9dc1e2e5 (patch)
tree67028e45792c575c25c92616633f64cc7a4a13eb /app/Models/Category.php
parent7e949d50320317b5c3b5a2da2bdaf324e794b2f7 (diff)
parent5f637bd816b7323885bfe1751a1724ee59a822f6 (diff)
Merge remote-tracking branch 'FreshRSS/master'
Diffstat (limited to 'app/Models/Category.php')
-rw-r--r--app/Models/Category.php53
1 files changed, 30 insertions, 23 deletions
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 328bae799..9a44a2d09 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -6,66 +6,73 @@ class FreshRSS_Category extends Minz_Model {
private $nbFeed = -1;
private $nbNotRead = -1;
private $feeds = null;
+ private $hasFeedsWithError = false;
- public function __construct ($name = '', $feeds = null) {
- $this->_name ($name);
- if (isset ($feeds)) {
- $this->_feeds ($feeds);
+ 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 ();
+ $this->nbNotRead += $feed->nbNotRead();
+ $this->hasFeedsWithError |= $feed->inError();
}
}
}
- public function id () {
+ public function id() {
return $this->id;
}
- public function name () {
+ public function name() {
return $this->name;
}
- public function nbFeed () {
+ public function nbFeed() {
if ($this->nbFeed < 0) {
- $catDAO = new FreshRSS_CategoryDAO ();
- $this->nbFeed = $catDAO->countFeed ($this->id ());
+ $catDAO = new FreshRSS_CategoryDAO();
+ $this->nbFeed = $catDAO->countFeed($this->id());
}
return $this->nbFeed;
}
- public function nbNotRead () {
+ public function nbNotRead() {
if ($this->nbNotRead < 0) {
- $catDAO = new FreshRSS_CategoryDAO ();
- $this->nbNotRead = $catDAO->countNotRead ($this->id ());
+ $catDAO = new FreshRSS_CategoryDAO();
+ $this->nbNotRead = $catDAO->countNotRead($this->id());
}
return $this->nbNotRead;
}
- public function feeds () {
+ public function feeds() {
if ($this->feeds === null) {
- $feedDAO = new FreshRSS_FeedDAO ();
- $this->feeds = $feedDAO->listByCategory ($this->id ());
+ $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 ();
+ $this->nbNotRead += $feed->nbNotRead();
+ $this->hasFeedsWithError |= $feed->inError();
}
}
return $this->feeds;
}
- public function _id ($value) {
+ public function hasFeedsWithError() {
+ return $this->hasFeedsWithError;
+ }
+
+ public function _id($value) {
$this->id = $value;
}
- public function _name ($value) {
- $this->name = $value;
+ public function _name($value) {
+ $this->name = substr(trim($value), 0, 255);
}
- public function _feeds ($values) {
- if (!is_array ($values)) {
- $values = array ($values);
+ public function _feeds($values) {
+ if (!is_array($values)) {
+ $values = array($values);
}
$this->feeds = $values;