[Vtigercrm-developers] 回复: How to support the chinese sort
Uma S
uma.s at vtiger.com
Mon Jun 1 08:05:48 GMT 2015
Hi,
Performing the above explained code of translating alphabets of list-view
search to chinese characters is too hard.
This list-view search is been handled through List.php of module, by
passing parameter search_value as alphabet that has been selected in
list-view.
On Mon, Jun 1, 2015 at 12:59 PM, sunny <1250572980 at qq.com> wrote:
> because chinese use hieroglyphic,for example '李' ,which can spell 'Li','陈'
> spell 'chen',chinese use character
> GBK,not utf-8,here have a code get the first getFirstCharter,
> /**
> * 取汉字的第一个字的首字母
> * @param type $str
> * @return string|null
> */
> public function _getFirstCharter($str){
> if(empty($str)){return '';}
> $fchar=ord($str{0});
> if($fchar>=ord('A')&&$fchar<=ord('z')) return strtoupper($str{0});
> $s1=iconv('UTF-8','gb2312',$str);
> $s2=iconv('gb2312','UTF-8',$s1);
> $s=$s2==$str?$s1:$str;
> $asc=ord($s{0})*256+ord($s{1})-65536;
> if($asc>=-20319&&$asc<=-20284) return 'A';
> if($asc>=-20283&&$asc<=-19776) return 'B';
> if($asc>=-19775&&$asc<=-19219) return 'C';
> if($asc>=-19218&&$asc<=-18711) return 'D';
> if($asc>=-18710&&$asc<=-18527) return 'E';
> if($asc>=-18526&&$asc<=-18240) return 'F';
> if($asc>=-18239&&$asc<=-17923) return 'G';
> if($asc>=-17922&&$asc<=-17418) return 'H';
> if($asc>=-17417&&$asc<=-16475) return 'J';
> if($asc>=-16474&&$asc<=-16213) return 'K';
> if($asc>=-16212&&$asc<=-15641) return 'L';
> if($asc>=-15640&&$asc<=-15166) return 'M';
> if($asc>=-15165&&$asc<=-14923) return 'N';
> if($asc>=-14922&&$asc<=-14915) return 'O';
> if($asc>=-14914&&$asc<=-14631) return 'P';
> if($asc>=-14630&&$asc<=-14150) return 'Q';
> if($asc>=-14149&&$asc<=-14091) return 'R';
> if($asc>=-14090&&$asc<=-13319) return 'S';
> if($asc>=-13318&&$asc<=-12839) return 'T';
> if($asc>=-12838&&$asc<=-12557) return 'W';
> if($asc>=-12556&&$asc<=-11848) return 'X';
> if($asc>=-11847&&$asc<=-11056) return 'Y';
> if($asc>=-11055&&$asc<=-10247) return 'Z';
> return null;
> }
>
> and how to use
>
> //门店名称
> $shopData = $this->_shopNamesArray;
>
> //根据门店名称第一个汉字的首字母正序排序
> $settles = $result['data'];
>
> $settlesRes = array();
> foreach ($settles as $sett) {
> $sname = $shopData[$sett['sid']];
> $sett['sname'] = $sname;
> $snameFirstChar = $this->_getFirstCharter($sname);
> //取出门店的第一个汉字的首字母
> $settlesRes[$snameFirstChar] = $sett;//以这个首字母作为key
> }
> ksort($settlesRes); //对数据进行ksort排序,以key的值升序排序
>
> _shopNamesArray
>
> Array
> (
> [0] => Array
> (
> [sid] => 2885842
> [recetcstoredpay] => 24000
> [recetclprinciple] => 23465
> [paytcstoredpay] => 5455
> [paytclprinciple] => 34900
> [sname] => 百宴餐饮---便宜坊烤鸭店
> )
>
> [1] => Array
> (
> [sid] => 3644191
> [recetcstoredpay] => 89200
> [recetclprinciple] => 406930
> [paytcstoredpay] => 4090
> [paytclprinciple] => 97800
> [sname] => 大长秋餐饮中心
> )
>
> [2] => Array
> (
> [sid] => 5229673
> [recetcstoredpay] => 26000
> [recetclprinciple] => 45930
> [paytcstoredpay] => 24795
> [paytclprinciple] => 121800
> [sname] => 大众点评网
> )
>
> [3] => Array
> (
> [sid] => 3715927
> [recetcstoredpay] => 13600
> [recetclprinciple] => 56930
> [paytcstoredpay] => 5710
> [paytclprinciple] => 37800
> [sname] => 江东北路店
> )
>
> [4] => Array
> (
> [sid] => 3671092
> [recetcstoredpay] => 1280
> [recetclprinciple] => 46930
> [paytcstoredpay] => 128090
> [paytclprinciple] => 149800
> [sname] => 金凤区新馆
> )
>
> [5] => Array
> (
> [sid] => 1858783
> [recetcstoredpay] => 2040
> [recetclprinciple] => 4465
> [paytcstoredpay] => 245
> [paytclprinciple] => 4900
> [sname] => 浙江西子宾馆
> )
>
> [6] => Array
> (
> [sid] => 16832117
> [recetcstoredpay] => 81600
> [recetclprinciple] => 470930
> [paytcstoredpay] => 506090
> [paytclprinciple] => 8000
> [sname] => 欢乐谷店
> )
>
> )
>
>
> ------------------ 原始邮件 ------------------
> *发件人:* "Uma S";<uma.s at vtiger.com>;
> *发送时间:* 2015年6月1日(星期一) 中午1:21
> *收件人:* "vtigercrm-developers"<vtigercrm-developers at lists.vtigercrm.com>;
> *主题:* Re: [Vtigercrm-developers] How to support the chinese sort
>
> Hi,
>
> Sorting in list-view should work irrespective of language translations
> right? Can you please let us know what's the issue you are facing with
> chinese characters?
>
> On Mon, Jun 1, 2015 at 7:55 AM, sunny <1250572980 at qq.com> wrote:
>
>>
>> We want to support the chinese sort in the list view,following:
>> when click the red Letter,the CRM system can sort by alphabet.
>> because our chinese use the same letters for the chinese ,or we can
>> translate the chinese to the english letters,but I do not know this sort
>> how to set up,or where to set up ,or which php file control the sort?
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>
>
>
> --
> With
> Best Regards
> Uma.S
> Vtiger Team
>
> _______________________________________________
> http://www.vtiger.com/
>
--
With
Best Regards
Uma.S
Vtiger Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20150601/667b0ed1/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 09096252 at 4050D10D.D5096C55
Type: application/octet-stream
Size: 55521 bytes
Desc: not available
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20150601/667b0ed1/attachment-0001.obj>
More information about the vtigercrm-developers
mailing list