aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-03-25 15:59:01 +0100
committerArthurHoaro <arthur@hoa.ro>2017-05-25 15:25:04 +0200
commitaa4797ba3679b847adc895e2f817ac058779a171 (patch)
treed854a1ab8748911dd10e8bced31a2d9b80ccf57b /index.php
parentbc988eb0420156219fdeb7af684fff37c8b33f4b (diff)
downloadShaarli-aa4797ba3679b847adc895e2f817ac058779a171.tar.gz
Shaarli-aa4797ba3679b847adc895e2f817ac058779a171.tar.zst
Shaarli-aa4797ba3679b847adc895e2f817ac058779a171.zip
Adds a taglist view with edit/delete buttons
* The tag list can be sort alphabetically or by most used tag * Edit/Delete are perform using AJAX, or fallback to 'do=changetag' page * New features aren't backported to vintage theme
Diffstat (limited to 'index.php')
-rw-r--r--index.php40
1 files changed, 28 insertions, 12 deletions
diff --git a/index.php b/index.php
index de098ab5..61b71129 100644
--- a/index.php
+++ b/index.php
@@ -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 }