X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=3a63319c63027fd3873896f9b1a3f12d9a5bd26a;hb=522b278b03280ed809025ebbeb3eac284b68bf81;hp=5de60425c4c8bdadecdad5163918a5491c24d16c;hpb=6cbff7e80f272d4a3bbd266b49efcd3607b7e1bd;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 5de60425..3a63319c 100644 --- a/index.php +++ b/index.php @@ -1229,11 +1229,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); } @@ -1558,6 +1572,8 @@ function renderPage() } // Remove multiple spaces. $tags = trim(preg_replace('/\s\s+/', ' ', $_POST['lf_tags'])); + // Remove first '-' char in tags. + $tags = preg_replace('/(^| )\-/', '$1', $tags); // Remove duplicates. $tags = implode(' ', array_unique(explode(' ', $tags))); $linkdate = $_POST['lf_linkdate']; @@ -1858,7 +1874,7 @@ HTML; ); // TODO: do not handle exceptions/errors in JS. - echo ''; + echo ''; exit; } header('Location: ?do='. Router::$PAGE_PLUGINSADMIN);