Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...) http://blog.slucas.fr/en/oss/calibre-opds-php-server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 2.7KB

**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*
10 years ago
8 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * COPS (Calibre OPDS PHP Server) HTML main script
  4. *
  5. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  6. * @author Sébastien Lucas <sebastien@slucas.fr>
  7. *
  8. */
  9. require_once ("config.php");
  10. require_once ("base.php");
  11. require_once ("author.php");
  12. require_once ("rating.php");
  13. require_once ("publisher.php");
  14. require_once ("serie.php");
  15. require_once ("tag.php");
  16. require_once ("language.php");
  17. require_once ("customcolumn.php");
  18. require_once ("book.php");
  19. require_once ("resources/doT-php/doT.php");
  20. // If we detect that an OPDS reader try to connect try to redirect to feed.php
  21. if (preg_match("/(MantanoReader|FBReader|Stanza|Marvin|Aldiko|Moon+ Reader|Chunky|AlReader|org\.ebookdroid)/", $_SERVER['HTTP_USER_AGENT'])) {
  22. header("location: feed.php");
  23. exit ();
  24. }
  25. $page = getURLParam ("page", Base::PAGE_INDEX);
  26. $query = getURLParam ("query");
  27. $qid = getURLParam ("id");
  28. $n = getURLParam ("n", "1");
  29. $database = GetUrlParam (DB);
  30. // Access the database ASAP to be sure it's readable, redirect if that's not the case.
  31. // It has to be done before any header is sent.
  32. Base::checkDatabaseAvailability ();
  33. if ($config ['cops_fetch_protect'] == "1") {
  34. session_start();
  35. if (!isset($_SESSION['connected'])) {
  36. $_SESSION['connected'] = 0;
  37. }
  38. }
  39. header ("Content-Type:text/html;charset=utf-8");
  40. $data = array("title" => $config['cops_title_default'],
  41. "version" => VERSION,
  42. "opds_url" => $config['cops_full_url'] . "feed.php",
  43. "customHeader" => "",
  44. "template" => getCurrentTemplate (),
  45. "server_side_rendering" => useServerSideRendering (),
  46. "current_css" => getCurrentCss (),
  47. "favico" => $config['cops_icon'],
  48. "getjson_url" => "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1));
  49. if (preg_match("/Kindle/", $_SERVER['HTTP_USER_AGENT'])) {
  50. $data ["customHeader"] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>';
  51. }
  52. $headcontent = file_get_contents('templates/' . getCurrentTemplate () . '/file.html');
  53. $template = new doT ();
  54. $dot = $template->template ($headcontent, NULL);
  55. echo ($dot ($data));
  56. ?><body>
  57. <?php
  58. if (useServerSideRendering ()) {
  59. // Get the data
  60. require_once ("JSON_renderer.php");
  61. $data = JSONRenderer::getJson (true);
  62. echo serverSideRender ($data);
  63. }
  64. ?>
  65. </body>
  66. </html>