A free, self-hostable news aggregator…
Fix issue #44 : affichage du nombre d'entrées non lues dans la sidebar
Marien Fressinaud204761a81035
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtmlindex 903a566af..1d1700170 100644--- a/app/layout/aside_flux.phtml+++ b/app/layout/aside_flux.phtml@@ -58,10 +58,15 @@</ul></div>+ <?php $not_read = $feed->nbNotRead (); ?>+<img class="favicon" src="http://g.etfv.co/<?php echo $feed->website (); ?>" alt="favicon <?php echo $feed->name (); ?>" />+ <?php echo $not_read > 0 ? '<b>' : ''; ?><a class="feed" href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>">+ <?php echo $not_read > 0 ? '(' . $not_read . ') ' : ''; ?><?php echo $feed->name(); ?></a>+ <?php echo $not_read > 0 ? '</b>' : ''; ?></li><?php } ?></ul>diff --git a/app/models/Feed.php b/app/models/Feed.phpindex 8e3168e3b..159b6e767 100644--- a/app/models/Feed.php+++ b/app/models/Feed.php@@ -58,6 +58,10 @@ class Feed extends Model {$feedDAO = new FeedDAO ();return $feedDAO->countEntries ($this->id ());}+ public function nbNotRead () {+ $feedDAO = new FeedDAO ();+ return $feedDAO->countNotRead ($this->id ());+ }public function _id ($value) {$this->id = $value;@@ -311,6 +315,15 @@ class FeedDAO extends Model_pdo {$stm->execute ($values);$res = $stm->fetchAll (PDO::FETCH_ASSOC);+ return $res[0]['count'];+ }+ public function countNotRead ($id) {+ $sql = 'SELECT COUNT(*) AS count FROM entry WHERE is_read=0 AND id_feed=?';+ $stm = $this->bd->prepare ($sql);+ $values = array ($id);+ $stm->execute ($values);+ $res = $stm->fetchAll (PDO::FETCH_ASSOC);+return $res[0]['count'];}}