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)
|
2014-03-05 11:46:44 +02:00
|
|
|
|
* @author S<EFBFBD>bastien Lucas <sebastien@slucas.fr>
|
2012-06-02 09:48:07 +03:00
|
|
|
|
*
|
|
|
|
|
*/
|
2013-12-05 11:52:51 +02:00
|
|
|
|
|
2012-06-02 09:48:07 +03:00
|
|
|
|
require_once ("config.php");
|
|
|
|
|
require_once ("base.php");
|
|
|
|
|
require_once ("author.php");
|
**2012-11-22**
**Added global support for publishers**
Files modified:
*base.php*
- changed class Entry,
- adding a constant ```cops:publishers``` to the icon array for the feed.
- changed class Page
- added branches to the page selector switch
- changed Page->public function InitializeContent
- added call to pull publisher count from database
- changed class PageAllBooks
- changed it so ```getCurrentOption``` is actually used...
- added page descendant class ```PageAllPublishers```
- handles pulling the publishers category from database
- added page descendant class ```PagePublisherDetail```
- handles pulling the books per publisher data from database
- changed class PageQueryResult
- added constant and switches for publisher search scope
- abstract class Base
- added constants for the publisher pages
*book.php*
- added require statement for publisher.php
- added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher.
- changed class Book
- added query constant
- added publisher item
- added test in case no known publisher
- added publishername and url array elements for the JSON output
- added public function ```getPublisher```
- added public static function ```getBooksByPublisher``` to fire the query
- changed function getJson
- added publisher category to search
- added publishername (single) and publishertitle(plural) localization entries to i18n translation array
*index.php*
- added require statement for publisher.php
*lang/Localization_en.json
- added new localization entries for publisher labels (see below)
```
"publisher.alphabetical.many":"Alphabetical index of the {0} publishers",
"publisher.alphabetical.none":"Alphabetical index of absolutely no publisher",
"publisher.alphabetical.one":"Alphabetical index of the single publisher",
"publisher.name":"Publisher",
"publisher.title":"Publishers",
"publisherword.many":"{0} publishers",
"publisherword.none":"No publisher",
"publisherword.one":"1 publisher",
"search.result.publisher":"Search result for *{0}* in publishers",
```
*templates\bookdetail.html*
- added publisher label and item to bookdetail popup
*test\bookTest.php*
- added indices and names of publishers added to testdatabase as comment
- added test function ```testGetBooksByPublisher```
- changed test function testGetBookById to add assertion for publisher name
- changed test function testTypeaheadSearch to add search on partial publisher name.
*test\pageTest.php*
- changed test function testPageIndex to insert publisher category and adjust page indices
- changed test function testPageIndexWithCustomColum to adjust for the changed page indices
- added test function testPageAllPublishers
- added test function testPagePublishersDetail
- added test function testPageSearchScopePublishers
*test\BaseWithSomeBooks\metadata.db*
- added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks
Files added:
*publisher.php*
2013-11-22 23:08:09 +02:00
|
|
|
|
require_once ("publisher.php");
|
2012-06-02 09:48:07 +03:00
|
|
|
|
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");
|
2013-12-05 11:52:51 +02: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
|
2014-02-07 10:19:02 +02:00
|
|
|
|
if (preg_match("/(MantanoReader|FBReader|Stanza|Marvin|Aldiko|Moon+ Reader)/", $_SERVER['HTTP_USER_AGENT'])) {
|
2013-02-28 17:26:15 +02:00
|
|
|
|
header("location: feed.php");
|
2013-03-01 18:48:25 +02:00
|
|
|
|
exit ();
|
2013-02-28 17:26:15 +02:00
|
|
|
|
}
|
2013-12-05 11:52:51 +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
|
|
|
|
|
2013-12-05 11:52:51 +02:00
|
|
|
|
|
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.
|
2013-12-14 19:25:32 +02:00
|
|
|
|
Base::checkDatabaseAvailability ();
|
2013-12-05 11:52:51 +02:00
|
|
|
|
|
2013-12-10 22:34:19 +02:00
|
|
|
|
if ($config ['cops_fetch_protect'] == "1") {
|
|
|
|
|
session_start();
|
|
|
|
|
if (!isset($_SESSION['connected'])) {
|
|
|
|
|
$_SESSION['connected'] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 22:35:02 +02:00
|
|
|
|
header ("Content-Type:text/html;charset=utf-8");
|
2013-12-05 11:52:51 +02:00
|
|
|
|
|
2014-02-09 16:24:54 +02:00
|
|
|
|
$data = array("title" => $config['cops_title_default'],
|
|
|
|
|
"version" => VERSION,
|
|
|
|
|
"opds_url" => $config['cops_full_url'] . "feed.php",
|
|
|
|
|
"template" => getCurrentTemplate (),
|
|
|
|
|
"server_side_rendering" => useServerSideRendering (),
|
|
|
|
|
"current_css" => getCurrentCss (),
|
|
|
|
|
"favico" => $config['cops_icon'],
|
|
|
|
|
"getjson_url" => "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1));
|
|
|
|
|
$headcontent = file_get_contents('templates/' . getCurrentTemplate () . '/file.html');
|
|
|
|
|
$template = new doT ();
|
|
|
|
|
$dot = $template->template ($headcontent, NULL);
|
|
|
|
|
echo ($dot ($data));
|
|
|
|
|
?><body>
|
2013-08-22 16:20:30 +03:00
|
|
|
|
<?php
|
|
|
|
|
if (useServerSideRendering ()) {
|
|
|
|
|
// Get the data
|
2014-03-05 11:46:44 +02:00
|
|
|
|
require_once ("JSON_renderer.php");
|
|
|
|
|
$data = JSONRenderer::getJson (true);
|
2014-02-06 22:04:30 +02:00
|
|
|
|
|
2014-01-06 22:24:11 +02:00
|
|
|
|
echo serverSideRender ($data);
|
2013-08-22 16:20:30 +03:00
|
|
|
|
}
|
|
|
|
|
?>
|
2012-06-02 09:48:07 +03:00
|
|
|
|
</body>
|
2014-03-05 11:46:44 +02:00
|
|
|
|
</html>
|