Add ratings only in recent addition for now.

This commit is contained in:
Sébastien Lucas 2012-12-04 10:58:39 +01:00
parent 7c9f081219
commit 8838f15034
2 changed files with 22 additions and 3 deletions

View file

@ -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 .= "&#9733;";
}
for ($i = 0; $i < 5 - $this->rating / 2; $i++) {
$retour .= "&#9734;";
}
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;

View file

@ -225,7 +225,7 @@
</div>
<div class="bookdetail">
<a class="navigation" href="bookdetail.php?id=<?php echo $entry->book->id ?>" />
<div class="entryTitle st"><?php echo htmlspecialchars ($entry->title) ?> <span class="sp">(<?php echo date ('Y', $entry->book->pubdate) ?>)</span></div>
<div class="entryTitle st"><?php echo htmlspecialchars ($entry->title) ?> <span class="sp">(<?php echo date ('Y', $entry->book->pubdate) ?>)</span> <span class="sr"><?php echo $entry->book->getRating () ?></span></div>
<div class="entryContent sa"><?php echo localize("authors.title") . " : " . htmlspecialchars ($entry->book->getAuthorsName ()) ?></div>
<div class="entryContent"><?php echo localize("tags.title") . " : " . htmlspecialchars ($entry->book->getTagsName ()) ?></div>
<?php