diff --git a/base.php b/base.php index c06c376..353bef1 100644 --- a/base.php +++ b/base.php @@ -33,7 +33,11 @@ function getURLParam ($name, $default = NULL) { function getCurrentOption ($option) { global $config; if (isset($_COOKIE[$option])) { - return $_COOKIE[$option]; + if (isset($config ["cops_" . $option]) && is_array ($config ["cops_" . $option])) { + return explode (",", $_COOKIE[$option]); + } else { + return $_COOKIE[$option]; + } } if ($option == "style") { return "default"; @@ -464,22 +468,23 @@ class Page Base::clearDb (); } } else { - if (!in_array (PageQueryResult::SCOPE_AUTHOR, $config ['cops_ignored_categories'])) { + //error_log (var_dump (getCurrentOption ('ignored_categories'))); + if (!in_array (PageQueryResult::SCOPE_AUTHOR, getCurrentOption ('ignored_categories'))) { array_push ($this->entryArray, Author::getCount()); } - if (!in_array (PageQueryResult::SCOPE_SERIES, $config ['cops_ignored_categories'])) { + if (!in_array (PageQueryResult::SCOPE_SERIES, getCurrentOption ('ignored_categories'))) { $series = Serie::getCount(); if (!is_null ($series)) array_push ($this->entryArray, $series); } - if (!in_array (PageQueryResult::SCOPE_PUBLISHER, $config ['cops_ignored_categories'])) { + if (!in_array (PageQueryResult::SCOPE_PUBLISHER, getCurrentOption ('ignored_categories'))) { $publisher = Publisher::getCount(); if (!is_null ($publisher)) array_push ($this->entryArray, $publisher); } - if (!in_array (PageQueryResult::SCOPE_TAG, $config ['cops_ignored_categories'])) { + if (!in_array (PageQueryResult::SCOPE_TAG, getCurrentOption ('ignored_categories'))) { $tags = Tag::getCount(); if (!is_null ($tags)) array_push ($this->entryArray, $tags); } - if (!in_array ("language", $config ['cops_ignored_categories'])) { + if (!in_array ("language", getCurrentOption ('ignored_categories'))) { $languages = Language::getCount(); if (!is_null ($languages)) array_push ($this->entryArray, $languages); } @@ -813,7 +818,20 @@ class PageCustomize extends Page if (getCurrentOption ("html_tag_filter") == 1) { $html_tag_filter = "checked='checked'"; } - + + $ignored_categories = array (); + $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, + PageQueryResult::SCOPE_TAG, + PageQueryResult::SCOPE_SERIES, + PageQueryResult::SCOPE_PUBLISHER, + "language"); + foreach ($ignoredBaseArray as $key) { + if (in_array ($key, getCurrentOption ('ignored_categories'))) { + $ignored_categories [$key] = "checked='checked'"; + } else { + $ignored_categories [$key] = ""; + } + } $content = ""; if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { @@ -861,6 +879,15 @@ class PageCustomize extends Page array_push ($this->entryArray, new Entry (localize ("customize.filter"), "", $content, "text", array ())); + $content = ""; + foreach ($ignoredBaseArray as $key) { + $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s"); + $content .= ' ' . localize ("{$keyPlural}.title") . ' '; + } + + array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "", + $content, "text", + array ())); } } diff --git a/book.php b/book.php index b6d9687..0a096fe 100644 --- a/book.php +++ b/book.php @@ -602,7 +602,7 @@ where data.book = books.id and data.id = ?'); PageQueryResult::SCOPE_SERIES, PageQueryResult::SCOPE_PUBLISHER, PageQueryResult::SCOPE_BOOK) as $key) { - if (in_array($key, $config ['cops_ignored_categories']) || + if (in_array($key, getCurrentOption ('ignored_categories')) || (!array_key_exists ($key, $query) && !array_key_exists ("all", $query))) { $critArray [$i] = self::BAD_SEARCH; } @@ -694,7 +694,7 @@ function getJson ($complete = false) { PageQueryResult::SCOPE_SERIES, PageQueryResult::SCOPE_TAG, PageQueryResult::SCOPE_PUBLISHER) as $key) { - if (in_array($key, $config ['cops_ignored_categories'])) { + if (in_array($key, getCurrentOption ('ignored_categories'))) { continue; } switch ($key) { diff --git a/lang/Localization_ca.json b/lang/Localization_ca.json index 719bac6..8bb85e0 100644 --- a/lang/Localization_ca.json +++ b/lang/Localization_ca.json @@ -23,6 +23,7 @@ "##TODO##customize.email":"Set your email (to allow book emailing)", "##TODO##customize.fancybox":"Use a Lightbox", "##TODO##customize.filter":"Enable tag filtering", +"##TODO##customize.ignored":"Ignored categories", "##TODO##customize.paging":"Max number of books per page (-1 to disable)", "##TODO##customize.style":"Theme", "##TODO##customize.title":"Customize COPS UI", diff --git a/lang/Localization_de.json b/lang/Localization_de.json index 6d54b8b..be7923e 100644 --- a/lang/Localization_de.json +++ b/lang/Localization_de.json @@ -23,6 +23,7 @@ "customize.email":"Geben Sie Ihre E-Mail-Adresse an (erlaubt das Zusenden von Büchern)", "customize.fancybox":"Benutze die Lightbox", "customize.filter":"Erlaube das Filtern durch Tags", +"##TODO##customize.ignored":"Ignored categories", "customize.paging":"Maximale Anzahl von Büchern pro Seite (-1 zum deaktivieren)", "customize.style":"Thema", "customize.title":"Anpassungen an COPS", diff --git a/lang/Localization_en.json b/lang/Localization_en.json index 74186b9..705ffae 100644 --- a/lang/Localization_en.json +++ b/lang/Localization_en.json @@ -23,6 +23,7 @@ "customize.email":"Set your email (to allow book emailing)", "customize.fancybox":"Use a Lightbox", "customize.filter":"Enable tag filtering", +"customize.ignored":"Ignored categories", "customize.paging":"Max number of books per page (-1 to disable)", "customize.style":"Theme", "customize.title":"Customize COPS UI", diff --git a/lang/Localization_es.json b/lang/Localization_es.json index 84cf8d6..dabe332 100644 --- a/lang/Localization_es.json +++ b/lang/Localization_es.json @@ -23,6 +23,7 @@ "##TODO##customize.email":"Set your email (to allow book emailing)", "##TODO##customize.fancybox":"Use a Lightbox", "##TODO##customize.filter":"Enable tag filtering", +"##TODO##customize.ignored":"Ignored categories", "##TODO##customize.paging":"Max number of books per page (-1 to disable)", "##TODO##customize.style":"Theme", "##TODO##customize.title":"Customize COPS UI", diff --git a/lang/Localization_fr.json b/lang/Localization_fr.json index 0e441ba..1ecc450 100644 --- a/lang/Localization_fr.json +++ b/lang/Localization_fr.json @@ -23,6 +23,7 @@ "customize.email":"Adresse email (pour l'envoi automatique de livres)", "customize.fancybox":"Utiliser une Lightbox", "customize.filter":"Filtrage via les étiquettes", +"customize.ignored":"Catégories ignorées", "customize.paging":"Nombre de livres par page (-1 pour désactiver)", "customize.style":"Thème", "customize.title":"Paramétrage de COPS", diff --git a/lang/Localization_it.json b/lang/Localization_it.json index 8e7198b..1542ed0 100644 --- a/lang/Localization_it.json +++ b/lang/Localization_it.json @@ -23,6 +23,7 @@ "customize.email":"Imposta la tua email (per permettere l'invio di email)", "customize.fancybox":"Usa una Lightbox", "customize.filter":"Abilita il filtro per argomento", +"##TODO##customize.ignored":"Ignored categories", "customize.paging":"Numero massimo di libri per pagina (-1 per disabilitare)", "customize.style":"Tema", "customize.title":"Personalizza l'interfaccia di COPS", diff --git a/lang/Localization_nb.json b/lang/Localization_nb.json index 1b6255d..660c463 100644 --- a/lang/Localization_nb.json +++ b/lang/Localization_nb.json @@ -23,6 +23,7 @@ "customize.email":"Sett e-pstadresse (for å sende bøker i e-post)", "customize.fancybox":"Bruk en Lightbox", "customize.filter":"Tillat filtrering på nøkkelord", +"##TODO##customize.ignored":"Ignored categories", "customize.paging":"Maks antall bøker per side (-1 for å deaktivere)", "customize.style":"Tema", "customize.title":"Tilpass COPS brukergrensesnitt", diff --git a/lang/Localization_nl.json b/lang/Localization_nl.json index 5e4f883..f49bccf 100644 --- a/lang/Localization_nl.json +++ b/lang/Localization_nl.json @@ -23,6 +23,7 @@ "customize.email":"Email-adres ontvanger (om boeken te versturen per elektronische post)", "customize.fancybox":"Gebruik een Lightbox", "customize.filter":"Zet filteren op tag aan", +"##TODO##customize.ignored":"Ignored categories", "customize.paging":"Maximaal aantal boeken per pagina (-1 voor oneindig aantal)", "customize.style":"Opmaak COPS gebruikersomgeving", "customize.title":"Aanpassen COPS gebruikersomgeving", diff --git a/lang/Localization_pt.json b/lang/Localization_pt.json index d0f7221..3af55a4 100644 --- a/lang/Localization_pt.json +++ b/lang/Localization_pt.json @@ -23,6 +23,7 @@ "customize.email":"Forneça seu email (para enviar o ebook)", "customize.fancybox":"Usar o Lightbox", "customize.filter":"Ativar filtro por etiqueta", +"##TODO##customize.ignored":"Ignored categories", "customize.paging":"Número máximo de livros por página (-1 para desabilitar)", "customize.style":"Tema", "customize.title":"Personalizar a interface do COPS", diff --git a/lang/Localization_ru.json b/lang/Localization_ru.json index 2668c30..0bf8c36 100644 --- a/lang/Localization_ru.json +++ b/lang/Localization_ru.json @@ -23,6 +23,7 @@ "customize.email":"Укажите Ваш email (для отправки книг по электронной почте)", "customize.fancybox":"Использовать Lightbox", "customize.filter":"Включить фильтрацию по меткам", +"##TODO##customize.ignored":"Ignored categories", "customize.paging":"Макс. число книг на странице (-1 - не ограничивать)", "customize.style":"Тема", "customize.title":"Изменить Интерфейс COPS", diff --git a/lang/Localization_zh.json b/lang/Localization_zh.json index de411f7..c6c45dd 100644 --- a/lang/Localization_zh.json +++ b/lang/Localization_zh.json @@ -23,6 +23,7 @@ "customize.email":"设置您的电子邮件(以允许发送邮件)", "customize.fancybox":"使用灯箱", "customize.filter":"打开标签过滤", +"##TODO##customize.ignored":"Ignored categories", "customize.paging":"页内最大书籍数(-1表示禁用)", "customize.style":"主题", "customize.title":"自定义界面", diff --git a/util.js b/util.js index 2cac252..4f7e907 100644 --- a/util.js +++ b/util.js @@ -52,6 +52,19 @@ function updateCookieFromCheckbox (id) { } } +/*exported updateCookieFromCheckboxGroup */ +function updateCookieFromCheckboxGroup (id) { + var name = $(id).attr('name'); + var idBase = name.replace (/\[\]/, ""); + var group = []; + $(':checkbox[name="' + name + '"]:checked').each (function () { + var id = $(this).attr("id"); + group.push (id.replace (idBase + "_", "")); + }); + $.cookie(idBase, group.join (), { expires: 365 }); +} + + function elapsed () { var elapsedTime = new Date () - before; return "Elapsed : " + elapsedTime;