ratings category fixes

This commit is contained in:
Michael 2014-02-27 11:44:11 +01:00
parent 4b7743397b
commit 4c234a84f1
3 changed files with 16 additions and 16 deletions

View File

@ -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");

View File

@ -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;
}

View File

@ -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 ();
}