예제 #1
0
 /**
  * 
  */
 private function mobile_redirect()
 {
     header('Cache-Control:max-age=3600');
     //        header('Cache-Control:no-cache,no-store,max-age=0,must-revalidate');
     //        header("Pragma: no-cache");
     $flag = Utils::ismobile();
     if ($flag === true) {
         $uri = $this->getRequestURIPath();
         if (stripos($uri, '.shtml') === false) {
             $uri = str_replace('//', '/', $uri . '/');
         }
         $redirect_url = sprintf('%s%s', \Yii::getAlias('@mjb_domain'), $uri);
         header("Location:{$redirect_url}", true, 302);
         exit;
     }
     $this->fillSuffix();
 }
 /**
  * 适应宽度数据
  * @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;
 }
예제 #3
0
 /**
  * JSONP Callback输出,用于远程调用
  *
  * @param String $caption
  * @param Integer $code
  * @param mixed $content
  */
 protected function helpJsonCallbackResult($callbackString, $code, $message = null, $data = null)
 {
     echo $callbackString . "(";
     echo json_encode(Utils::result($code, $message, $data));
     echo ")";
     exit;
 }