Add custom filter of tags in the OPDS feed using facets.

Need more testing but should be ok.

re #21
This commit is contained in:
Sébastien Lucas 2013-01-11 15:16:15 +01:00
parent 98362a6d39
commit 5d9c54eee6
5 changed files with 67 additions and 12 deletions

View file

@ -130,6 +130,13 @@ class OPDSRenderer
$link = new Link ($config['cops_full_url'] . 'feed.php?query={searchTerms}', "application/atom+xml", "search", "Search here");
}
self::renderLink ($link);
if ($page->containsBook () && !is_null ($config['cops_books_filter']) && count ($config['cops_books_filter']) > 0) {
$Urlfilter = getURLParam ("tag", "");
foreach ($config['cops_books_filter'] as $lib => $filter) {
$link = new LinkFacet ("?" . $_SERVER['QUERY_STRING'] . "&tag=" . $filter, $lib, localize ("tagword.title"), $filter == $Urlfilter);
self::renderLink ($link);
}
}
}
private function endXmlDocument () {
@ -148,6 +155,12 @@ class OPDSRenderer
if (!is_null ($link->title)) {
self::getXmlStream ()->writeAttribute ("title", $link->title);
}
if (!is_null ($link->facetGroup)) {
self::getXmlStream ()->writeAttribute ("opds:facetGroup", $link->facetGroup);
}
if ($link->activeFacet) {
self::getXmlStream ()->writeAttribute ("opds:activeFacet", "true");
}
self::getXmlStream ()->endElement ();
}