Add tags in book detail
This commit is contained in:
parent
f332f072fb
commit
fccbbd8334
9
book.php
9
book.php
|
@ -9,6 +9,7 @@
|
||||||
require_once('base.php');
|
require_once('base.php');
|
||||||
require_once('serie.php');
|
require_once('serie.php');
|
||||||
require_once('author.php');
|
require_once('author.php');
|
||||||
|
require_once('tag.php');
|
||||||
|
|
||||||
class Book extends Base {
|
class Book extends Base {
|
||||||
const ALL_BOOKS_ID = "calibre:books";
|
const ALL_BOOKS_ID = "calibre:books";
|
||||||
|
@ -89,7 +90,7 @@ class Book extends Base {
|
||||||
if (is_null ($this->tags)) {
|
if (is_null ($this->tags)) {
|
||||||
$this->tags = array ();
|
$this->tags = array ();
|
||||||
|
|
||||||
$result = parent::getDb ()->prepare('select name
|
$result = parent::getDb ()->prepare('select tags.id as id, name
|
||||||
from books_tags_link, tags
|
from books_tags_link, tags
|
||||||
where tag = tags.id
|
where tag = tags.id
|
||||||
and book = ?
|
and book = ?
|
||||||
|
@ -97,7 +98,7 @@ class Book extends Base {
|
||||||
$result->execute (array ($this->id));
|
$result->execute (array ($this->id));
|
||||||
while ($post = $result->fetchObject ())
|
while ($post = $result->fetchObject ())
|
||||||
{
|
{
|
||||||
array_push ($this->tags, $post->name);
|
array_push ($this->tags, new Tag ($post->id, $post->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->tags;
|
return $this->tags;
|
||||||
|
@ -107,11 +108,11 @@ class Book extends Base {
|
||||||
$tagList = null;
|
$tagList = null;
|
||||||
foreach ($this->getTags () as $tag) {
|
foreach ($this->getTags () as $tag) {
|
||||||
if ($tagList) {
|
if ($tagList) {
|
||||||
$tagList = $tagList . ", " . $tag;
|
$tagList = $tagList . ", " . $tag->name;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tagList = $tag;
|
$tagList = $tag->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $tagList;
|
return $tagList;
|
||||||
|
|
|
@ -12,6 +12,7 @@ require_once ("book.php");
|
||||||
|
|
||||||
$book = Book::getBookById($_GET["id"]);
|
$book = Book::getBookById($_GET["id"]);
|
||||||
$authors = $book->getAuthors ();
|
$authors = $book->getAuthors ();
|
||||||
|
$tags = $book->getTags ();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="bookpopup">
|
<div class="bookpopup">
|
||||||
|
@ -26,15 +27,26 @@ $authors = $book->getAuthors ();
|
||||||
foreach ($authors as $author) {
|
foreach ($authors as $author) {
|
||||||
if ($i > 0) echo ", ";
|
if ($i > 0) echo ", ";
|
||||||
?>
|
?>
|
||||||
<a href="kobo.php<?php echo str_replace ("&", "&", $author->getUri ()) ?>"><?php echo $author->name ?></a>
|
<a href="index.php<?php echo str_replace ("&", "&", $author->getUri ()) ?>"><?php echo $author->name ?></a>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<div class="tags">
|
||||||
|
<?php
|
||||||
|
$i = 0;
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
if ($i > 0) echo ", ";
|
||||||
|
?>
|
||||||
|
<a href="index.php<?php echo str_replace ("&", "&", $tag->getUri ()) ?>"><?php echo $tag->name ?></a>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearer" />
|
<div class="clearer" />
|
||||||
<div><?php echo localize("content.summary") ?></div>
|
|
||||||
<hr />
|
<hr />
|
||||||
|
<div><?php echo localize("content.summary") ?></div>
|
||||||
<?php echo $book->getComment () ?>
|
<?php echo $book->getComment () ?>
|
||||||
<hr />
|
<hr />
|
||||||
</div>
|
</div>
|
Loading…
Reference in a new issue