From 4c234a84f1323fe1b5345e75cac7c72085890f74 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 27 Feb 2014 11:44:11 +0100 Subject: [PATCH] ratings category fixes --- index.php | 2 +- rating.php | 18 +++++++++--------- test/pageTest.php | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/index.php b/index.php index 0dbeb4f..bb53226 100644 --- a/index.php +++ b/index.php @@ -10,7 +10,7 @@ require_once ("config.php"); require_once ("base.php"); require_once ("author.php"); - require_once ("rating.php"); + require_once ("rating.php"); require_once ("publisher.php"); require_once ("serie.php"); require_once ("tag.php"); diff --git a/rating.php b/rating.php index 074a1d9..0c7e4b4 100644 --- a/rating.php +++ b/rating.php @@ -11,7 +11,7 @@ require_once('base.php'); class Rating extends Base { const ALL_RATING_ID = "cops:rating"; - const AUTHOR_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count"; + const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count"; const SQL_ALL_RATINGS ="select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating"; public $id; public $name; @@ -31,9 +31,9 @@ class Rating extends Base { } public static function getCount() { - $nAuthors = parent::getDb ()->query('select count(*) from ratings')->fetchColumn(); + $nRatings = parent::getDb ()->query('select count(*) from ratings')->fetchColumn(); $entry = new Entry (localize("rating.title"), self::ALL_RATING_ID, - str_format (localize("ratings", $nAuthors), $nAuthors), "text", + str_format (localize("ratings", $nRatings), $nRatings), "text", array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RATINGS))); return $entry; } @@ -43,16 +43,16 @@ class Rating extends Base { } public static function getEntryArray ($query, $params) { - list ($totalNumber, $result) = parent::executeQuery ($query, self::AUTHOR_COLUMNS, "", $params, -1); + list ($totalNumber, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); $entryArray = array(); while ($post = $result->fetchObject ()) { - $rating = new Rating ($post->id, $post->rating); - $bewertung=$post->rating/2; - $bewertung.=" Sterne"; - array_push ($entryArray, new Entry ($bewertung, $rating->getEntryId (), + $ratingObj = new Rating ($post->id, $post->rating); + $rating=$post->rating/2; + $rating = str_format (localize("ratingword", $rating), $rating); + array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (), str_format (localize("bookword", $post->count), $post->count), "text", - array ( new LinkNavigation ($rating->getUri ())))); + array ( new LinkNavigation ($ratingObj->getUri ())))); } return $entryArray; } diff --git a/test/pageTest.php b/test/pageTest.php index 2dc0577..d6709a4 100644 --- a/test/pageTest.php +++ b/test/pageTest.php @@ -23,7 +23,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage->InitializeContent (); $this->assertEquals ($config['cops_title_default'], $currentPage->title); - $this->assertCount (7, $currentPage->entryArray); + $this->assertCount (8, $currentPage->entryArray); $this->assertEquals ("Authors", $currentPage->entryArray [0]->title); $this->assertEquals ("Alphabetical index of the 5 authors", $currentPage->entryArray [0]->content); $this->assertEquals ("Series", $currentPage->entryArray [1]->title); @@ -55,7 +55,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage->InitializeContent (); $this->assertEquals ($config['cops_title_default'], $currentPage->title); - $this->assertCount (2, $currentPage->entryArray); + $this->assertCount (3, $currentPage->entryArray); $this->assertEquals ("All books", $currentPage->entryArray [0]->title); $this->assertEquals ("Alphabetical index of the 14 books", $currentPage->entryArray [0]->content); $this->assertEquals ("Recent additions", $currentPage->entryArray [1]->title); @@ -77,7 +77,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent (); - $this->assertCount (8, $currentPage->entryArray); + $this->assertCount (9, $currentPage->entryArray); $this->assertEquals ("Type1", $currentPage->entryArray [5]->title); $this->assertEquals ("Alphabetical index of the 2 tags", $currentPage->entryArray [5]->content); @@ -86,7 +86,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent (); - $this->assertCount (8, $currentPage->entryArray); + $this->assertCount (9, $currentPage->entryArray); $this->assertEquals ("Type2", $currentPage->entryArray [5]->title); $this->assertEquals ("Alphabetical index of the 3 tags", $currentPage->entryArray [5]->content); @@ -95,7 +95,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent (); - $this->assertCount (8, $currentPage->entryArray); + $this->assertCount (9, $currentPage->entryArray); $this->assertEquals ("Type4", $currentPage->entryArray [5]->title); $this->assertEquals ("Alphabetical index of the 2 tags", $currentPage->entryArray [5]->content); @@ -104,7 +104,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent (); - $this->assertCount (10, $currentPage->entryArray); + $this->assertCount (11, $currentPage->entryArray); $config['cops_calibre_custom_column'] = array (); }