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.

67 lines
2.2KB

  1. <?php
  2. /**
  3. * COPS (Calibre OPDS PHP Server) class file
  4. *
  5. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  6. * @author Sébastien Lucas <sebastien@slucas.fr>
  7. */
  8. require_once('base.php');
  9. class Serie extends Base {
  10. const ALL_SERIES_ID = "calibre:series";
  11. public $id;
  12. public $name;
  13. public function __construct($pid, $pname) {
  14. $this->id = $pid;
  15. $this->name = $pname;
  16. }
  17. public function getUri () {
  18. return "feed.php?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id";
  19. }
  20. public static function getCount() {
  21. $nSeries = parent::getDb ()->query('select count(*) from series')->fetchColumn();
  22. parent::addEntryClass (new Entry ("Series", self::ALL_SERIES_ID,
  23. "Alphabetical index of the $nSeries series", "text",
  24. array ( new LinkNavigation ("feed.php?page=".parent::PAGE_ALL_SERIES))));
  25. }
  26. public static function getSerieByBookId ($bookId) {
  27. $result = parent::getDb ()->prepare('select series.id as id, name
  28. from books_series_link, series
  29. where series.id = series and book = ?');
  30. $result->execute (array ($bookId));
  31. if ($post = $result->fetchObject ()) {
  32. return new Serie ($post->id, $post->name);
  33. }
  34. return NULL;
  35. }
  36. public static function getSerieById ($serieId) {
  37. $result = parent::getDb ()->prepare('select id, name from series where id = ?');
  38. $result->execute (array ($serieId));
  39. if ($post = $result->fetchObject ()) {
  40. return new Serie ($post->id, $post->name);
  41. }
  42. return NULL;
  43. }
  44. public static function getAllSeries() {
  45. $result = parent::getDb ()->query('select series.id as id, series.name as name, series.sort as sort, count(*) as count
  46. from series, books_series_link
  47. where series.id = series
  48. group by series.id, series.name, series.sort
  49. order by series.sort');
  50. while ($post = $result->fetchObject ())
  51. {
  52. parent::addEntryClass (new Entry ($post->sort, self::ALL_SERIES_ID.":".$post->id,
  53. "$post->count books", "text",
  54. array ( new LinkNavigation ("feed.php?page=".parent::PAGE_SERIE_DETAIL."&id=$post->id"))));
  55. }
  56. }
  57. }
  58. ?>