From fccbbd83341f93cd01ee6acdb6a20743927ad4ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Mon, 11 Jun 2012 21:30:25 +0200 Subject: [PATCH] Add tags in book detail --- book.php | 9 +++++---- bookdetail.php | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/book.php b/book.php index 03f835d..1740e98 100644 --- a/book.php +++ b/book.php @@ -9,6 +9,7 @@ require_once('base.php'); require_once('serie.php'); require_once('author.php'); +require_once('tag.php'); class Book extends Base { const ALL_BOOKS_ID = "calibre:books"; @@ -89,7 +90,7 @@ class Book extends Base { if (is_null ($this->tags)) { $this->tags = array (); - $result = parent::getDb ()->prepare('select name + $result = parent::getDb ()->prepare('select tags.id as id, name from books_tags_link, tags where tag = tags.id and book = ? @@ -97,7 +98,7 @@ class Book extends Base { $result->execute (array ($this->id)); while ($post = $result->fetchObject ()) { - array_push ($this->tags, $post->name); + array_push ($this->tags, new Tag ($post->id, $post->name)); } } return $this->tags; @@ -107,11 +108,11 @@ class Book extends Base { $tagList = null; foreach ($this->getTags () as $tag) { if ($tagList) { - $tagList = $tagList . ", " . $tag; + $tagList = $tagList . ", " . $tag->name; } else { - $tagList = $tag; + $tagList = $tag->name; } } return $tagList; diff --git a/bookdetail.php b/bookdetail.php index b8ac8f6..9efd897 100644 --- a/bookdetail.php +++ b/bookdetail.php @@ -12,6 +12,7 @@ require_once ("book.php"); $book = Book::getBookById($_GET["id"]); $authors = $book->getAuthors (); +$tags = $book->getTags (); ?>
@@ -26,15 +27,26 @@ $authors = $book->getAuthors (); foreach ($authors as $author) { if ($i > 0) echo ", "; ?> - getUri ()) ?>">name ?> + getUri ()) ?>">name ?> + +
+
+ 0) echo ", "; +?> + getUri ()) ?>">name ?>
-

+
getComment () ?>
\ No newline at end of file