diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-05-25 15:28:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-25 15:28:26 +0200 |
commit | 81a91579ba8eb7b5a203722baf927a3653b5cb94 (patch) | |
tree | 228456f9b4d95d03e97fc9bc1b5004aa599f95ee /index.php | |
parent | 8b27824338eb445d69730c9b05f05b131ccea52f (diff) | |
parent | 82e3bb5f06dc531ee1080a0313833791a1c1f3c7 (diff) | |
download | Shaarli-81a91579ba8eb7b5a203722baf927a3653b5cb94.tar.gz Shaarli-81a91579ba8eb7b5a203722baf927a3653b5cb94.tar.zst Shaarli-81a91579ba8eb7b5a203722baf927a3653b5cb94.zip |
Merge pull request #835 from ArthurHoaro/feature/tag-cloud
Adds a taglist view with edit/delete buttons
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 49 |
1 files changed, 36 insertions, 13 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) { |
@@ -835,7 +825,32 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
835 | $PAGE->assign($key, $value); | 825 | $PAGE->assign($key, $value); |
836 | } | 826 | } |
837 | 827 | ||
838 | $PAGE->renderPage('tagcloud'); | 828 | $PAGE->renderPage('tag.cloud'); |
829 | exit; | ||
830 | } | ||
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'); | ||
839 | exit; | 854 | exit; |
840 | } | 855 | } |
841 | 856 | ||
@@ -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 | } |
@@ -1582,6 +1598,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history) | |||
1582 | exit; | 1598 | exit; |
1583 | } | 1599 | } |
1584 | 1600 | ||
1601 | // Get a fresh token | ||
1602 | if ($targetPage == Router::$GET_TOKEN) { | ||
1603 | header('Content-Type:text/plain'); | ||
1604 | echo getToken($conf); | ||
1605 | exit; | ||
1606 | } | ||
1607 | |||
1585 | // -------- Otherwise, simply display search form and links: | 1608 | // -------- Otherwise, simply display search form and links: |
1586 | showLinkList($PAGE, $LINKSDB, $conf, $pluginManager); | 1609 | showLinkList($PAGE, $LINKSDB, $conf, $pluginManager); |
1587 | exit; | 1610 | exit; |