Public/private filter: use two separate buttons

#1038
This commit is contained in:
ArthurHoaro 2018-01-24 18:46:31 +01:00
parent 9d4736a3e9
commit d2f6d909e5
5 changed files with 54 additions and 57 deletions

View File

@ -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';
}
}
}

View File

@ -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 ""
"<pre>Sessions do not seem to work correctly on your server.<br>Make sure the "
@ -333,7 +333,7 @@ msgstr ""
"cookies. Nous vous recommandons d'accéder à votre serveur depuis son adresse "
"IP ou un <em>Fully Qualified Domain Name</em>.<br>"
#: 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:17
#: tmp/linklist.paging.cedf684561d925457130839629000a81.rtpl.php:17
#: 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: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"

View File

@ -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'])) {

View File

@ -6,9 +6,12 @@
{'Filters'|t}
</span>
{if="isLoggedIn()"}
<a href="?visibility={$nextVisibility}" title="{'Filter links by visibility'|t}"
class="{if="$visibility=='private'"}filter-on{elseif="$visibility=='public'"}filter-block{else}filter-off{/if}"
><i class="fa fa-key"></i></a>
<a href="?visibility=private" title="{'Only display private links'|t}"
class="{if="$visibility==='private'"}filter-on{else}filter-off{/if}"
><i class="fa fa-user-secret"></i></a>
<a href="?visibility=public" title="{'Only display public links'|t}"
class="{if="$visibility==='public'"}filter-on{else}filter-off{/if}"
><i class="fa fa-globe"></i></a>
{/if}
<a href="?untaggedonly" title="{'Filter untagged links'|t}"
class={if="$untaggedonly"}"filter-on"{else}"filter-off"{/if}

View File

@ -1,8 +1,8 @@
<div class="paging">
{if="isLoggedIn()"}
<div class="paging_privatelinks">
<a href="?visibility={$nextVisibility}">
{if="$visibility=='private' || $visibility=='public'"}
<a href="?visibility=private">
{if="$visibility=='private'"}
<img src="images/private_16x16_active.png#" width="16" height="16" title="Filter links by visibility" alt="Filter links by visibility">
{else}
<img src="images/private_16x16.png#" width="16" height="16" title="Filter links by visibility" alt="Filter links by visibility">