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 31dcbf0f..93e4cc63 100644
--- a/index.php
+++ b/index.php
@@ -1203,11 +1203,25 @@ function renderPage()
1203 1203
1204 // We sort tags alphabetically, then choose a font size according to count. 1204 // We sort tags alphabetically, then choose a font size according to count.
1205 // First, find max value. 1205 // First, find max value.
1206 $maxcount=0; foreach($tags as $key=>$value) $maxcount=max($maxcount,$value); 1206 $maxcount = 0;
1207 ksort($tags); 1207 foreach ($tags as $value) {
1208 $maxcount = max($maxcount, $value);
1209 }
1210
1211 // Sort tags alphabetically: case insensitive, support locale if avalaible.
1212 uksort($tags, function($a, $b) {
1213 // Collator is part of PHP intl.
1214 if (class_exists('Collator')) {
1215 $c = new Collator(setlocale(LC_ALL, 0));
1216 return $c->compare($a, $b);
1217 } else {
1218 return strcasecmp($a, $b);
1219 }
1220 });
1221
1208 $tagList=array(); 1222 $tagList=array();
1209 foreach($tags as $key=>$value) 1223 foreach($tags as $key=>$value)
1210 // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes. 1224 // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes.
1211 { 1225 {
1212 $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6); 1226 $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6);
1213 } 1227 }