Refactor the use of fetch.php to prepare multi database. re #40

This commit is contained in:
Sébastien Lucas 2013-04-03 20:59:53 +02:00
parent d86d544074
commit f5d86b37e5
2 changed files with 18 additions and 16 deletions

View file

@ -329,15 +329,8 @@ class Book extends Base {
if ($this->hasCover) if ($this->hasCover)
{ {
array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)); 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"])) { array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
$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));
} }
foreach ($this->getDatas () as $data) foreach ($this->getDatas () as $data)

View file

@ -111,18 +111,27 @@ class Data extends Base {
{ {
global $config; global $config;
$textData = ""; $urlParam = addURLParameter("", "data", $idData);
if (!is_null ($idData))
{
$textData = "&data=" . $idData;
}
if (preg_match ('/^\//', Base::getDbDirectory ()) || // Linux / if (preg_match ('/^\//', Base::getDbDirectory ()) || // Linux /
preg_match ('/^\w\:/', Base::getDbDirectory ()) || // Windows X: preg_match ('/^\w\:/', Base::getDbDirectory ()) || // Windows X:
$rel == Link::OPDS_THUMBNAIL_TYPE ||
($type == "epub" && $config['cops_update_epub-metadata'])) ($type == "epub" && $config['cops_update_epub-metadata']))
{ {
if ($type != "jpg") $textData .= "&type=" . $type; if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type);
return new Link ("fetch.php?id=$book->id" . $textData, $mime, $rel, $title); 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 else
{ {