summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-30 22:30:40 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-30 22:30:40 +0100
commit0f2891f4325d6f88845790393d006883831118fd (patch)
tree29720da808978990185a9ca5987a09621a8149d5
parent3a8a6d2d56c468af924936a80e110727bc503594 (diff)
Fix issue #8 : ajoute le nombre de non lus pour les catégories (mérite amélioration ?)
-rw-r--r--app/layout/aside.phtml18
-rwxr-xr-xapp/models/Category.php14
-rw-r--r--app/views/javascript/main.phtml22
-rw-r--r--public/theme/base.css2
4 files changed, 32 insertions, 24 deletions
diff --git a/app/layout/aside.phtml b/app/layout/aside.phtml
index 7f33bff2f..61efae7c3 100644
--- a/app/layout/aside.phtml
+++ b/app/layout/aside.phtml
@@ -8,9 +8,7 @@
<ul id="menu">
<li <?php echo Request::controllerName () == 'index' ? 'class="active"' : ''; ?>>
- <a href="<?php echo Url::display (array ()); ?>">
- Flux RSS <span class="nb_not_read"><?php if ($this->nb_not_read > 0) { ?>(<?php echo $this->nb_not_read; ?> non lu<?php echo $this->nb_not_read > 1 ? 's' : ''; ?>)<?php } ?></span>
- </a>
+ <a href="<?php echo Url::display (array ()); ?>">Flux RSS</a>
</li>
<?php if (!login_is_conf ($this->conf) || is_logged ()) { ?>
@@ -36,12 +34,22 @@
<?php if (isset ($this->cat_aside)) { ?>
<ul id="categories">
- <li class="all<?php echo !$this->get ? ' active' : ''; ?>"><a href="<?php echo Url::display (array ()); ?>">Tous <span><?php echo $this->nb_total; ?> article<?php echo $this->nb_total > 1 ? 's' : ''; ?></span></a></li>
+ <li class="all<?php echo !$this->get ? ' active' : ''; ?>">
+ <a href="<?php echo Url::display (array ()); ?>">
+ Tous
+ <span><?php echo $this->nb_total; ?> article<?php echo $this->nb_total > 1 ? 's' : ''; ?> (<span class="nb_not_read"><?php echo $this->nb_not_read; ?></span>)</span>
+ </a>
+ </li>
<li class="favorites<?php echo $this->get == 'favoris' ? ' active' : ''; ?>"><a href="<?php echo Url::display (array ('params' => array ('get' => 'favoris'))); ?>">Favoris <span><?php echo $this->nb_favorites; ?> article<?php echo $this->nb_favorites > 1 ? 's' : ''; ?></span></a></li>
<?php foreach ($this->cat_aside as $cat) { ?>
- <li class="category<?php echo $this->get == $cat->id () ? ' active' : ''; ?>"><a href="<?php echo Url::display (array ('params' => array ('get' => $cat->id ()))); ?>"><?php echo $cat->name (); ?> <span><?php echo $cat->nbFeed (); ?> flux</span></a></li>
+ <li class="category<?php echo $this->get == $cat->id () ? ' active' : ''; ?>">
+ <a href="<?php echo Url::display (array ('params' => array ('get' => $cat->id ()))); ?>">
+ <?php echo $cat->name (); ?>
+ <span><?php echo $cat->nbFeed (); ?> flux (<?php echo $cat->nbNotRead (); ?>)</span>
+ </a>
+ </li>
<?php } ?>
</ul>
<?php } ?>
diff --git a/app/models/Category.php b/app/models/Category.php
index 47ed913c9..ceecea453 100755
--- a/app/models/Category.php
+++ b/app/models/Category.php
@@ -27,6 +27,10 @@ class Category extends Model {
$catDAO = new CategoryDAO ();
return $catDAO->countFeed ($this->id ());
}
+ public function nbNotRead () {
+ $catDAO = new CategoryDAO ();
+ return $catDAO->countNotRead ($this->id ());
+ }
public function _id ($value) {
$this->id = $value;
@@ -134,6 +138,16 @@ class CategoryDAO extends Model_pdo {
return $res[0]['count'];
}
+
+ public function countNotRead ($id) {
+ $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE category=? AND e.is_read=0';
+ $stm = $this->bd->prepare ($sql);
+ $values = array ($id);
+ $stm->execute ($values);
+ $res = $stm->fetchAll (PDO::FETCH_ASSOC);
+
+ return $res[0]['count'];
+ }
}
class HelperCategory {
diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml
index 9283c89cb..710b04988 100644
--- a/app/views/javascript/main.phtml
+++ b/app/views/javascript/main.phtml
@@ -35,28 +35,14 @@ function slide (new_active, old_active) {
}
function add_not_read (nb) {
- span_not_read = $("#main_aside #menu a span.nb_not_read");
+ span_not_read = $("#categories li.all span.nb_not_read");
html = span_not_read.html ();
- if (html == "" && nb > 0) {
- nb_not_read = nb;
- } else if (html != "") {
- regex = /\((\d+) non lus?\)/;
- nb_not_read = parseInt (regex.exec (html)[1]) + nb;
- } else {
- nb_not_read = 0;
- }
- pluriel = "";
- if (nb_not_read > 1) {
- pluriel = "s";
- }
+ regex = /(\d+)/;
+ nb_not_read = parseInt (regex.exec (html)[1]) + nb;
- if (nb_not_read > 0) {
- span_not_read.html ("(" + nb_not_read + " non lu" + pluriel + ")");
- } else {
- span_not_read.html ("");
- }
+ span_not_read.html (nb_not_read);
}
function mark_read (active) {
diff --git a/public/theme/base.css b/public/theme/base.css
index 4e06670c2..41ecca310 100644
--- a/public/theme/base.css
+++ b/public/theme/base.css
@@ -130,7 +130,7 @@ form {
.aside li.disable > span {
background: #fff;
}
- .aside li > a span {
+ .aside li > a > span {
float: right;
padding: 0 5px;
font-size: 80%;