Add ratings only in recent addition for now.
This commit is contained in:
parent
7c9f081219
commit
8838f15034
23
book.php
23
book.php
|
@ -34,6 +34,7 @@ class Book extends Base {
|
||||||
public $relativePath;
|
public $relativePath;
|
||||||
public $seriesIndex;
|
public $seriesIndex;
|
||||||
public $comment;
|
public $comment;
|
||||||
|
public $rating;
|
||||||
public $datas = NULL;
|
public $datas = NULL;
|
||||||
public $authors = NULL;
|
public $authors = NULL;
|
||||||
public $serie = NULL;
|
public $serie = NULL;
|
||||||
|
@ -159,6 +160,20 @@ class Book extends Base {
|
||||||
return $tagList;
|
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) {
|
public function getComment ($withSerie = true) {
|
||||||
$addition = "";
|
$addition = "";
|
||||||
$se = $this->getSerie ();
|
$se = $this->getSerie ();
|
||||||
|
@ -354,13 +369,17 @@ order by substr (upper (sort), 1, 1)");
|
||||||
|
|
||||||
public static function getAllRecentBooks() {
|
public static function getAllRecentBooks() {
|
||||||
global $config;
|
global $config;
|
||||||
$result = parent::getDb ()->query("select " . self::BOOK_COLUMNS . "
|
$result = parent::getDb ()->query("select " . self::BOOK_COLUMNS . ", ratings.rating
|
||||||
from books left outer join comments on book = books.id
|
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']);
|
order by timestamp desc limit " . $config['cops_recentbooks_limit']);
|
||||||
$entryArray = array();
|
$entryArray = array();
|
||||||
while ($post = $result->fetchObject ())
|
while ($post = $result->fetchObject ())
|
||||||
{
|
{
|
||||||
$book = new Book ($post);
|
$book = new Book ($post);
|
||||||
|
$book->rating = $post->rating;
|
||||||
array_push ($entryArray, $book->getEntry ());
|
array_push ($entryArray, $book->getEntry ());
|
||||||
}
|
}
|
||||||
return $entryArray;
|
return $entryArray;
|
||||||
|
|
|
@ -225,7 +225,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="bookdetail">
|
<div class="bookdetail">
|
||||||
<a class="navigation" href="bookdetail.php?id=<?php echo $entry->book->id ?>" />
|
<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 sa"><?php echo localize("authors.title") . " : " . htmlspecialchars ($entry->book->getAuthorsName ()) ?></div>
|
||||||
<div class="entryContent"><?php echo localize("tags.title") . " : " . htmlspecialchars ($entry->book->getTagsName ()) ?></div>
|
<div class="entryContent"><?php echo localize("tags.title") . " : " . htmlspecialchars ($entry->book->getTagsName ()) ?></div>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in a new issue