diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 40 |
1 files changed, 28 insertions, 12 deletions
@@ -791,7 +791,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
791 | if ($targetPage == Router::$PAGE_TAGCLOUD) | 791 | if ($targetPage == Router::$PAGE_TAGCLOUD) |
792 | { | 792 | { |
793 | $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; | 793 | $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; |
794 | $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : array(); | 794 | $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; |
795 | $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); | 795 | $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); |
796 | 796 | ||
797 | // We sort tags alphabetically, then choose a font size according to count. | 797 | // We sort tags alphabetically, then choose a font size according to count. |
@@ -801,17 +801,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
801 | $maxcount = max($maxcount, $value); | 801 | $maxcount = max($maxcount, $value); |
802 | } | 802 | } |
803 | 803 | ||
804 | // Sort tags alphabetically: case insensitive, support locale if available. | 804 | alphabetical_sort($tags, true, true); |
805 | uksort($tags, function($a, $b) { | ||
806 | // Collator is part of PHP intl. | ||
807 | if (class_exists('Collator')) { | ||
808 | $c = new Collator(setlocale(LC_COLLATE, 0)); | ||
809 | if (!intl_is_failure(intl_get_error_code())) { | ||
810 | return $c->compare($a, $b); | ||
811 | } | ||
812 | } | ||
813 | return strcasecmp($a, $b); | ||
814 | }); | ||
815 | 805 | ||
816 | $tagList = array(); | 806 | $tagList = array(); |
817 | foreach($tags as $key => $value) { | 807 | foreach($tags as $key => $value) { |
@@ -839,6 +829,31 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
839 | exit; | 829 | exit; |
840 | } | 830 | } |
841 | 831 | ||
832 | // -------- Tag cloud | ||
833 | if ($targetPage == Router::$PAGE_TAGLIST) | ||
834 | { | ||
835 | $visibility = ! empty($_SESSION['privateonly']) ? 'private' : 'all'; | ||
836 | $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; | ||
837 | $tags = $LINKSDB->linksCountPerTag($filteringTags, $visibility); | ||
838 | |||
839 | if (! empty($_GET['sort']) && $_GET['sort'] === 'alpha') { | ||
840 | alphabetical_sort($tags, false, true); | ||
841 | } | ||
842 | |||
843 | $data = [ | ||
844 | 'search_tags' => implode(' ', $filteringTags), | ||
845 | 'tags' => $tags, | ||
846 | ]; | ||
847 | $pluginManager->executeHooks('render_taglist', $data, ['loggedin' => isLoggedIn()]); | ||
848 | |||
849 | foreach ($data as $key => $value) { | ||
850 | $PAGE->assign($key, $value); | ||
851 | } | ||
852 | |||
853 | $PAGE->renderPage('tag.list'); | ||
854 | exit; | ||
855 | } | ||
856 | |||
842 | // Daily page. | 857 | // Daily page. |
843 | if ($targetPage == Router::$PAGE_DAILY) { | 858 | if ($targetPage == Router::$PAGE_DAILY) { |
844 | showDaily($PAGE, $LINKSDB, $conf, $pluginManager); | 859 | showDaily($PAGE, $LINKSDB, $conf, $pluginManager); |
@@ -1152,6 +1167,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
1152 | if ($targetPage == Router::$PAGE_CHANGETAG) | 1167 | if ($targetPage == Router::$PAGE_CHANGETAG) |
1153 | { | 1168 | { |
1154 | if (empty($_POST['fromtag']) || (empty($_POST['totag']) && isset($_POST['renametag']))) { | 1169 | if (empty($_POST['fromtag']) || (empty($_POST['totag']) && isset($_POST['renametag']))) { |
1170 | $PAGE->assign('fromtag', ! empty($_GET['fromtag']) ? escape($_GET['fromtag']) : ''); | ||
1155 | $PAGE->renderPage('changetag'); | 1171 | $PAGE->renderPage('changetag'); |
1156 | exit; | 1172 | exit; |
1157 | } | 1173 | } |