Authored by 周少峰

错误页关键词处理

@@ -1047,7 +1047,7 @@ class HelperSearch @@ -1047,7 +1047,7 @@ class HelperSearch
1047 * @param array $list 1047 * @param array $list
1048 * @return array 1048 * @return array
1049 */ 1049 */
1050 - public static function getDiscount(array $list = array()) 1050 + public static function getDiscount($list = array())
1051 { 1051 {
1052 $params = self::$params; 1052 $params = self::$params;
1053 $query = array(); 1053 $query = array();
@@ -1378,4 +1378,65 @@ class HelperSearch @@ -1378,4 +1378,65 @@ class HelperSearch
1378 } 1378 }
1379 return $url; 1379 return $url;
1380 } 1380 }
  1381 +
  1382 +
  1383 + public static function stripTags($html) {
  1384 + $search = array(
  1385 + ' ',
  1386 + "'<script[^>]*?>.*?</script>'si",
  1387 + "'<[\/\!]*?[^<>]*?>'si",
  1388 + "'([\r\n])[\s]+'",
  1389 + "'&(quot|#34|#034|#x22);'i",
  1390 + "'&(amp|#38|#038|#x26);'i",
  1391 + "'&(lt|#60|#060|#x3c);'i",
  1392 + "'&(gt|#62|#062|#x3e);'i",
  1393 + "'&(nbsp|#160|#xa0);'i",
  1394 + "'&(iexcl|#161);'i",
  1395 + "'&(cent|#162);'i",
  1396 + "'&(pound|#163);'i",
  1397 + "'&(copy|#169);'i",
  1398 + "'&(reg|#174);'i",
  1399 + "'&(deg|#176);'i",
  1400 + "'&(#39|#039|#x27);'",
  1401 + "'&(euro|#8364);'i",
  1402 + "'&a(uml|UML);'",
  1403 + "'&o(uml|UML);'",
  1404 + "'&u(uml|UML);'",
  1405 + "'&A(uml|UML);'",
  1406 + "'&O(uml|UML);'",
  1407 + "'&U(uml|UML);'",
  1408 + "'&szlig;'i",
  1409 + "\n",
  1410 + "\r",
  1411 + "\t",
  1412 + "\0",
  1413 + " "
  1414 + );
  1415 + return trim(str_replace($search, '', strip_tags($html,"")));
  1416 + }
  1417 +
  1418 + /**
  1419 + *
  1420 + * 按字来切分字符 (UTF-8截字)
  1421 + *
  1422 + * @param String $str
  1423 + * @param Integer $length
  1424 + * @param Integer $start
  1425 + * @param String $encoding
  1426 + * @return String
  1427 + */
  1428 + public static function mbSubstr($str, $length, $start = 0, $suffix = '...', $encoding = "utf-8") {
  1429 + if (!is_string($str)) {
  1430 + return $str;
  1431 + }
  1432 + $str = trim($str);
  1433 + if (mb_strlen($str) == $length) {
  1434 + return $str;
  1435 + }
  1436 + $strs = mb_substr($str, $start, $length, $encoding);
  1437 + if ((mb_strlen($str) / 3) > $length) {
  1438 + $strs .= $suffix;
  1439 + }
  1440 + return $strs;
  1441 + }
1381 } 1442 }
@@ -160,7 +160,7 @@ class SearchModel @@ -160,7 +160,7 @@ class SearchModel
160 //$urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']); 160 //$urlList['sort'] = SearchData::getClassesUrl($searchCondition['sortCondition']);
161 $urlList['sort'] = SearchData::getClassesUrl(); 161 $urlList['sort'] = SearchData::getClassesUrl();
162 // 组合搜索折扣区间url 162 // 组合搜索折扣区间url
163 - $urlList['discount'] = SearchData::getDiscountUrl($searchCondition['condition']); 163 + $urlList['discount'] = SearchData::getDiscountUrl();
164 $result = Yohobuy::getMulti($urlList); 164 $result = Yohobuy::getMulti($urlList);
165 // 组织模板数据 165 // 组织模板数据
166 $data = HelperSearch::getList($result, $searchCondition['options']); 166 $data = HelperSearch::getList($result, $searchCondition['options']);
@@ -276,4 +276,32 @@ class SearchModel @@ -276,4 +276,32 @@ class SearchModel
276 return HelperSearch::size($result['data']['filter'], true); 276 return HelperSearch::size($result['data']['filter'], true);
277 } 277 }
278 } 278 }
  279 +
  280 + /**
  281 + * @param $keyword
  282 + * @return array
  283 + */
  284 + public static function searchError($keyword) {
  285 + $keyword = HelperSearch::stripTags($keyword);
  286 + $keyword = HelperSearch::mbSubstr($keyword, 300);
  287 + $data = array(
  288 + //初始化js
  289 + 'searchListPage' => true,
  290 + 'search' => array(
  291 + 'keyWord' => $keyword,
  292 + 'searchActionUrl' => 'http://search.yohobuy.com',
  293 + 'latestWalk' => 7,
  294 + 'pathNav' => Array(
  295 + '0'=>array(
  296 + 'href' => '/',
  297 + 'name' => '首页'
  298 + ),
  299 + '1'=>array(
  300 + 'name' => '搜索“<span id="nav_keyword">'.$keyword.'</span>”共<span id="nav_keyword_count">0</span>个结果'
  301 + )
  302 + )
  303 + )
  304 + );
  305 + return $data;
  306 + }
279 } 307 }
@@ -66,14 +66,15 @@ class ListController extends WebAction @@ -66,14 +66,15 @@ class ListController extends WebAction
66 $options['controller'] = 'Index'; 66 $options['controller'] = 'Index';
67 $options['action'] = 'sale'; 67 $options['action'] = 'sale';
68 $options['reviewNum'] = 6; 68 $options['reviewNum'] = 6;
69 - $condition = array(  
70 - 'p_d' => '0.01,0.99'  
71 - );  
72 $option = array( 69 $option = array(
73 'controller' => 'List', 70 'controller' => 'List',
74 'action' => 'sale', 71 'action' => 'sale',
75 'reviewNum' => 6 72 'reviewNum' => 6
76 ); 73 );
  74 + $condition = array();
  75 + if (!$this->get('p_d')){
  76 + $condition['p_d'] = '0.01,0.99';
  77 + }
77 $list = SearchModel::getListData($condition,$option); 78 $list = SearchModel::getListData($condition,$option);
78 $data = array( 79 $data = array(
79 //初始化js 80 //初始化js
@@ -63,24 +63,7 @@ class SearchController extends WebAction @@ -63,24 +63,7 @@ class SearchController extends WebAction
63 public function errorAction() 63 public function errorAction()
64 { 64 {
65 $keyword = $this->get('query'); 65 $keyword = $this->get('query');
66 - $data = array(  
67 - //初始化js  
68 - 'searchListPage' => true,  
69 - 'search' => array(  
70 - 'keyWord' => $keyword,  
71 - 'searchActionUrl' => 'http:://search.yohobuy.com',  
72 - 'latestWalk' => 7,  
73 - 'pathNav' => Array(  
74 - '0'=>array(  
75 - 'href' => '/',  
76 - 'name' => '首页'  
77 - ),  
78 - '1'=>array(  
79 - 'name' => '搜索“<span id="nav_keyword">'.$keyword.'</span>”共<span id="nav_keyword_count">0</span>个结果'  
80 - )  
81 - )  
82 - )  
83 - ); 66 + $data = SearchModel::searchError($keyword);
84 $this->setTitle('潮流商品搜索 | YOHO!有货'); 67 $this->setTitle('潮流商品搜索 | YOHO!有货');
85 $this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流'); 68 $this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流');
86 $this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜'); 69 $this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');