Merge pull request #461 from ArthurHoaro/tagcloud-sort
Fixes #456: Tag cloud does not sort tags (fully) alphabetically
This commit is contained in:
commit
07c2f73543
1 changed files with 17 additions and 3 deletions
18
index.php
18
index.php
|
@ -1229,8 +1229,22 @@ function renderPage()
|
|||
|
||||
// We sort tags alphabetically, then choose a font size according to count.
|
||||
// First, find max value.
|
||||
$maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value);
|
||||
ksort($tags);
|
||||
$maxcount = 0;
|
||||
foreach ($tags as $value) {
|
||||
$maxcount = max($maxcount, $value);
|
||||
}
|
||||
|
||||
// Sort tags alphabetically: case insensitive, support locale if avalaible.
|
||||
uksort($tags, function($a, $b) {
|
||||
// Collator is part of PHP intl.
|
||||
if (class_exists('Collator')) {
|
||||
$c = new Collator(setlocale(LC_ALL, 0));
|
||||
return $c->compare($a, $b);
|
||||
} else {
|
||||
return strcasecmp($a, $b);
|
||||
}
|
||||
});
|
||||
|
||||
$tagList=array();
|
||||
foreach($tags as $key=>$value)
|
||||
// Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes.
|
||||
|
|
Loading…
Reference in a new issue