Changeset 3105:5411dc9bea4a
- Timestamp:
- 09/29/15 17:22:58 (10 years ago)
- Branch:
- default
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/posts.php
r3033 r3105 47 47 { 48 48 # Filter form we'll put in html_block 49 $users_combo = dcAdminCombos::getUsersCombo($users); 50 dcUtils::lexicalKeySort($users_combo); 49 51 $users_combo = array_merge( 50 52 array('-' => ''), 51 dcAdminCombos::getUsersCombo($users)53 $users_combo 52 54 ); 53 55 -
admin/users.php
r2720 r3105 84 84 $rs = $core->getUsers($params); 85 85 $counter = $core->getUsers($params,1); 86 $user_list = new adminUserList($core,$rs,$counter->f(0)); 86 $rsStatic = $rs->toStatic(); 87 if ($sortby != 'nb_post') { 88 // Sort user list using lexical order if necessary 89 $rsStatic->extend('rsExtUser'); 90 $rsStatic = $rsStatic->toExtStatic(); 91 $rsStatic->lexicalSort($sortby,$order); 92 } 93 $user_list = new adminUserList($core,$rsStatic,$counter->f(0)); 87 94 } catch (Exception $e) { 88 95 $core->error->add($e->getMessage()); -
inc/admin/actions/class.dcactionposts.php
r2627 r3105 345 345 ); 346 346 $rs = $core->getUsers($params); 347 while ($rs->fetch()) 347 $rsStatic = $rs->toStatic(); 348 $rsStatic->extend('rsExtUser'); 349 $rsStatic = $rsStatic->toExtStatic(); 350 $rsStatic->lexicalSort('user_id'); 351 while ($rsStatic->fetch()) 348 352 { 349 $usersList .= ($usersList != '' ? ',' : '').'"'.$rs ->user_id.'"';353 $usersList .= ($usersList != '' ? ',' : '').'"'.$rsStatic->user_id.'"'; 350 354 } 351 355 } -
inc/core/class.dc.rs.extensions.php
r2566 r3105 846 846 class rsExtUser 847 847 { 848 private static $sortfield; 849 private static $sortsign; 848 850 /** 849 851 Returns a user option. … … 877 879 return array(); 878 880 } 881 882 /** 883 Converts this record to a {@link extStaticRecord} instance. 884 885 @param rs Invisible parameter 886 */ 887 public static function toExtStatic($rs) 888 { 889 if ($rs instanceof extStaticRecord) { 890 return $rs; 891 } 892 return new extStaticRecord($rs); 893 } 879 894 } 895 896 class extStaticRecord extends staticRecord 897 { 898 private $sortfield; 899 private $sortsign; 900 901 public function __construct($rs) 902 { 903 parent::__construct($rs->__data,$rs->__info); 904 } 905 906 /** 907 Lexically sort. 908 909 @param field <b>string<b> sort field 910 @param order <b>string<b> sort order 911 */ 912 public function lexicalSort($field,$order='asc') 913 { 914 $this->sortfield = $field; 915 $this->sortsign = strtolower($order) == 'asc' ? 1 : -1; 916 917 usort($this->__data,array($this,'lexicalSortCallback')); 918 919 $this->sortfield = null; 920 $this->sortsign = null; 921 } 922 private function lexicalSortCallback($a,$b) 923 { 924 $a = $a[$this->sortfield]; 925 $b = $b[$this->sortfield]; 926 927 # Integer values 928 if ($a == (string) (integer) $a && $b == (string) (integer) $b) { 929 $a = (integer) $a; 930 $b = (integer) $b; 931 return ($a - $b) * $this->sortsign; 932 } 933 934 return strcoll(strtolower(dcUtils::removeDiacritics($a)),strtolower(dcUtils::removeDiacritics($b))) * $this->sortsign; 935 } 936 }
Note: See TracChangeset
for help on using the changeset viewer.