From 32ee8feccfb28aa3141469581cd04d4813fd6835 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 25 Oct 2012 15:52:54 +0200 Subject: [PATCH] =?UTF-8?q?affichage=20du=20nombre=20d'articles=20pour=20u?= =?UTF-8?q?n=20flux=20donn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/layout/aside.phtml | 2 +- app/models/Category.php | 6 +++--- app/models/Feed.php | 14 ++++++++++++++ app/views/configure/flux.phtml | 2 +- lib/Request.php | 4 ++-- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/layout/aside.phtml b/app/layout/aside.phtml index 0b1d3f4f4..525357ea5 100644 --- a/app/layout/aside.phtml +++ b/app/layout/aside.phtml @@ -14,7 +14,7 @@ diff --git a/app/models/Category.php b/app/models/Category.php index 6e2847b51..47ed913c9 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -23,9 +23,9 @@ class Category extends Model { public function color () { return $this->color; } - public function nbFlux () { + public function nbFeed () { $catDAO = new CategoryDAO (); - return $catDAO->countFlux ($this->id ()); + return $catDAO->countFeed ($this->id ()); } public function _id ($value) { @@ -125,7 +125,7 @@ class CategoryDAO extends Model_pdo { return $res[0]['count']; } - public function countFlux ($id) { + public function countFeed ($id) { $sql = 'SELECT COUNT(*) AS count FROM feed WHERE category=?'; $stm = $this->bd->prepare ($sql); $values = array ($id); diff --git a/app/models/Feed.php b/app/models/Feed.php index 92a20eb80..399c34d18 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -37,6 +37,10 @@ class Feed extends Model { public function description () { return $this->description; } + public function nbEntries () { + $feedDAO = new FeedDAO (); + return $feedDAO->countEntries ($this->id ()); + } public function _url ($value) { if (!is_null ($value) && filter_var ($value, FILTER_VALIDATE_URL)) { @@ -186,6 +190,16 @@ class FeedDAO extends Model_pdo { return $res[0]['count']; } + + public function countEntries ($id) { + $sql = 'SELECT COUNT(*) AS count FROM entry WHERE 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 { diff --git a/app/views/configure/flux.phtml b/app/views/configure/flux.phtml index d21230895..fe1ddc644 100644 --- a/app/views/configure/flux.phtml +++ b/app/views/configure/flux.phtml @@ -23,7 +23,7 @@ flux->website (); ?> - Coming soon + flux->nbEntries (); ?> categories)) { ?> diff --git a/lib/Request.php b/lib/Request.php index 4f06be1d8..fe168b05f 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -59,8 +59,8 @@ class Request { self::$params = $params; } - public static function _param ($key, $value = null) { - if (is_null ($value)) { + public static function _param ($key, $value = false) { + if ($value === false) { unset (self::$params[$key]); } else { self::$params[$key] = $value;