X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=93e4cc63f503d6eae03952ec3ce7a0a8f3f74857;hb=f1e96a06d8471dd10b730bf89747665eb4595211;hp=31dcbf0fe7455a9de4a437ea190d556801734117;hpb=268a2e52659964fb7d033a1bb4d1490bf8cc49bf;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 31dcbf0f..93e4cc63 100644 --- a/index.php +++ b/index.php @@ -1203,11 +1203,25 @@ 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. + // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes. { $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6); }