From d35b7d4dc42fbed52c7a391422393bf9f44baa77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 30 Apr 2013 09:42:43 +0200 Subject: [PATCH] Fix opensearch, has to be tested on FBReader / Mantano. re #40 --- OPDS_renderer.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/OPDS_renderer.php b/OPDS_renderer.php index 522b04b..5d0ced5 100644 --- a/OPDS_renderer.php +++ b/OPDS_renderer.php @@ -60,7 +60,11 @@ class OPDSRenderer $xml->endElement (); $xml->startElement ("Url"); $xml->writeAttribute ("type", 'application/atom+xml'); - $xml->writeAttribute ("template", $config['cops_full_url'] . 'feed.php?query={searchTerms}'); + $urlparam = "?query={searchTerms}"; + if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); + $urlparam = str_replace ("%7B", "{", $urlparam); + $urlparam = str_replace ("%7D", "}", $urlparam); + $xml->writeAttribute ("template", $config['cops_full_url'] . 'feed.php' . $urlparam); $xml->endElement (); $xml->startElement ("Query"); $xml->writeAttribute ("role", "example"); @@ -122,14 +126,16 @@ class OPDSRenderer self::renderLink ($link); $link = new LinkNavigation ("?" . $_SERVER['QUERY_STRING'], "self"); self::renderLink ($link); + $urlparam = "?page=" . self::PAGE_OPENSEARCH; + if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) { // Good and compliant way of handling search - $link = new Link ("feed.php?page=" . self::PAGE_OPENSEARCH, "application/opensearchdescription+xml", "search", "Search here"); + $link = new Link ("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here"); } else { // Bad way, will be removed when OPDS client are fixed - $link = new Link ($config['cops_full_url'] . 'feed.php?query={searchTerms}', "application/atom+xml", "search", "Search here"); + $link = new Link ($config['cops_full_url'] . 'feed.php' . $urlparam, "application/atom+xml", "search", "Search here"); } self::renderLink ($link); if ($page->containsBook () && !is_null ($config['cops_books_filter']) && count ($config['cops_books_filter']) > 0) {