Authored by 周少峰

分类和其他搜索条件分离

@@ -16,7 +16,6 @@ class HelperSearch @@ -16,7 +16,6 @@ class HelperSearch
16 public static $options = array(); 16 public static $options = array();
17 //当前页 17 //当前页
18 public static $page = 1; 18 public static $page = 1;
19 - public static $siteDomain = '.yohobuy.com';  
20 19
21 /** 20 /**
22 * 选中的条件 21 * 选中的条件
@@ -223,6 +222,9 @@ class HelperSearch @@ -223,6 +222,9 @@ class HelperSearch
223 } 222 }
224 $params = self::$params; 223 $params = self::$params;
225 $gender = isset($params['gender']) ? $params['gender'] : ''; 224 $gender = isset($params['gender']) ? $params['gender'] : '';
  225 + if (isset($params['gender'])) {
  226 + unset($params['gender']);
  227 + }
226 //设置选中 228 //设置选中
227 if ($gender == '1,3' || $gender == '2,3') { 229 if ($gender == '1,3' || $gender == '2,3') {
228 self::$selected['gender'] = array( 230 self::$selected['gender'] = array(
@@ -230,9 +232,7 @@ class HelperSearch @@ -230,9 +232,7 @@ class HelperSearch
230 'href' => self::buildUrl($params) 232 'href' => self::buildUrl($params)
231 ); 233 );
232 } 234 }
233 - if (isset($params['gender'])) {  
234 - unset($params['gender']);  
235 - } 235 +
236 if (self::checkSearch('gender')) { 236 if (self::checkSearch('gender')) {
237 return array(); 237 return array();
238 } 238 }
@@ -317,22 +317,15 @@ class HelperSearch @@ -317,22 +317,15 @@ class HelperSearch
317 foreach ($sort as $key => $val) { 317 foreach ($sort as $key => $val) {
318 $result[$key]['id'] = $val['sort_id']; 318 $result[$key]['id'] = $val['sort_id'];
319 $result[$key]['name'] = $val['sort_name']; 319 $result[$key]['name'] = $val['sort_name'];
320 - if (isset($params['msort']) && $params['msort'] == $val['sort_id']) {  
321 - unset($params['msort']);  
322 - self::$selected['sort'] = array(  
323 - 'name' => $val['sort_name'],  
324 - 'href' => self::buildUrl($params)  
325 - );  
326 - }  
327 if (isset($val['sub']) && !empty($val['sub'])) { 320 if (isset($val['sub']) && !empty($val['sub'])) {
328 foreach ($val['sub'] as $k => $v) { 321 foreach ($val['sub'] as $k => $v) {
329 - $result[$key]['sub'][$k]['href'] = self::buildUrl(array_merge($params, array('msort' => $val['sort_id'], 'misort' => $v['sort_id']))); 322 + $result[$key]['sub'][$k]['href'] = self::buildUrl(array('msort' => $val['sort_id'], 'misort' => $v['sort_id']));
330 $result[$key]['sub'][$k]['name'] = $v['sort_name']; 323 $result[$key]['sub'][$k]['name'] = $v['sort_name'];
331 if (isset($params['misort']) && $params['misort'] == $v['sort_id']) { 324 if (isset($params['misort']) && $params['misort'] == $v['sort_id']) {
332 unset($params['misort']); 325 unset($params['misort']);
333 self::$selected['sort'] = array( 326 self::$selected['sort'] = array(
334 'name' => $v['sort_name'], 327 'name' => $v['sort_name'],
335 - 'href' => self::buildUrl($params) 328 + 'href' => self::buildUrl()
336 ); 329 );
337 } 330 }
338 331
@@ -424,10 +417,6 @@ class HelperSearch @@ -424,10 +417,6 @@ class HelperSearch
424 'href' => self::buildUrl($params) 417 'href' => self::buildUrl($params)
425 ); 418 );
426 } 419 }
427 - //搜索页已选中,返回空  
428 - if (self::checkSearch('brand')) {  
429 - return array();  
430 - }  
431 ksort($brandList); 420 ksort($brandList);
432 //品牌列表排序, 添加品牌索引 421 //品牌列表排序, 添加品牌索引
433 $index_key = array(); 422 $index_key = array();
@@ -446,6 +435,10 @@ class HelperSearch @@ -446,6 +435,10 @@ class HelperSearch
446 } 435 }
447 unset($brandList); 436 unset($brandList);
448 } 437 }
  438 + //搜索页已选中,返回空
  439 + if (self::checkSearch('brand')) {
  440 + return array();
  441 + }
449 return $result; 442 return $result;
450 } 443 }
451 /** 444 /**
@@ -470,9 +463,7 @@ class HelperSearch @@ -470,9 +463,7 @@ class HelperSearch
470 'href' => self::buildUrl($params) 463 'href' => self::buildUrl($params)
471 ); 464 );
472 } 465 }
473 - if (self::checkSearch('size')) {  
474 - return array();  
475 - } 466 +
476 $result[] = array( 467 $result[] = array(
477 'name' => $v['size_name'], 468 'name' => $v['size_name'],
478 'href' => self::buildUrl(array_merge($params, array( 469 'href' => self::buildUrl(array_merge($params, array(
@@ -480,6 +471,9 @@ class HelperSearch @@ -480,6 +471,9 @@ class HelperSearch
480 ))) , 471 ))) ,
481 ); 472 );
482 } 473 }
  474 + if (self::checkSearch('size')) {
  475 + return array();
  476 + }
483 } 477 }
484 return $result; 478 return $result;
485 } 479 }
@@ -1061,6 +1055,7 @@ class HelperSearch @@ -1061,6 +1055,7 @@ class HelperSearch
1061 */ 1055 */
1062 public static function shop($shop) 1056 public static function shop($shop)
1063 { 1057 {
  1058 + $url = Helpers::url('','',$shop['brand_domain']);
1064 $shopEntry = array(); 1059 $shopEntry = array();
1065 $sort = array(); 1060 $sort = array();
1066 foreach ($shop['sort'] as $msort) { 1061 foreach ($shop['sort'] as $msort) {
@@ -1071,13 +1066,13 @@ class HelperSearch @@ -1071,13 +1066,13 @@ class HelperSearch
1071 if (count($sort) >= 10) { 1066 if (count($sort) >= 10) {
1072 break 2; 1067 break 2;
1073 } 1068 }
1074 - $sortInfo['href'] = 'http://' . $shop['brand_domain'] . self::$siteDomain.'/?msort=' . $msort['sort_id'] . '&misort=' . $misort['sort_id']; 1069 + $sortInfo['href'] = $url.'/?msort=' . $msort['sort_id'] . '&misort=' . $misort['sort_id'];
1075 $sortInfo['name'] = $misort['sort_name']; 1070 $sortInfo['name'] = $misort['sort_name'];
1076 $sort[] = $sortInfo; 1071 $sort[] = $sortInfo;
1077 } 1072 }
1078 1073
1079 } 1074 }
1080 - $shopEntry['home'] = $shop['brand_domain'].'yohobuy.com'; 1075 + $shopEntry['home'] = $url;
1081 $shopEntry['logo'] = Images::getSourceUrl($shop['brand_ico'],'brandLogo'); 1076 $shopEntry['logo'] = Images::getSourceUrl($shop['brand_ico'],'brandLogo');
1082 $shopEntry['shopName'] = $shop['brand_name']; 1077 $shopEntry['shopName'] = $shop['brand_name'];
1083 $shopEntry['sort'] = $sort; 1078 $shopEntry['sort'] = $sort;