/**
  * 适应宽度数据
  * @param type $data
  * @param type $max_dis_lenth
  * @return type
  */
 private function fitwidthdata($data, $max_dis_lenth)
 {
     $return_arr = array();
     $tmp_str = '';
     foreach ($data as $v) {
         $v = is_array($v) ? $v['name'] : $v;
         $pinyin = is_array($v) ? $v['pinyin_initial'] : $v;
         $tmp_str .= $v;
         $str_len = mb_strlen($tmp_str, 'utf8');
         if ($str_len >= $max_dis_lenth) {
             $cut_len = $max_dis_lenth - ($str_len - mb_strlen($v, 'utf8'));
             $cur_str = Utils::String()->mbSubstr($v, $cut_len, 0);
             $return_arr[] = $cur_str;
             break;
         } else {
             $return_arr[] = $v;
         }
     }
     return $return_arr;
 }
예제 #2
0
 /**
  * refresh跳转
  *
  * @param String $url
  * @param String $message
  * @param Integer $content
  */
 protected function helpRefresh($url, $message = '', $content = 0, $show = false)
 {
     if (!empty($message)) {
         header("content-type: text/html; charset=utf-8");
         $message = Utils::String()->addslash($message);
         $message = str_replace("\n", "\\n", $message);
         echo "<script language=\"javascript\">";
         echo "alert(\"{$message}\");";
         echo "</script>";
     }
     echo "<script language=\"javascript\">";
     echo "window.location.href='{$url}';";
     echo "</script>";
     if ($show == false) {
         exit;
     }
 }