From f5d86b37e51c0a274e607c75aa83fc2d028233f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Wed, 3 Apr 2013 20:59:53 +0200 Subject: [PATCH] Refactor the use of fetch.php to prepare multi database. re #40 --- book.php | 11 ++--------- data.php | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/book.php b/book.php index c37e187..5fd8367 100644 --- a/book.php +++ b/book.php @@ -329,15 +329,8 @@ class Book extends Base { if ($this->hasCover) { array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)); - $height = "50"; - if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { - $height = $config['cops_opds_thumbnail_height']; - } - else - { - $height = $config['cops_html_thumbnail_height']; - } - array_push ($linkArray, new Link ("fetch.php?id=$this->id&height=" . $height, "image/jpeg", Link::OPDS_THUMBNAIL_TYPE)); + + array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL)); } foreach ($this->getDatas () as $data) diff --git a/data.php b/data.php index 3602314..1ed427f 100644 --- a/data.php +++ b/data.php @@ -111,18 +111,27 @@ class Data extends Base { { global $config; - $textData = ""; - if (!is_null ($idData)) - { - $textData = "&data=" . $idData; - } + $urlParam = addURLParameter("", "data", $idData); if (preg_match ('/^\//', Base::getDbDirectory ()) || // Linux / preg_match ('/^\w\:/', Base::getDbDirectory ()) || // Windows X: + $rel == Link::OPDS_THUMBNAIL_TYPE || ($type == "epub" && $config['cops_update_epub-metadata'])) { - if ($type != "jpg") $textData .= "&type=" . $type; - return new Link ("fetch.php?id=$book->id" . $textData, $mime, $rel, $title); + if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type); + if ($rel == Link::OPDS_THUMBNAIL_TYPE) { + $height = "50"; + if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { + $height = $config['cops_opds_thumbnail_height']; + } + else + { + $height = $config['cops_html_thumbnail_height']; + } + $urlParam = addURLParameter($urlParam, "height", $height); + } + $urlParam = addURLParameter($urlParam, "id", $book->id); + return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); } else {