From c266a89d0fbb0d60d2d7df0ec171b7cb022224f6 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 26 Jan 2020 14:35:25 +0100 Subject: Process tag cloud page through Slim controller --- index.php | 45 ++------------------------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index a42c844a..83f1264f 100644 --- a/index.php +++ b/index.php @@ -616,49 +616,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM // -------- Tag cloud if ($targetPage == Router::$PAGE_TAGCLOUD) { - $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; - $filteringTags = isset($_GET['searchtags']) ? explode(' ', $_GET['searchtags']) : []; - $tags = $bookmarkService->bookmarksCountPerTag($filteringTags, $visibility); - - // We sort tags alphabetically, then choose a font size according to count. - // First, find max value. - $maxcount = 0; - foreach ($tags as $value) { - $maxcount = max($maxcount, $value); - } - - alphabetical_sort($tags, false, true); - - $logMaxCount = $maxcount > 1 ? log($maxcount, 30) : 1; - $tagList = array(); - foreach ($tags as $key => $value) { - if (in_array($key, $filteringTags)) { - continue; - } - // Tag font size scaling: - // default 15 and 30 logarithm bases affect scaling, - // 2.2 and 0.8 are arbitrary font sizes in em. - $size = log($value, 15) / $logMaxCount * 2.2 + 0.8; - $tagList[$key] = array( - 'count' => $value, - 'size' => number_format($size, 2, '.', ''), - ); - } - - $searchTags = implode(' ', escape($filteringTags)); - $data = array( - 'search_tags' => $searchTags, - 'tags' => $tagList, - ); - $pluginManager->executeHooks('render_tagcloud', $data, array('loggedin' => $loginManager->isLoggedIn())); - - foreach ($data as $key => $value) { - $PAGE->assign($key, $value); - } - - $searchTags = ! empty($searchTags) ? $searchTags .' - ' : ''; - $PAGE->assign('pagetitle', $searchTags. t('Tag cloud') .' - '. $conf->get('general.title', 'Shaarli')); - $PAGE->renderPage('tag.cloud'); + header('Location: ./tag-cloud'); exit; } @@ -1916,6 +1874,7 @@ $app->group('', function () { $this->get('/login', '\Shaarli\Front\Controller\LoginController:index')->setName('login'); $this->get('/logout', '\Shaarli\Front\Controller\LogoutController:index')->setName('logout'); $this->get('/picture-wall', '\Shaarli\Front\Controller\PictureWallController:index')->setName('picwall'); + $this->get('/tag-cloud', '\Shaarli\Front\Controller\TagCloudController:index')->setName('tagcloud'); $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag'); })->add('\Shaarli\Front\ShaarliMiddleware'); -- cgit v1.2.3