diff options
| author | fox <fox@fakecake.org> | 2026-06-15 22:12:27 +0300 |
|---|---|---|
| committer | fox <fox@fakecake.org> | 2026-06-15 22:12:27 +0300 |
| commit | 789758a094d4885432f165c0c8a419adeb55906c (patch) | |
| tree | b5e4229ed2119bcfc0b59cf3f634fd8fa503cf0c /classes/Handler/ListHandler.php | |
| parent | 3a87066a7cf645eb8f8ddbc5d031afe753516de9 (diff) | |
| parent | 7d5e7b0f95992650189b73c6160264db6b658bde (diff) | |
| download | the-epube-789758a094d4885432f165c0c8a419adeb55906c.tar.gz the-epube-789758a094d4885432f165c0c8a419adeb55906c.tar.xz | |
Merge branch 'dev' into 'master'
remove dedicated getinfo handler because list may operate on IDs; add some... See merge request git/the-epube!56
Diffstat (limited to 'classes/Handler/ListHandler.php')
| -rw-r--r-- | classes/Handler/ListHandler.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/classes/Handler/ListHandler.php b/classes/Handler/ListHandler.php index 9c65176..e8a5916 100644 --- a/classes/Handler/ListHandler.php +++ b/classes/Handler/ListHandler.php @@ -14,15 +14,17 @@ class ListHandler implements RequestHandlerInterface, AuthRequired public function handle(Request $request): Response { $owner = $_SESSION["owner"] ?? ""; - $mode = $request->getAttribute('mode', ''); - $query = $request->getAttribute('query', ''); - $limit = (int) $request->getAttribute('limit', 60); - $offset = (int) $request->getAttribute('offset', 0); + $mode = $request->getString('mode', ''); + $query = $request->getString('query', ''); + $limit = $request->getInt('limit', 60); + $offset = $request->getInt('offset', 0); $ldb = \Db::pdo(); $caldb = new PDO('sqlite:' . Config::get(Config::CALIBRE_DB)); - $ids_qpart = "1"; + $ids = array_filter( + explode(",", $request->getString('ids', '')), 'intval'); + if ($mode == "favorites") { $fav_sth = $ldb->prepare("SELECT bookid FROM epube_favorites WHERE owner = ?"); @@ -38,14 +40,19 @@ class ListHandler implements RequestHandlerInterface, AuthRequired } $ids_qpart = "books.id IN (" . implode(",", $fav_ids) . ")"; + } else if (count($ids) > 0) { + $ids_qpart = "books.id IN (" . implode(",", $ids) . ")"; + } else { + $ids_qpart = "1"; } $order_by = $query ? "author_sort, series_name, series_index, title, books.id" : "books.id DESC"; - $sth = $caldb->prepare("SELECT books.*, s.name AS series_name, + $sth = $caldb->prepare("SELECT books.*, s.name AS series_name, c.text AS comment, (SELECT id FROM data WHERE book = books.id AND format = 'EPUB' LIMIT 1) AS epub_id FROM books LEFT JOIN books_series_link AS bsl ON (bsl.book = books.id) LEFT JOIN series AS s ON (bsl.series = s.id) + LEFT JOIN comments AS c ON (c.book = books.id) WHERE ((:query = '') OR ( @@ -117,11 +124,13 @@ class ListHandler implements RequestHandlerInterface, AuthRequired "series_name" => $line["series_name"] ?? "", "series_index" => $line["series_index"] ?? 0, "cover_link" => $cover_link, + "has_cover" => $line["has_cover"] == 1, "in_progress" => $in_progress, "is_read" => $is_read, "is_fav" => $is_fav, "epub_id" => $line["epub_id"] ?? 0, "download_formats" => $download_formats, + "comment" => \Sanitizer::sanitize($line["comment"] ?? "") ]; } |
