2012-06-02 09:48:07 +03:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
2012-06-12 23:52:39 +03:00
|
|
|
|
* COPS (Calibre OPDS PHP Server) HTML main script
|
2012-06-02 09:48:07 +03:00
|
|
|
|
*
|
|
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
2012-09-03 16:57:35 +03:00
|
|
|
|
* @author S<EFBFBD>bastien Lucas <sebastien@slucas.fr>
|
2012-06-02 09:48:07 +03:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
require_once ("config.php");
|
|
|
|
|
require_once ("base.php");
|
|
|
|
|
require_once ("author.php");
|
|
|
|
|
require_once ("serie.php");
|
|
|
|
|
require_once ("tag.php");
|
2013-05-21 20:49:21 +03:00
|
|
|
|
require_once ("language.php");
|
2013-01-19 08:08:47 +02:00
|
|
|
|
require_once ("customcolumn.php");
|
2012-06-02 09:48:07 +03:00
|
|
|
|
require_once ("book.php");
|
2013-08-22 16:20:30 +03:00
|
|
|
|
require_once ("resources/doT-php/doT.php");
|
2012-06-02 09:48:07 +03:00
|
|
|
|
|
2013-02-28 17:26:15 +02:00
|
|
|
|
// If we detect that an OPDS reader try to connect try to redirect to feed.php
|
|
|
|
|
if (preg_match("/(MantanoReader|FBReader|Stanza|Aldiko|Moon+ Reader)/", $_SERVER['HTTP_USER_AGENT'])) {
|
|
|
|
|
header("location: feed.php");
|
2013-03-01 18:48:25 +02:00
|
|
|
|
exit ();
|
2013-02-28 17:26:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-02 09:48:07 +03:00
|
|
|
|
$page = getURLParam ("page", Base::PAGE_INDEX);
|
|
|
|
|
$query = getURLParam ("query");
|
|
|
|
|
$qid = getURLParam ("id");
|
2012-09-19 19:20:01 +03:00
|
|
|
|
$n = getURLParam ("n", "1");
|
2013-04-08 18:28:45 +03:00
|
|
|
|
$database = GetUrlParam (DB);
|
2013-11-25 22:35:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Access the database ASAP to be sure it's readable, redirect if that's not the case.
|
|
|
|
|
// It has to be done before any header is sent.
|
|
|
|
|
if (is_array ($config['calibre_directory']) && is_null ($database)) {
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach (array_keys ($config['calibre_directory']) as $key) {
|
|
|
|
|
$test = Base::getDb ($i);
|
|
|
|
|
Base::clearDb ();
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$test = Base::getDb ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header ("Content-Type:text/html;charset=utf-8");
|
2013-09-05 15:45:42 +03:00
|
|
|
|
?><!DOCTYPE html>
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
2012-06-02 09:48:07 +03:00
|
|
|
|
<head>
|
2013-05-16 18:12:19 +03:00
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
2013-08-11 20:32:07 +03:00
|
|
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
|
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
|
|
|
|
<link rel="apple-touch-icon" href="./icons/icon57.png" />
|
|
|
|
|
<link rel="apple-touch-icon" sizes="72x72" href="./icons/icon72.png" />
|
|
|
|
|
<link rel="apple-touch-icon" sizes="114x114" href="./icons/icon114.png" />
|
|
|
|
|
<link rel="apple-touch-icon" sizes="144x144" href="./icons/icon144.png" />
|
|
|
|
|
|
2013-06-15 09:03:22 +03:00
|
|
|
|
<title>COPS</title>
|
2013-09-05 09:41:40 +03:00
|
|
|
|
|
2013-07-21 23:14:24 +03:00
|
|
|
|
<script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jQuery/jquery-1.10.2.min.js") ?>"></script>
|
2013-06-18 13:33:33 +03:00
|
|
|
|
<script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jquery-cookie/jquery.cookies.js") ?>"></script>
|
2013-09-05 09:41:40 +03:00
|
|
|
|
<script type="text/javascript" src="<?php echo getUrlWithVersion("js/jquery.sortElements.js") ?>"></script>
|
|
|
|
|
<?php if (!useServerSideRendering ()) { ?>
|
2013-06-25 09:53:04 +03:00
|
|
|
|
<script type="text/javascript" src="<?php echo getUrlWithVersion("resources/Magnific-Popup/jquery.magnific-popup.min.js") ?>"></script>
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/Magnific-Popup/magnific-popup.css") ?>" media="screen" />
|
2013-06-15 09:03:22 +03:00
|
|
|
|
<script type="text/javascript" src="<?php echo getUrlWithVersion("resources/doT/doT.min.js") ?>"></script>
|
2013-06-20 22:08:50 +03:00
|
|
|
|
<script type="text/javascript" src="<?php echo getUrlWithVersion("resources/lru/lru.js") ?>"></script>
|
2013-10-13 23:18:46 +03:00
|
|
|
|
<script type="text/javascript" src="<?php echo getUrlWithVersion("resources/typeahead/typeahead.js") ?>"></script>
|
2013-09-05 09:41:40 +03:00
|
|
|
|
<?php } ?>
|
2013-06-15 09:03:22 +03:00
|
|
|
|
<script type="text/javascript" src="<?php echo getUrlWithVersion("util.js") ?>"></script>
|
2013-03-08 10:43:37 +02:00
|
|
|
|
<link rel="related" href="<?php echo $config['cops_full_url'] ?>feed.php" type="application/atom+xml;profile=opds-catalog" title="<?php echo $config['cops_title_default']; ?>" />
|
2013-08-26 11:49:23 +03:00
|
|
|
|
<link rel="icon" type="image/vnd.microsoft.icon" href="<?php echo $config['cops_icon']; ?>" />
|
2013-05-17 07:36:38 +03:00
|
|
|
|
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
|
2013-07-19 18:59:13 +03:00
|
|
|
|
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("styles/font-awesome.css") ?>" media="screen" />
|
2013-07-11 22:12:28 +03:00
|
|
|
|
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
|
2013-08-22 16:20:30 +03:00
|
|
|
|
<?php if (!useServerSideRendering ()) { ?>
|
2012-06-02 09:48:07 +03:00
|
|
|
|
<script type="text/javascript">
|
2013-11-28 22:41:16 +02:00
|
|
|
|
console.log ("Start");
|
2012-06-02 09:48:07 +03:00
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
// Handler for .ready() called.
|
2013-11-28 22:41:16 +02:00
|
|
|
|
console.log ("Start Ready");
|
2013-11-28 22:19:06 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
2013-06-25 09:40:08 +03:00
|
|
|
|
var url = "<?php echo "getJSON.php?" . addURLParameter ($_SERVER["QUERY_STRING"], "complete", 1); ?>";
|
2013-06-20 22:21:43 +03:00
|
|
|
|
|
2013-06-16 09:46:41 +03:00
|
|
|
|
$.when($.get('templates/default/header.html'),
|
|
|
|
|
$.get('templates/default/footer.html'),
|
|
|
|
|
$.get('templates/default/bookdetail.html'),
|
|
|
|
|
$.get('templates/default/main.html'),
|
|
|
|
|
$.get('templates/default/page.html'),
|
2013-10-13 23:20:08 +03:00
|
|
|
|
$.get('templates/default/suggestion.html'),
|
|
|
|
|
$.getJSON(url)).done(function(header, footer, bookdetail, main, page, suggestion, data){
|
2013-06-16 09:46:41 +03:00
|
|
|
|
templateBookDetail = doT.template (bookdetail [0]);
|
2013-11-28 22:41:16 +02:00
|
|
|
|
console.log ("Start When");
|
2013-06-16 09:46:41 +03:00
|
|
|
|
var defMain = {
|
|
|
|
|
bookdetail: bookdetail [0]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
templateMain = doT.template (main [0], undefined, defMain);
|
|
|
|
|
|
|
|
|
|
var defPage = {
|
|
|
|
|
header: header [0],
|
|
|
|
|
footer: footer [0],
|
|
|
|
|
main : main [0],
|
|
|
|
|
bookdetail: bookdetail [0]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
templatePage = doT.template (page [0], undefined, defPage);
|
2013-10-13 23:20:08 +03:00
|
|
|
|
|
|
|
|
|
templateSuggestion = doT.template (suggestion [0]);
|
|
|
|
|
|
2013-06-16 16:08:47 +03:00
|
|
|
|
currentData = data [0];
|
2013-06-16 09:46:41 +03:00
|
|
|
|
|
|
|
|
|
updatePage (data [0]);
|
2013-06-20 22:21:43 +03:00
|
|
|
|
cache.put (url, data [0]);
|
2013-11-25 22:18:38 +02:00
|
|
|
|
if (isPushStateEnabled) {
|
|
|
|
|
history.replaceState(url, "", window.location);
|
|
|
|
|
}
|
2013-07-16 22:56:55 +03:00
|
|
|
|
handleLinks ();
|
2013-06-15 17:09:37 +03:00
|
|
|
|
});
|
2013-11-28 22:19:06 +02:00
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
2013-11-28 22:41:16 +02:00
|
|
|
|
console.log ("Catch");
|
2013-11-28 22:19:06 +02:00
|
|
|
|
alert (e.message);
|
|
|
|
|
}
|
2012-06-02 09:48:07 +03:00
|
|
|
|
});
|
2013-06-15 09:03:22 +03:00
|
|
|
|
|
|
|
|
|
|
2012-10-11 22:43:37 +03:00
|
|
|
|
|
2012-06-02 09:48:07 +03:00
|
|
|
|
</script>
|
2013-08-22 16:20:30 +03:00
|
|
|
|
<?php } ?>
|
2012-06-02 09:48:07 +03:00
|
|
|
|
</head>
|
|
|
|
|
<body>
|
2013-08-22 16:20:30 +03:00
|
|
|
|
<?php
|
|
|
|
|
if (useServerSideRendering ()) {
|
|
|
|
|
// Get the templates
|
|
|
|
|
$header = file_get_contents('templates/default/header.html');
|
|
|
|
|
$footer = file_get_contents('templates/default/footer.html');
|
|
|
|
|
$main = file_get_contents('templates/default/main.html');
|
|
|
|
|
$bookdetail = file_get_contents('templates/default/bookdetail.html');
|
|
|
|
|
$page = file_get_contents('templates/default/page.html');
|
|
|
|
|
|
|
|
|
|
// Get the data
|
|
|
|
|
$data = getJson (true);
|
|
|
|
|
|
|
|
|
|
// Generate the function for the template
|
|
|
|
|
$template = new doT ();
|
|
|
|
|
$dot = $template->template ($page, array ("bookdetail" => $bookdetail,
|
|
|
|
|
"header" => $header,
|
|
|
|
|
"footer" => $footer,
|
|
|
|
|
"main" => $main));
|
|
|
|
|
// Execute the template
|
|
|
|
|
echo $dot ($data);
|
|
|
|
|
}
|
|
|
|
|
?>
|
2012-06-02 09:48:07 +03:00
|
|
|
|
</body>
|
2013-07-22 15:29:32 +03:00
|
|
|
|
</html>
|