Change the way format are handled in HTML catalog.
More work remaining to make it clean
This commit is contained in:
parent
9a8e9bacae
commit
06ce256e55
16
book.php
16
book.php
|
@ -217,7 +217,7 @@ from data where book = ?');
|
||||||
if (array_key_exists ($ext, self::$mimetypes))
|
if (array_key_exists ($ext, self::$mimetypes))
|
||||||
{
|
{
|
||||||
array_push ($linkArray, $this->getLink ($ext, self::$mimetypes [$ext], Link::OPDS_ACQUISITION_TYPE, $post->name . "." . strtolower ($post->format), $post->id, "Download"));
|
array_push ($linkArray, $this->getLink ($ext, self::$mimetypes [$ext], Link::OPDS_ACQUISITION_TYPE, $post->name . "." . strtolower ($post->format), $post->id, "Download"));
|
||||||
$this->format [$ext] = $post->name . "." . strtolower ($post->format);
|
$this->format [$post->format] = array ($post->id, $post->name . "." . strtolower ($post->format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,6 +318,20 @@ where books.id = ?');
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getBookByDataId($dataId) {
|
||||||
|
$result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . '
|
||||||
|
from data, books left outer join comments on comments.book = books.id
|
||||||
|
where data.book = books.id and data.id = ?');
|
||||||
|
$entryArray = array();
|
||||||
|
$result->execute (array ($dataId));
|
||||||
|
while ($post = $result->fetchObject ())
|
||||||
|
{
|
||||||
|
$book = new Book ($post);
|
||||||
|
return $book;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getBooksByQuery($query) {
|
public static function getBooksByQuery($query) {
|
||||||
$result = parent::getDb ()->prepare("select " . self::BOOK_COLUMNS . "
|
$result = parent::getDb ()->prepare("select " . self::BOOK_COLUMNS . "
|
||||||
from books left outer join comments on book = books.id
|
from books left outer join comments on book = books.id
|
||||||
|
|
|
@ -73,4 +73,11 @@
|
||||||
* http://www.php.net/manual/en/timezones.php
|
* http://www.php.net/manual/en/timezones.php
|
||||||
*/
|
*/
|
||||||
$config['default_timezone'] = "Europe/Paris";
|
$config['default_timezone'] = "Europe/Paris";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prefered format for HTML catalog
|
||||||
|
* The two first will be displayed in book entries
|
||||||
|
* The other only appear in book detail
|
||||||
|
*/
|
||||||
|
$config['cops_prefered_format'] = array ("EPUB", "PDF");
|
||||||
?>
|
?>
|
11
fetch.php
11
fetch.php
|
@ -14,10 +14,17 @@
|
||||||
header("Pragma: public");
|
header("Pragma: public");
|
||||||
header("Cache-Control: maxage=".$expires);
|
header("Cache-Control: maxage=".$expires);
|
||||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
|
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
|
||||||
$bookId = $_GET["id"];
|
$bookId = getURLParam ("id", NULL);
|
||||||
$book = Book::getBookById($bookId);
|
|
||||||
$type = getURLParam ("type", "jpg");
|
$type = getURLParam ("type", "jpg");
|
||||||
$idData = getURLParam ("data", NULL);
|
$idData = getURLParam ("data", NULL);
|
||||||
|
if (is_null ($bookId))
|
||||||
|
{
|
||||||
|
$book = Book::getBookByDataId($idData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$book = Book::getBookById($bookId);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
|
|
14
index.php
14
index.php
|
@ -153,17 +153,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="download">
|
<div class="download">
|
||||||
<?php
|
<?php
|
||||||
if (array_key_exists("epub", $entry->book->format)) {
|
foreach ($config['cops_prefered_format'] as $format)
|
||||||
|
{
|
||||||
|
if (array_key_exists($format, $entry->book->format)) {
|
||||||
?>
|
?>
|
||||||
<div class="button buttonEffect"><a href="<?php echo "download/" . $entry->book->id . "/" . urlencode ($entry->book->format ["epub"]) ?>">EPUB</a></div>
|
<div class="button buttonEffect"><a href="<?php echo "download/" . $entry->book->format [$format][0] . "/" . urlencode ($entry->book->format [$format][1]) ?>"><?php echo $format ?></a></div>
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<?php
|
|
||||||
if (array_key_exists("pdf", $entry->book->format)) {
|
|
||||||
?>
|
|
||||||
<div class="button buttonEffect"><a href="<?php echo "download/" . $entry->book->id . "/" . urlencode ($entry->book->format ["pdf"]) ?>">PDF</a></div>
|
|
||||||
<?php
|
<?php
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue