Authored by 周少峰

错误页关键词处理

... ... @@ -1047,7 +1047,7 @@ class HelperSearch
* @param array $list
* @return array
*/
public static function getDiscount(array $list = array())
public static function getDiscount($list = array())
{
$params = self::$params;
$query = array();
... ... @@ -1378,4 +1378,65 @@ class HelperSearch
}
return $url;
}
public static function stripTags($html) {
$search = array(
' ',
"'<script[^>]*?>.*?</script>'si",
"'<[\/\!]*?[^<>]*?>'si",
"'([\r\n])[\s]+'",
"'&(quot|#34|#034|#x22);'i",
"'&(amp|#38|#038|#x26);'i",
"'&(lt|#60|#060|#x3c);'i",
"'&(gt|#62|#062|#x3e);'i",
"'&(nbsp|#160|#xa0);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&(reg|#174);'i",
"'&(deg|#176);'i",
"'&(#39|#039|#x27);'",
"'&(euro|#8364);'i",
"'&a(uml|UML);'",
"'&o(uml|UML);'",
"'&u(uml|UML);'",
"'&A(uml|UML);'",
"'&O(uml|UML);'",
"'&U(uml|UML);'",
"'&szlig;'i",
"\n",
"\r",
"\t",
"\0",
" "
);
return trim(str_replace($search, '', strip_tags($html,"")));
}
/**
*
* 按字来切分字符 (UTF-8截字)
*
* @param String $str
* @param Integer $length
* @param Integer $start
* @param String $encoding
* @return String
*/
public static function mbSubstr($str, $length, $start = 0, $suffix = '...', $encoding = "utf-8") {
if (!is_string($str)) {
return $str;
}
$str = trim($str);
if (mb_strlen($str) == $length) {
return $str;
}
$strs = mb_substr($str, $start, $length, $encoding);
if ((mb_strlen($str) / 3) > $length) {
$strs .= $suffix;
}
return $strs;
}
}
... ...
... ... @@ -160,7 +160,7 @@ class SearchModel
//$urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']);
$urlList['sort'] = SearchData::getClassesUrl();
// 组合搜索折扣区间url
$urlList['discount'] = SearchData::getDiscountUrl($searchCondition['condition']);
$urlList['discount'] = SearchData::getDiscountUrl();
$result = Yohobuy::getMulti($urlList);
// 组织模板数据
$data = HelperSearch::getList($result, $searchCondition['options']);
... ... @@ -276,4 +276,32 @@ class SearchModel
return HelperSearch::size($result['data']['filter'], true);
}
}
/**
* @param $keyword
* @return array
*/
public static function searchError($keyword) {
$keyword = HelperSearch::stripTags($keyword);
$keyword = HelperSearch::mbSubstr($keyword, 300);
$data = array(
//初始化js
'searchListPage' => true,
'search' => array(
'keyWord' => $keyword,
'searchActionUrl' => 'http://search.yohobuy.com',
'latestWalk' => 7,
'pathNav' => Array(
'0'=>array(
'href' => '/',
'name' => '首页'
),
'1'=>array(
'name' => '搜索“<span id="nav_keyword">'.$keyword.'</span>”共<span id="nav_keyword_count">0</span>个结果'
)
)
)
);
return $data;
}
}
\ No newline at end of file
... ...
... ... @@ -66,14 +66,15 @@ class ListController extends WebAction
$options['controller'] = 'Index';
$options['action'] = 'sale';
$options['reviewNum'] = 6;
$condition = array(
'p_d' => '0.01,0.99'
);
$option = array(
'controller' => 'List',
'action' => 'sale',
'reviewNum' => 6
);
$condition = array();
if (!$this->get('p_d')){
$condition['p_d'] = '0.01,0.99';
}
$list = SearchModel::getListData($condition,$option);
$data = array(
//初始化js
... ...
... ... @@ -63,24 +63,7 @@ class SearchController extends WebAction
public function errorAction()
{
$keyword = $this->get('query');
$data = array(
//初始化js
'searchListPage' => true,
'search' => array(
'keyWord' => $keyword,
'searchActionUrl' => 'http:://search.yohobuy.com',
'latestWalk' => 7,
'pathNav' => Array(
'0'=>array(
'href' => '/',
'name' => '首页'
),
'1'=>array(
'name' => '搜索“<span id="nav_keyword">'.$keyword.'</span>”共<span id="nav_keyword_count">0</span>个结果'
)
)
)
);
$data = SearchModel::searchError($keyword);
$this->setTitle('潮流商品搜索 | YOHO!有货');
$this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流');
$this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');
... ...