Reimplementation of strcasecmp()

Reimplementation of strcasecmp() using collator.
It uses the same implementation already made for strcmp().
Fix of menuSort() function in "Ui/Admin.php".

Screens fixed:
- Administration
This commit is contained in:
Moisés Braga Ribeiro 2020-05-10 21:49:04 -03:00
parent 5f109073e5
commit 49097b7b07
2 changed files with 4 additions and 3 deletions

View File

@ -159,7 +159,7 @@ class Admin extends Ui {
* @return int
*/
protected function menuSort($a, $b) {
$strcmp = strcasecmp($a['prompt'], $b['prompt']);
$strcmp = strcompare($a['prompt'], $b['prompt']);
if($strcmp != 0) return $strcmp;
if($a['sort'] === $b['sort']) return 0;
return ($a['sort'] < $b['sort']) ? -1 : 1;

View File

@ -70,14 +70,15 @@ function natural_sort(&$files_or_dirs){
}
/**
* Replacement for strcmp() in fulltext.php, line 373.
* Replacement for strcmp() in fulltext.php, line 373, where all strings are lowercase.
* Replacement for strcasecmp() in Ui/Admin.php, line 162.
*/
function strcompare($first, $second){
global $collator;
_init_collator();
if(!isset($collator))
return strcmp($first, $second);
return strcasecmp($first, $second);
else
return $collator->compare($first, $second);
}