aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--index.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/index.php b/index.php
index d9fe5bc2..3a63319c 100644
--- a/index.php
+++ b/index.php
@@ -1229,11 +1229,25 @@ function renderPage()
1229 1229
1230 // We sort tags alphabetically, then choose a font size according to count. 1230 // We sort tags alphabetically, then choose a font size according to count.
1231 // First, find max value. 1231 // First, find max value.
1232 $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value); 1232 $maxcount = 0;
1233 ksort($tags); 1233 foreach ($tags as $value) {
1234 $maxcount = max($maxcount, $value);
1235 }
1236
1237 // Sort tags alphabetically: case insensitive, support locale if avalaible.
1238 uksort($tags, function($a, $b) {
1239 // Collator is part of PHP intl.
1240 if (class_exists('Collator')) {
1241 $c = new Collator(setlocale(LC_ALL, 0));
1242 return $c->compare($a, $b);
1243 } else {
1244 return strcasecmp($a, $b);
1245 }
1246 });
1247
1234 $tagList=array(); 1248 $tagList=array();
1235 foreach($tags as $key=>$value) 1249 foreach($tags as $key=>$value)
1236 // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes. 1250 // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes.
1237 { 1251 {
1238 $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6); 1252 $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6);
1239 } 1253 }