diff --git a/OPDS_renderer.php b/OPDS_renderer.php index b6eb45f..f67fb0d 100644 --- a/OPDS_renderer.php +++ b/OPDS_renderer.php @@ -114,7 +114,15 @@ class OPDSRenderer self::renderLink ($link); $link = new LinkNavigation ("?" . $_SERVER['QUERY_STRING'], "self"); self::renderLink ($link); - $link = new Link ($config['cops_full_url'] . 'feed.php?query={searchTerms}', "application/atom+xml", "search", "Search here"); + if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader)/", $_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"); + } + 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"); + } self::renderLink ($link); } diff --git a/config_default.php b/config_default.php index 2e156b6..d88ff84 100644 --- a/config_default.php +++ b/config_default.php @@ -88,4 +88,14 @@ * 0 : disable */ $config['cops_use_url_rewriting'] = "0"; + + /* + * generate a invalid OPDS stream to allow bad OPDS client to use search + * Example of non compliant OPDS client : FBReader (was working in May 2012), Moon+ Reader + * Example of good OPDS client : Mantano + * 1 : enable support for non compliant OPDS client + * 0 : always generate valid OPDS code + */ + $config['cops_generate_invalid_opds_stream'] = "0"; + ?> \ No newline at end of file