diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2014-01-15 17:55:05 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2014-02-11 10:49:34 +0100 |
commit | 41e8d44cf7261e05a40842ab56d4d4c3f61cf083 (patch) | |
tree | ffdeaa9831c864528e8e4c482abe13e8134c26c7 /core/ajax | |
parent | 1d0a2365631955944d746b4567cac85eb10a80db (diff) | |
download | nextcloud-server-41e8d44cf7261e05a40842ab56d4d4c3f61cf083.tar.gz nextcloud-server-41e8d44cf7261e05a40842ab56d4d4c3f61cf083.zip |
move sorter into a class
Diffstat (limited to 'core/ajax')
-rw-r--r-- | core/ajax/share.php | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index 5c2dbc6654d..21e320a4732 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -354,32 +354,11 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo break; } } - usort($shareWith, 'sortSearchFirst'); + $sorter = new \OC\Share\SearchResultSorter($_GET['search'], + 'label'); + usort($shareWith, array($sorter, 'sort')); OC_JSON::success(array('data' => $shareWith)); } break; } } - - -/** - * User and Group names matching the search term at the beginning shall appear - * on top of the share dialog. - * Callback function for usort. http://php.net/usort - */ -function sortSearchFirst($a, $b) { - $enc = 'UTF-8'; - $nameA = mb_strtolower($a['label'], $enc); - $nameB = mb_strtolower($b['label'], $enc); - $term = mb_strtolower($_GET['search'], $enc); - $i = mb_strpos($nameA, $term, 0, 'UTF-8'); - $j = mb_strpos($nameB, $term, 0, 'UTF-8'); - - if($i === $j) { - return 0; - } elseif ($i === 0) { - return -1; - } else { - return 1; - } -} |