cops/customize.php

125 lines
5.1 KiB
PHP
Raw Normal View History

2013-05-29 22:30:37 +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");
2013-06-26 22:28:04 +03:00
header ("Content-Type:text/html;charset=utf-8");
2013-05-29 22:30:37 +03:00
$database = GetUrlParam (DB);
$use_fancybox = "";
if (getCurrentOption ("use_fancyapps") == 1) {
$use_fancybox = "checked='checked'";
}
2013-06-26 22:28:04 +03:00
$max_item_per_page = getCurrentOption ("max_item_per_page");
2013-05-29 22:30:37 +03:00
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2013-06-04 22:08:11 +03:00
<title><?php echo localize ("customize.title") ?></title>
2013-06-25 18:43:44 +03:00
<script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jQuery/jquery-1.10.1.min.js") ?>"></script>
<script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jquery-cookie/jquery.cookies.js") ?>"></script>
2013-05-29 22:30:37 +03:00
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Open+Sans:400,300italic,800,300,400italic,600,600italic,700,700italic,800italic' />
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
<link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
<script type="text/javascript">
2013-06-26 22:28:04 +03:00
2013-05-29 22:30:37 +03:00
function updateCookie (id) {
2013-06-26 22:28:04 +03:00
if($(id).prop('pattern') && !$(id).val().match(new RegExp ($(id).prop('pattern')))) {
return;
}
2013-05-29 22:30:37 +03:00
var name = $(id).attr('id');
var value = $(id).val ();
$.cookie(name, value);
}
function updateCookieFromCheckbox (id) {
var name = $(id).attr('id');
if ((/^style/).test (name)) {
name = "style";
}
2013-05-29 22:30:37 +03:00
if ($(id).is(":checked"))
{
if ($(id).is(':radio')) {
2013-06-11 23:00:05 +03:00
$.cookie(name, $(id).val ());
} else {
$.cookie(name, '1');
}
2013-05-29 22:30:37 +03:00
}
else
{
$.cookie(name, '0');
}
}
</script>
</head>
<body>
<div class="container">
<header>
<a class="headleft" href="index.php">
<img src="<?php echo getUrlWithVersion("images/home.png") ?>" alt="<?php echo localize ("home.alternate") ?>" />
</a>
<img class="headright" style="visibility: hidden;" id="searchImage" src="<?php echo getUrlWithVersion("images/setting64.png") ?>" alt="Settings and menu" />
<div class="headcenter">
2013-06-04 22:08:11 +03:00
<h1><?php echo localize ("customize.title") ?></h1>
2013-05-29 22:30:37 +03:00
</div>
</header>
<section>
<article class="frontpage">
2013-06-04 22:08:11 +03:00
<h2><?php echo localize ("customize.style") ?></h2>
<h4>
2013-05-29 22:30:37 +03:00
<?php
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
echo '<select id="style" onchange="updateCookie (this);">';
}
foreach (glob ("styles/style-*.css") as $filename) {
2013-05-29 22:30:37 +03:00
if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) {
$filename = $m [1];
}
$selected = "";
if (getCurrentOption ("style") == $filename) {
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
$selected = "selected='selected'";
} else {
$selected = "checked='checked'";
}
}
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
echo "<option value='{$filename}' {$selected}>{$filename}</option>";
} else {
echo "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' {$selected} /><label for='style-{$filename}'> {$filename} </label>";
2013-05-29 22:30:37 +03:00
}
}
if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
echo '</select>';
}
2013-05-29 22:30:37 +03:00
?>
</h4>
2013-05-29 22:30:37 +03:00
</article>
<article class="frontpage">
2013-06-04 22:08:11 +03:00
<h2><?php echo localize ("customize.fancybox") ?></h2>
2013-05-29 22:30:37 +03:00
<h4><input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" <?php echo $use_fancybox ?> /></h4>
</article>
2013-06-26 22:28:04 +03:00
<article class="frontpage">
<h2><?php echo localize ("customize.paging") ?></h2>
<h4><input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="<?php echo $max_item_per_page ?>" min="-1" max="1200" pattern="^[-+]?[0-9]+$" /></h4>
</article>
2013-05-29 22:30:37 +03:00
</section>
<footer>
</footer>
</div>
</body>
</html>