Add ratings only in recent addition for now.
This commit is contained in:
parent
7c9f081219
commit
8838f15034
2 changed files with 22 additions and 3 deletions
23
book.php
23
book.php
|
@ -34,6 +34,7 @@ class Book extends Base {
|
|||
public $relativePath;
|
||||
public $seriesIndex;
|
||||
public $comment;
|
||||
public $rating;
|
||||
public $datas = NULL;
|
||||
public $authors = NULL;
|
||||
public $serie = NULL;
|
||||
|
@ -159,6 +160,20 @@ class Book extends Base {
|
|||
return $tagList;
|
||||
}
|
||||
|
||||
public function getRating () {
|
||||
if (is_null ($this->rating) || $this->rating == 0) {
|
||||
return "";
|
||||
}
|
||||
$retour = "";
|
||||
for ($i = 0; $i < $this->rating / 2; $i++) {
|
||||
$retour .= "★";
|
||||
}
|
||||
for ($i = 0; $i < 5 - $this->rating / 2; $i++) {
|
||||
$retour .= "☆";
|
||||
}
|
||||
return $retour;
|
||||
}
|
||||
|
||||
public function getComment ($withSerie = true) {
|
||||
$addition = "";
|
||||
$se = $this->getSerie ();
|
||||
|
@ -354,13 +369,17 @@ order by substr (upper (sort), 1, 1)");
|
|||
|
||||
public static function getAllRecentBooks() {
|
||||
global $config;
|
||||
$result = parent::getDb ()->query("select " . self::BOOK_COLUMNS . "
|
||||
from books left outer join comments on book = books.id
|
||||
$result = parent::getDb ()->query("select " . self::BOOK_COLUMNS . ", ratings.rating
|
||||
from books
|
||||
left outer join comments on comments.book = books.id
|
||||
left outer join books_ratings_link on books_ratings_link.book = books.id
|
||||
left outer join ratings on books_ratings_link.rating = ratings.id
|
||||
order by timestamp desc limit " . $config['cops_recentbooks_limit']);
|
||||
$entryArray = array();
|
||||
while ($post = $result->fetchObject ())
|
||||
{
|
||||
$book = new Book ($post);
|
||||
$book->rating = $post->rating;
|
||||
array_push ($entryArray, $book->getEntry ());
|
||||
}
|
||||
return $entryArray;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue