Authored by whb

修改bug

... ... @@ -127,7 +127,7 @@ define('mobile', function(require, exports) {
$('.search-wrap input').focus().addClass('hasVal');
});
//获取所有品牌
$(".all_brand").live("tap", function() {
$(".all_brand").live("click", function() {
$("input[type='text']").val("");
getBrand();
});
... ...
... ... @@ -719,7 +719,44 @@ class Lib_Utils_StringHelper
$ar [$k] = iconv ( "UCS-2", "UTF-8", pack ( "H4", substr ( $v, - 4 ) ) );
return join ( "", $ar );
}
/**
* 截取完整英文
*
* @param string $string
* @param int $length
* @param $etc
* @return string
*/
public static function substr_full_en($string, $length = 280, $etc = '...')
{
$chars = $string;
$tmp = $i = $n = $m = $l = 0;
if (mb_strwidth ( $string , 'UTF-8' ) <= $length)
return $string;
do
{
if (preg_match ("/[0-9a-zA-Z]/", @$chars[$i])) //纯英文
{
$m++;
$tmp++;
}
else //非英文字节
{
$n++;
$tmp = 0;
}
$k = $n/3 + $m/2;
$l = $n/3 + $m;//最终截取长度;$l = $n/3+$m
$i++;
} while($k < $length);
if(preg_match ("/[0-9a-zA-Z]/", @$chars[$i-1]))//英文是不是完整的
{
$l = $l- $tmp;
}
return mb_substr($string, 0, $l,'utf-8').$etc;//保证不会出现乱码
}
/**
* 获取货币
*
... ...
... ... @@ -43,7 +43,33 @@
</div>
<?php endif;?>
<div class="text-body">
<?php echo $this->view->info['content']?>
<?php
if(preg_match('/ipad/i', $_SERVER['HTTP_USER_AGENT']))
{
$temps = $videoMatches = array();
@preg_match_all("@<embed([^>]*)\s*src=\"http:\/\/res\.yoho\.cn\/res\/yohood\/swf\/YohoodPlayer\.swf\?url=(.+\.mp4)\"@", $this->view->info['content'], $videoMatches1);
@preg_match_all("@<embed([^>]*)\s*src=\"http:\/\/res\.yohood\.test\.yoho\.cn\/swf\/YohoodPlayer\.swf\?url=(.+\.mp4|.+)\"@iU", $this->view->info['content'], $videoMatches2);
@preg_match_all("@<embed([^>]*)\s*src=\"http:\/\/res\.yohood\.cn\/swf\/YohoodPlayer\.swf\?url=(.+\.mp4|.+)\"@iU", $this->view->info['content'], $videoMatches3);
$temps[] = $videoMatches1;
$temps[] = $videoMatches2;
$temps[] = $videoMatches3;
foreach($temps as $temp)
{
if(!empty($temp[2]))
{
$videoMatches = $temp;
}
}
if(!empty($videoMatches[2]))
{
$video = current($videoMatches[2]);
$videoHtml = '<video controls="controls" preload="auto" poster="'.Lib_Images::getImageUrl($this->view->info['thumb'],'0650x0390','fragmentimg','autoCrop').'" width="660" height="390"><source src="'.$video.'" type="video/mp4" /></video>';
$this->view->info['content'] = preg_replace('@<(object.*?)>(.*?)<(\/object.*?)>@si',$videoHtml, $this->view->info['content']);
$this->view->info['content'] = preg_replace('@<(embed.*?)>@si', $videoHtml, $this->view->info['content']);
}
}
echo $this->view->info['content'];
?>
</div>
<div class="related-post detail-related-post">
<h3>相关推荐</h3>
... ...
<?php foreach($list as $news):
$title = Util_StringHelper::substr_cn($news['title'], 90);
$description = Lib_Utils_StringHelper::substr_cn(Lib_Utils_StringHelper::stripTags($news['content']), 68);
$description = Lib_Utils_StringHelper::substr_full_en(Lib_Utils_StringHelper::stripTags($news['content']), 40);
$height = $width = 0;
$thumb_size = json_decode($news['thumb_size'], true);
if ($news['thumb'])
... ...
<?php foreach($list as $news):
$title = Util_StringHelper::substr_cn($news['title'], 90);
$description = Lib_Utils_StringHelper::substr_cn(Lib_Utils_StringHelper::stripTags($news['content']), 68);
$height = $width = 0;
$description = Lib_Utils_StringHelper::substr_full_en(Lib_Utils_StringHelper::stripTags($news['content']), 36);
$thumb_size = json_decode($news['thumb_size'], true);
if(empty($news['client_thumb']))
{
... ...