aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php38
1 files changed, 27 insertions, 11 deletions
diff --git a/index.php b/index.php
index ae0ce8f0..067b8fcb 100644
--- a/index.php
+++ b/index.php
@@ -124,6 +124,11 @@ if (isset($_COOKIE['shaarli']) && !SessionManager::checkId($_COOKIE['shaarli']))
124$conf = new ConfigManager(); 124$conf = new ConfigManager();
125$sessionManager = new SessionManager($_SESSION, $conf); 125$sessionManager = new SessionManager($_SESSION, $conf);
126 126
127// LC_MESSAGES isn't defined without php-intl, in this case use LC_COLLATE locale instead.
128if (! defined('LC_MESSAGES')) {
129 define('LC_MESSAGES', LC_COLLATE);
130}
131
127// Sniff browser language and set date format accordingly. 132// Sniff browser language and set date format accordingly.
128if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 133if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
129 autoLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']); 134 autoLocale($_SERVER['HTTP_ACCEPT_LANGUAGE']);
@@ -282,7 +287,7 @@ function logout() {
282 unset($_SESSION['uid']); 287 unset($_SESSION['uid']);
283 unset($_SESSION['ip']); 288 unset($_SESSION['ip']);
284 unset($_SESSION['username']); 289 unset($_SESSION['username']);
285 unset($_SESSION['privateonly']); 290 unset($_SESSION['visibility']);
286 unset($_SESSION['untaggedonly']); 291 unset($_SESSION['untaggedonly']);
287 } 292 }
288 setcookie('shaarli_staySignedIn', FALSE, 0, WEB_PATH); 293 setcookie('shaarli_staySignedIn', FALSE, 0, WEB_PATH);
@@ -803,7 +808,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
803 // -------- Tag cloud 808 // -------- Tag cloud
804 if ($targetPage == Router::$PAGE_TAGCLOUD) 809 if ($targetPage == Router::$PAGE_TAGCLOUD)
805 { 810 {
806 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 811 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
807 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; 812 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
808 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); 813 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility);
809 814
@@ -848,7 +853,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
848 // -------- Tag list 853 // -------- Tag list
849 if ($targetPage == Router::$PAGE_TAGLIST) 854 if ($targetPage == Router::$PAGE_TAGLIST)
850 { 855 {
851 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 856 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
852 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; 857 $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : [];
853 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); 858 $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility);
854 foreach ($filteringTags as $tag) { 859 foreach ($filteringTags as $tag) {
@@ -1014,15 +1019,26 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager)
1014 } 1019 }
1015 1020
1016 // -------- User wants to see only private links (toggle) 1021 // -------- User wants to see only private links (toggle)
1017 if (isset($_GET['privateonly'])) { 1022 if (isset($_GET['visibility'])) {
1018 if (empty($_SESSION['privateonly'])) { 1023 if ($_GET['visibility'] === 'private') {
1019 $_SESSION['privateonly'] = 1; // See only private links 1024 // Visibility not set or not already private, set private, otherwise reset it
1020 } else { 1025 if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'private') {
1021 unset($_SESSION['privateonly']); // See all links 1026 // See only private links
1027 $_SESSION['visibility'] = 'private';
1028 } else {
1029 unset($_SESSION['visibility']);
1030 }
1031 } else if ($_GET['visibility'] === 'public') {
1032 if (empty($_SESSION['visibility']) || $_SESSION['visibility'] !== 'public') {
1033 // See only public links
1034 $_SESSION['visibility'] = 'public';
1035 } else {
1036 unset($_SESSION['visibility']);
1037 }
1022 } 1038 }
1023 1039
1024 if (! empty($_SERVER['HTTP_REFERER'])) { 1040 if (! empty($_SERVER['HTTP_REFERER'])) {
1025 $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('privateonly')); 1041 $location = generateLocation($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], array('visibility'));
1026 } else { 1042 } else {
1027 $location = '?'; 1043 $location = '?';
1028 } 1044 }
@@ -1664,7 +1680,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1664 } 1680 }
1665 } else { 1681 } else {
1666 // Filter links according search parameters. 1682 // Filter links according search parameters.
1667 $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; 1683 $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '';
1668 $request = [ 1684 $request = [
1669 'searchtags' => $searchtags, 1685 'searchtags' => $searchtags,
1670 'searchterm' => $searchterm, 1686 'searchterm' => $searchterm,
@@ -1740,7 +1756,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1740 'result_count' => count($linksToDisplay), 1756 'result_count' => count($linksToDisplay),
1741 'search_term' => $searchterm, 1757 'search_term' => $searchterm,
1742 'search_tags' => $searchtags, 1758 'search_tags' => $searchtags,
1743 'visibility' => ! empty($_SESSION['privateonly']) ? 'private' : '', 1759 'visibility' => ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : '',
1744 'redirector' => $conf->get('redirector.url'), // Optional redirector URL. 1760 'redirector' => $conf->get('redirector.url'), // Optional redirector URL.
1745 'links' => $linkDisp, 1761 'links' => $linkDisp,
1746 ); 1762 );