summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-02 19:51:07 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-04-02 19:51:07 +0200
commit204761a81035f04f3159f9679826c432912f0022 (patch)
tree7e64a03d0852063aa7781b0b6c310a640488e06e
parentbf24aa601f96d184f9635fa72377d7521b324b4f (diff)
Fix issue #44 : affichage du nombre d'entrées non lues dans la sidebar
-rw-r--r--app/layout/aside_flux.phtml5
-rw-r--r--app/models/Feed.php13
2 files changed, 18 insertions, 0 deletions
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml
index 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.php
index 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;
@@ -313,6 +317,15 @@ class FeedDAO extends Model_pdo {
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'];
+ }
}
class HelperFeed {