diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-01-26 14:35:25 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-23 21:19:21 +0200 |
commit | c266a89d0fbb0d60d2d7df0ec171b7cb022224f6 (patch) | |
tree | ef7b34378e19332f0fa44800caa78108aec1a6c7 /index.php | |
parent | 03340c18ead651ef9e11f883745695f2edafbae3 (diff) | |
download | Shaarli-c266a89d0fbb0d60d2d7df0ec171b7cb022224f6.tar.gz Shaarli-c266a89d0fbb0d60d2d7df0ec171b7cb022224f6.tar.zst Shaarli-c266a89d0fbb0d60d2d7df0ec171b7cb022224f6.zip |
Process tag cloud page through Slim controller
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 45 |
1 files changed, 2 insertions, 43 deletions
@@ -616,49 +616,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
616 | 616 | ||
617 | // -------- Tag cloud | 617 | // -------- Tag cloud |
618 | if ($targetPage == Router::$PAGE_TAGCLOUD) { | 618 | if ($targetPage == Router::$PAGE_TAGCLOUD) { |
619 | $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; | 619 | header('Location: ./tag-cloud'); |
620 | $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; | ||
621 | $tags = $bookmarkService->bookmarksCountPerTag($filteringTags, $visibility); | ||
622 | |||
623 | // We sort tags alphabetically, then choose a font size according to count. | ||
624 | // First, find max value. | ||
625 | $maxcount = 0; | ||
626 | foreach ($tags as $value) { | ||
627 | $maxcount = max($maxcount, $value); | ||
628 | } | ||
629 | |||
630 | alphabetical_sort($tags, false, true); | ||
631 | |||
632 | $logMaxCount = $maxcount > 1 ? log($maxcount, 30) : 1; | ||
633 | $tagList = array(); | ||
634 | foreach ($tags as $key => $value) { | ||
635 | if (in_array($key, $filteringTags)) { | ||
636 | continue; | ||
637 | } | ||
638 | // Tag font size scaling: | ||
639 | // default 15 and 30 logarithm bases affect scaling, | ||
640 | // 2.2 and 0.8 are arbitrary font sizes in em. | ||
641 | $size = log($value, 15) / $logMaxCount * 2.2 + 0.8; | ||
642 | $tagList[$key] = array( | ||
643 | 'count' => $value, | ||
644 | 'size' => number_format($size, 2, '.', ''), | ||
645 | ); | ||
646 | } | ||
647 | |||
648 | $searchTags = implode(' ', escape($filteringTags)); | ||
649 | $data = array( | ||
650 | 'search_tags' => $searchTags, | ||
651 | 'tags' => $tagList, | ||
652 | ); | ||
653 | $pluginManager->executeHooks('render_tagcloud', $data, array('loggedin' => $loginManager->isLoggedIn())); | ||
654 | |||
655 | foreach ($data as $key => $value) { | ||
656 | $PAGE->assign($key, $value); | ||
657 | } | ||
658 | |||
659 | $searchTags = ! empty($searchTags) ? $searchTags .' - ' : ''; | ||
660 | $PAGE->assign('pagetitle', $searchTags. t('Tag cloud') .' - '. $conf->get('general.title', 'Shaarli')); | ||
661 | $PAGE->renderPage('tag.cloud'); | ||
662 | exit; | 620 | exit; |
663 | } | 621 | } |
664 | 622 | ||
@@ -1916,6 +1874,7 @@ $app->group('', function () { | |||
1916 | $this->get('/login', '\Shaarli\Front\Controller\LoginController:index')->setName('login'); | 1874 | $this->get('/login', '\Shaarli\Front\Controller\LoginController:index')->setName('login'); |
1917 | $this->get('/logout', '\Shaarli\Front\Controller\LogoutController:index')->setName('logout'); | 1875 | $this->get('/logout', '\Shaarli\Front\Controller\LogoutController:index')->setName('logout'); |
1918 | $this->get('/picture-wall', '\Shaarli\Front\Controller\PictureWallController:index')->setName('picwall'); | 1876 | $this->get('/picture-wall', '\Shaarli\Front\Controller\PictureWallController:index')->setName('picwall'); |
1877 | $this->get('/tag-cloud', '\Shaarli\Front\Controller\TagCloudController:index')->setName('tagcloud'); | ||
1919 | $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag'); | 1878 | $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag'); |
1920 | })->add('\Shaarli\Front\ShaarliMiddleware'); | 1879 | })->add('\Shaarli\Front\ShaarliMiddleware'); |
1921 | 1880 | ||