Skip to content

Commit

Permalink
Reimplementation of strcasecmp()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
moisesbr-dw committed May 11, 2020
1 parent 5f10907 commit 49097b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion inc/Ui/Admin.php
Expand Up @@ -159,7 +159,7 @@ protected function getPluginList() {
* @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;
Expand Down
5 changes: 3 additions & 2 deletions inc/sort.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit 49097b7

Please sign in to comment.