2013-06-15 09:03:22 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* COPS (Calibre OPDS PHP Server) HTML main script
|
|
|
|
*
|
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
|
|
|
* @author Sébastien Lucas <sebastien@slucas.fr>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once ("config.php");
|
|
|
|
require_once ("base.php");
|
|
|
|
require_once ("author.php");
|
|
|
|
require_once ("serie.php");
|
|
|
|
require_once ("tag.php");
|
|
|
|
require_once ("language.php");
|
|
|
|
require_once ("customcolumn.php");
|
|
|
|
require_once ("book.php");
|
|
|
|
|
|
|
|
header ("Content-Type:application/json;charset=utf-8");
|
|
|
|
$page = getURLParam ("page", Base::PAGE_INDEX);
|
|
|
|
$query = getURLParam ("query");
|
|
|
|
$qid = getURLParam ("id");
|
|
|
|
$n = getURLParam ("n", "1");
|
|
|
|
$database = GetUrlParam (DB);
|
|
|
|
|
|
|
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
|
|
|
$currentPage->InitializeContent ();
|
|
|
|
|
2013-06-17 22:21:52 +03:00
|
|
|
$out = array ( "title" => $currentPage->title);
|
2013-06-15 09:43:38 +03:00
|
|
|
$entries = array ();
|
|
|
|
foreach ($currentPage->entryArray as $entry) {
|
|
|
|
array_push ($entries, $entry->getContentArray ());
|
|
|
|
}
|
2013-06-15 17:09:37 +03:00
|
|
|
if (!is_null ($currentPage->book)) {
|
|
|
|
$out ["book"] = $currentPage->book->getFullContentArray ();
|
|
|
|
}
|
2013-06-15 09:43:38 +03:00
|
|
|
$out ["databaseId"] = GetUrlParam (DB, "");
|
|
|
|
$out ["databaseName"] = Base::getDbName ();
|
|
|
|
$out ["page"] = $page;
|
|
|
|
$out ["entries"] = $entries;
|
|
|
|
$out ["isPaginated"] = 0;
|
|
|
|
if ($currentPage->isPaginated ()) {
|
|
|
|
$prevLink = $currentPage->getPrevLink ();
|
|
|
|
$nextLink = $currentPage->getNextLink ();
|
|
|
|
$out ["isPaginated"] = 1;
|
|
|
|
$out ["prevLink"] = "";
|
|
|
|
if (!is_null ($prevLink)) {
|
|
|
|
$out ["prevLink"] = $prevLink->hrefXhtml ();
|
|
|
|
}
|
|
|
|
$out ["nextLink"] = "";
|
|
|
|
if (!is_null ($nextLink)) {
|
|
|
|
$out ["nextLink"] = $nextLink->hrefXhtml ();
|
|
|
|
}
|
|
|
|
$out ["maxPage"] = $currentPage->getMaxPage ();
|
|
|
|
$out ["currentPage"] = $currentPage->n;
|
|
|
|
}
|
2013-06-16 16:21:21 +03:00
|
|
|
if (!is_null (getURLParam ("complete"))) {
|
2013-06-17 22:21:52 +03:00
|
|
|
$out ["const"] = array ("version" => VERSION, "i18n" => array (
|
2013-06-17 23:23:58 +03:00
|
|
|
"coverAlt" => localize("i18n.coversection"),
|
|
|
|
"authorsTitle" => localize("authors.title"),
|
|
|
|
"bookwordTitle" => localize("bookword.title"),
|
|
|
|
"tagsTitle" => localize("tags.title"),
|
|
|
|
"seriesTitle" => localize("series.title"),
|
|
|
|
"customizeTitle" => localize ("customize.title"),
|
|
|
|
"aboutTitle" => localize ("about.title"),
|
|
|
|
"previousAlt" => localize ("paging.previous.alternate"),
|
|
|
|
"nextAlt" => localize ("paging.next.alternate"),
|
|
|
|
"searchAlt" => localize ("search.alternate"),
|
|
|
|
"sortAlt" => localize ("sort.alternate"),
|
|
|
|
"homeAlt" => localize ("home.alternate"),
|
|
|
|
"permalinkAlt" => localize ("permalink.alternate"),
|
|
|
|
"pubdateTitle" => localize("pubdate.title"),
|
|
|
|
"languagesTitle" => localize("language.title"),
|
|
|
|
"contentTitle" => localize("content.summary"),
|
|
|
|
"sortorderAsc" => localize("search.sortorder.asc"),
|
|
|
|
"sortorderDesc" => localize("search.sortorder.desc")),
|
|
|
|
"url" => array (
|
2013-06-25 09:40:08 +03:00
|
|
|
"detailUrl" => "index.php?page=13&id={0}&db={1}",
|
|
|
|
"coverUrl" => "fetch.php?id={0}&db={1}",
|
|
|
|
"thumbnailUrl" => "fetch.php?height=70&id={0}&db={1}"),
|
2013-06-19 22:37:47 +03:00
|
|
|
"config" => array (
|
|
|
|
"use_fancyapps" => $config ["cops_use_fancyapps"],
|
|
|
|
"max_item_per_page" => $config['cops_max_item_per_page']));
|
2013-06-16 16:21:21 +03:00
|
|
|
}
|
2013-06-15 09:43:38 +03:00
|
|
|
|
|
|
|
$out ["containsBook"] = 0;
|
|
|
|
if ($currentPage->containsBook ()) {
|
|
|
|
$out ["containsBook"] = 1;
|
|
|
|
}
|
|
|
|
$out["abouturl"] = "about.xml";
|
|
|
|
if (getCurrentOption ('use_fancyapps') == 0) {
|
2013-06-25 09:40:08 +03:00
|
|
|
$out["abouturl"] = "index.php" . addURLParameter ("?page=16", DB, $database);
|
2013-06-15 09:43:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$out ["homeurl"] = "index.php";
|
|
|
|
if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter ("", DB, $database);
|
|
|
|
|
|
|
|
|
|
|
|
echo json_encode ($out);
|
2013-06-15 09:03:22 +03:00
|
|
|
|
|
|
|
?>
|