示例#1
0
 /**
  * 根据用户名与昵称获得拼音 
  * @param $name
  * @param $nick
  * @return string
  */
 private function getPinYinByName($name, $nick)
 {
     $py = new PinYin();
     $allPY = $py->getAllPY($name);
     $firstPY = $py->getFirstPY($name);
     $namePY = $allPY . "|" . $firstPY;
     $allPY = $py->getAllPY($nick);
     $firstPY = $py->getFirstPY($nick);
     $nickPY = $allPY . "|" . $firstPY;
     return $namePY . "|" . $nickPY;
 }
示例#2
0
文件: at.php 项目: druphliu/dzzoffice
include_once dzz_libfile('class/pinyin');
$py = new PinYin();
$data = array();
$term = trim($_GET['term']);
$filter = intval($_GET['filter']);
//0:机构和用户;1:仅用户;2:仅机构
if ($filter == 1 || !$filter) {
    $param_user = array('user', 'user_status');
    $sql_user = "******";
    if ($term) {
        $sql_user .= " and username LIKE %s";
        $param_user[] = '%' . $term . '%';
    }
    foreach (DB::fetch_all("select u.uid,u.username  from %t u LEFT JOIN %t s on u.uid=s.uid  {$sql_user} order by s.lastactivity DESC limit 10", $param_user) as $value) {
        if ($value['uid'] != $_G['uid']) {
            $data[] = array('name' => $value['username'], 'searchkey' => $py->getAllPY($value['username']) . $value['username'], 'id' => 'u' . $value['uid'], 'icon' => 'avatar.php?uid=' . $value['uid'] . '&size=small', 'title' => $value['username'] . ':' . 'u' . $value['uid']);
        }
    }
    $param_org = array('organization');
    $sql_org = "where 1";
    if ($term) {
        $sql_org .= " and orgname LIKE %s";
        $param_org[] = '%' . $term . '%';
    }
}
if ($filter == 2 || !$filter) {
    $orgids = array();
    if ($at_range = $_G['setting']['at_range'][$_G['groupid']]) {
        switch ($at_range) {
            case 1:
                //本部门
示例#3
0
 /**
  * 获得文件名全拼及简拼
  */
 public static function getPinYinByName($name)
 {
     $py = new PinYin();
     $len = mb_strlen($name, 'utf-8');
     $allPY = "";
     $firstPY = "";
     for ($i = 0; $i < $len; $i++) {
         $subName = mb_substr($name, $i, 1, "utf-8");
         $allPY .= $py->getAllPY($subName);
         $firstPY .= $py->getFirstPY($subName);
     }
     if (empty($allPY)) {
         $allPY = $firstPY = $name;
     }
     $namePY = $allPY . "|" . $firstPY;
     if (strlen($namePY) > 255) {
         $namePY = substr($namePY, 0, 254);
     }
     return $namePY;
 }