Small fixes to facets handling. re #21
* Fix ths duplicate of URL parameter * Fix when parameter is empty
This commit is contained in:
parent
e5d0933971
commit
11645b2155
|
@ -133,7 +133,7 @@ class OPDSRenderer
|
||||||
if ($page->containsBook () && !is_null ($config['cops_books_filter']) && count ($config['cops_books_filter']) > 0) {
|
if ($page->containsBook () && !is_null ($config['cops_books_filter']) && count ($config['cops_books_filter']) > 0) {
|
||||||
$Urlfilter = getURLParam ("tag", "");
|
$Urlfilter = getURLParam ("tag", "");
|
||||||
foreach ($config['cops_books_filter'] as $lib => $filter) {
|
foreach ($config['cops_books_filter'] as $lib => $filter) {
|
||||||
$link = new LinkFacet ("?" . $_SERVER['QUERY_STRING'] . "&tag=" . $filter, $lib, localize ("tagword.title"), $filter == $Urlfilter);
|
$link = new LinkFacet ("?" . addURLParameter ($_SERVER['QUERY_STRING'], "tag", $filter), $lib, localize ("tagword.title"), $filter == $Urlfilter);
|
||||||
self::renderLink ($link);
|
self::renderLink ($link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
base.php
11
base.php
|
@ -81,6 +81,17 @@ function localize($phrase, $count=-1) {
|
||||||
return $translations[$phrase];
|
return $translations[$phrase];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addURLParameter($urlParams, $paramName, $paramValue) {
|
||||||
|
$params = array();
|
||||||
|
parse_str($urlParams, $params);
|
||||||
|
if (empty ($paramValue)) {
|
||||||
|
unset ($params[$paramName]);
|
||||||
|
} else {
|
||||||
|
$params[$paramName] = $paramValue;
|
||||||
|
}
|
||||||
|
return http_build_query($params);
|
||||||
|
}
|
||||||
|
|
||||||
class Link
|
class Link
|
||||||
{
|
{
|
||||||
const OPDS_THUMBNAIL_TYPE = "http://opds-spec.org/image/thumbnail";
|
const OPDS_THUMBNAIL_TYPE = "http://opds-spec.org/image/thumbnail";
|
||||||
|
|
2
book.php
2
book.php
|
@ -119,7 +119,7 @@ class Book extends Base {
|
||||||
|
|
||||||
public function getFilterString () {
|
public function getFilterString () {
|
||||||
$filter = getURLParam ("tag", NULL);
|
$filter = getURLParam ("tag", NULL);
|
||||||
if (is_null ($filter)) return "";
|
if (empty ($filter)) return "";
|
||||||
|
|
||||||
$exists = true;
|
$exists = true;
|
||||||
if (preg_match ("/^!(.*)$/", $filter, $matches)) {
|
if (preg_match ("/^!(.*)$/", $filter, $matches)) {
|
||||||
|
|
|
@ -139,7 +139,7 @@
|
||||||
/*
|
/*
|
||||||
* Filter on tags to book list
|
* Filter on tags to book list
|
||||||
*/
|
*/
|
||||||
$config['cops_books_filter'] = array ("Non lus" => "!Read", "lus" => "Read");
|
$config['cops_books_filter'] = array ("Tout" => "", "Non lus" => "!Read", "lus" => "Read");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Custom Columns to add as an array containing the lookup names
|
* Custom Columns to add as an array containing the lookup names
|
||||||
|
|
Loading…
Reference in a new issue