diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-01-26 14:55:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-26 14:55:07 +0100 |
commit | f6637392a93fb0708b7f972a22151b38795dc1e2 (patch) | |
tree | 82a95ff0db10ba3eec901f796859bf7100c9dfbf | |
parent | c653ae3bfb11f663a52f55817e6d02a66d0852c8 (diff) | |
parent | b495d5c92ad453baddb05c7a7763ae434f0c50ae (diff) | |
download | Shaarli-f6637392a93fb0708b7f972a22151b38795dc1e2.tar.gz Shaarli-f6637392a93fb0708b7f972a22151b38795dc1e2.tar.zst Shaarli-f6637392a93fb0708b7f972a22151b38795dc1e2.zip |
Fix division by zero in tagcloud (#1411)
Fix division by zero in tagcloud
-rw-r--r-- | index.php | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -659,6 +659,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
659 | 659 | ||
660 | alphabetical_sort($tags, false, true); | 660 | alphabetical_sort($tags, false, true); |
661 | 661 | ||
662 | $logMaxCount = $maxcount > 1 ? log($maxcount, 30) : 1; | ||
662 | $tagList = array(); | 663 | $tagList = array(); |
663 | foreach ($tags as $key => $value) { | 664 | foreach ($tags as $key => $value) { |
664 | if (in_array($key, $filteringTags)) { | 665 | if (in_array($key, $filteringTags)) { |
@@ -666,8 +667,8 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
666 | } | 667 | } |
667 | // Tag font size scaling: | 668 | // Tag font size scaling: |
668 | // default 15 and 30 logarithm bases affect scaling, | 669 | // default 15 and 30 logarithm bases affect scaling, |
669 | // 22 and 6 are arbitrary font sizes for max and min sizes. | 670 | // 2.2 and 0.8 are arbitrary font sizes in em. |
670 | $size = log($value, 15) / log($maxcount, 30) * 2.2 + 0.8; | 671 | $size = log($value, 15) / $logMaxCount * 2.2 + 0.8; |
671 | $tagList[$key] = array( | 672 | $tagList[$key] = array( |
672 | 'count' => $value, | 673 | 'count' => $value, |
673 | 'size' => number_format($size, 2, '.', ''), | 674 | 'size' => number_format($size, 2, '.', ''), |