From d2f6d909e529898c43b32defb890ec8e2d6b72f5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 24 Jan 2018 18:46:31 +0100 Subject: [PATCH] Public/private filter: use two separate buttons #1038 --- application/PageBuilder.php | 21 --------- inc/languages/fr/LC_MESSAGES/shaarli.po | 61 +++++++++++++------------ index.php | 16 +++++-- tpl/default/linklist.paging.html | 9 ++-- tpl/vintage/linklist.paging.html | 4 +- 5 files changed, 54 insertions(+), 57 deletions(-) diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 0902d00d..3233d6b6 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php @@ -85,7 +85,6 @@ class PageBuilder $this->tpl->assign('scripturl', index_url($_SERVER)); $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; $this->tpl->assign('visibility', $visibility); - $this->tpl->assign('nextVisibility', $this->getNextVisibility($visibility)); $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli')); if ($this->conf->exists('general.header_link')) { @@ -172,24 +171,4 @@ class PageBuilder $this->tpl->assign('error_message', $message); $this->renderPage('404'); } - - /** - * Return the next visibility option: - * private -> public -> all - * - * @param string $current visibility value - * - * @return string next visibility value - */ - protected function getNextVisibility($current) - { - switch ($current) { - case 'private': - return 'public'; - case 'public': - return ''; - default: - return 'private'; - } - } } diff --git a/inc/languages/fr/LC_MESSAGES/shaarli.po b/inc/languages/fr/LC_MESSAGES/shaarli.po index b62ff6ed..857b13c7 100644 --- a/inc/languages/fr/LC_MESSAGES/shaarli.po +++ b/inc/languages/fr/LC_MESSAGES/shaarli.po @@ -1,15 +1,15 @@ msgid "" msgstr "" "Project-Id-Version: Shaarli\n" -"POT-Creation-Date: 2017-12-16 14:27+0100\n" -"PO-Revision-Date: 2017-12-16 14:27+0100\n" +"POT-Creation-Date: 2018-01-24 18:43+0100\n" +"PO-Revision-Date: 2018-01-24 18:44+0100\n" "Last-Translator: \n" "Language-Team: Shaarli\n" "Language: fr_FR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.0.5\n" +"X-Generator: Poedit 2.0.6\n" "X-Poedit-Basepath: ../../../..\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "X-Poedit-SourceCharset: UTF-8\n" @@ -161,11 +161,11 @@ msgstr "" "a été importé avec succès en %d secondes : %d liens importés, %d liens " "écrasés, %d liens ignorés." -#: application/PageBuilder.php:169 +#: application/PageBuilder.php:168 msgid "The page you are trying to reach does not exist or has been deleted." msgstr "La page que vous essayez de consulter n'existe pas ou a été supprimée." -#: application/PageBuilder.php:171 +#: application/PageBuilder.php:170 msgid "404 Not Found" msgstr "404 Introuvable" @@ -265,46 +265,46 @@ msgstr "NON. Vous êtes banni pour le moment. Revenez plus tard." msgid "Wrong login/password." msgstr "Nom d'utilisateur ou mot de passe incorrects." -#: index.php:1093 +#: index.php:1103 msgid "You are not supposed to change a password on an Open Shaarli." msgstr "" "Vous n'êtes pas censé modifier le mot de passe d'un Shaarli en mode ouvert." -#: index.php:1098 index.php:1139 index.php:1215 index.php:1245 index.php:1345 +#: index.php:1108 index.php:1149 index.php:1225 index.php:1255 index.php:1355 msgid "Wrong token." msgstr "Jeton invalide." -#: index.php:1103 +#: index.php:1113 msgid "The old password is not correct." msgstr "L'ancien mot de passe est incorrect." -#: index.php:1123 +#: index.php:1133 msgid "Your password has been changed" msgstr "Votre mot de passe a été modifié" -#: index.php:1176 +#: index.php:1186 msgid "Configuration was saved." msgstr "La configuration a été sauvegardé." -#: index.php:1227 +#: index.php:1237 #, php-format msgid "The tag was removed from %d link." msgid_plural "The tag was removed from %d links." msgstr[0] "Le tag a été supprimé de %d lien." msgstr[1] "Le tag a été supprimé de %d liens." -#: index.php:1228 +#: index.php:1238 #, php-format msgid "The tag was renamed in %d link." msgid_plural "The tag was renamed in %d links." msgstr[0] "Le tag a été renommé dans %d lien." msgstr[1] "Le tag a été renommé dans %d liens." -#: index.php:1444 +#: index.php:1454 msgid "Note: " msgstr "Note : " -#: index.php:1553 +#: index.php:1563 #, php-format msgid "" "The file you are trying to upload is probably bigger than what this " @@ -314,7 +314,7 @@ msgstr "" "le serveur web peut accepter (%s). Merci de l'envoyer en parties plus " "légères." -#: index.php:1973 +#: index.php:1983 #, php-format msgid "" "
Sessions do not seem to work correctly on your server.
Make sure the " @@ -333,7 +333,7 @@ msgstr "" "cookies. Nous vous recommandons d'accéder à votre serveur depuis son adresse " "IP ou un Fully Qualified Domain Name.
" -#: index.php:1983 +#: index.php:1993 msgid "Click to try again." msgstr "Cliquer ici pour réessayer." @@ -933,25 +933,30 @@ msgstr "Filtres" #: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:12 #: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:12 -msgid "Filter links by visibility" -msgstr "Filtrer les liens par visibilité" +msgid "Only display private links" +msgstr "Afficher uniquement les liens privés" + +#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:15 +#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:15 +msgid "Only display public links" +msgstr "Afficher uniquement les liens publics" -#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:17 -#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:17 +#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:20 +#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:20 msgid "Filter untagged links" msgstr "Filtrer par liens privés" -#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:21 -#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:73 -#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:21 -#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:73 +#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:24 +#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:76 +#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:24 +#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:76 #: tmp/page.footer.b91ef64efc3688266305ea9b42e5017e.rtpl.php:43 #: tmp/page.footer.cedf684561d925457130839629000a81.rtpl.php:43 msgid "Fold all" msgstr "Replier tout" -#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:66 -#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:66 +#: tmp/linklist.paging.b91ef64efc3688266305ea9b42e5017e.rtpl.php:69 +#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:69 msgid "Links per page" msgstr "Liens par page" @@ -1284,8 +1289,8 @@ msgstr "" "Glisser ce lien dans votre barre de favoris ou cliquer droit dessus et « " "Ajouter aux favoris »" -#~ msgid "Filter private links" -#~ msgstr "Filtrer par liens privés" +#~ msgid "Filter links by visibility" +#~ msgstr "Filtrer les liens par visibilité" #~ msgid "Redirector" #~ msgstr "Redirecteur" diff --git a/index.php b/index.php index 60ac24ac..8770b669 100644 --- a/index.php +++ b/index.php @@ -1012,11 +1012,21 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager) // -------- User wants to see only private links (toggle) if (isset($_GET['visibility'])) { - unset($_SESSION['visibility']); if ($_GET['visibility'] === 'private') { - $_SESSION['visibility'] = 'private'; // See only private links + // Visibility not set or not already private, set private, otherwise reset it + if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'private') { + // See only private links + $_SESSION['visibility'] = 'private'; + } else { + unset($_SESSION['visibility']); + } } else if ($_GET['visibility'] === 'public') { - $_SESSION['visibility'] = 'public'; // See only public links + if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') { + // See only public links + $_SESSION['visibility'] = 'public'; + } else { + unset($_SESSION['visibility']); + } } if (! empty($_SERVER['HTTP_REFERER'])) { diff --git a/tpl/default/linklist.paging.html b/tpl/default/linklist.paging.html index e1726f87..72bdd931 100644 --- a/tpl/default/linklist.paging.html +++ b/tpl/default/linklist.paging.html @@ -6,9 +6,12 @@ {'Filters'|t} {if="isLoggedIn()"} - + + {/if} {if="isLoggedIn()"}