...
|
...
|
@@ -27,6 +27,8 @@ class HelperSearch |
|
|
public static $selected = array();
|
|
|
//list分类面包屑
|
|
|
public static $listNav = array();
|
|
|
//
|
|
|
public static $specialsaleParam = array();
|
|
|
//设置导航
|
|
|
private static function setListNav()
|
|
|
{
|
...
|
...
|
@@ -100,6 +102,10 @@ class HelperSearch |
|
|
if (isset($data['discount']['discount']) && !empty($data['discount']['discount'])) {
|
|
|
$result['leftContent'][]['allDiscount'] = self::getDiscount($data['discount']['discount']);
|
|
|
}
|
|
|
//一周新品上架
|
|
|
if (isset($data['recent']['recent']) && !empty($data['recent']['recent'])) {
|
|
|
$result['leftContent'][]['newSales'] = self::recentShelve($data['recent']['recent']);
|
|
|
}
|
|
|
//分类条件(搜索页面)
|
|
|
if (isset($data['sort']['sort'])) {
|
|
|
//分类条件(搜索页面)
|
...
|
...
|
@@ -110,10 +116,7 @@ class HelperSearch |
|
|
$result['leftContent'][]['allSort'] = self::groupSort($data['sort']['sort']);
|
|
|
}
|
|
|
}
|
|
|
//一周新品上架
|
|
|
if (isset($data['recent']['recent']) && !empty($data['recent']['recent'])) {
|
|
|
$result['leftContent'][]['newSales'] = self::recentShelve($data['recent']['recent']);
|
|
|
}
|
|
|
|
|
|
//品牌banner
|
|
|
$result['brandBanner'] = isset($data['brand']) && !empty($data['brand']) ? self::getBannerFormat($data['brand'], $options['brandBanner']) : array();
|
|
|
//总记录数
|
...
|
...
|
@@ -149,6 +152,7 @@ class HelperSearch |
|
|
/**
|
|
|
* TODO 组织商品列表信息
|
|
|
* @param $product 接口返回商品列表
|
|
|
* @param $options 条件
|
|
|
* @author sefon 2015-12-21 17:24:04
|
|
|
* @return array
|
|
|
*/
|
...
|
...
|
@@ -350,6 +354,13 @@ class HelperSearch |
|
|
);
|
|
|
$sortList = array();
|
|
|
|
|
|
//加上specialsale_id参数
|
|
|
if (self::$options['controller'] == 'Sale') {
|
|
|
self::$specialsaleParam = array(
|
|
|
'specialsale_id' => isset(self::$params['specialsale_id']) ? self::$params['specialsale_id'] : ''
|
|
|
);
|
|
|
}
|
|
|
|
|
|
foreach ($sort as $key => $val) {
|
|
|
//是否有品牌
|
|
|
if ($options['action'] != 'brand' && $options['controller'] != 'Index') {
|
...
|
...
|
@@ -379,13 +390,13 @@ class HelperSearch |
|
|
$sortList[$key]['name'] = $val['sort_name'];
|
|
|
$sortList[$key]['active'] = isset(self::$params['msort']) && self::$params['msort'] == $val['sort_id'] ? true : false;
|
|
|
$sortList[$key]['childList'][] = array(
|
|
|
'name' => '全部分类',
|
|
|
'name' => '全部'.$val['sort_name'],
|
|
|
'href' => self::buildUrl(array_merge($gender, array('msort'=>$val['sort_id'])))
|
|
|
);
|
|
|
if (isset($val['sub']) && !empty($val['sub'])) {
|
|
|
foreach ($val['sub'] as $k => $v) {
|
|
|
$sortList[$key]['childList'][$k+1]['name'] = $v['sort_name'];
|
|
|
$sortList[$key]['childList'][$k+1]['href'] = self::buildUrl(array_merge($gender, array('msort' => $val['sort_id'], 'misort' => $v['sort_id'])));
|
|
|
$sortList[$key]['childList'][$k+1]['href'] = self::buildUrl(array_merge($gender, array('msort' => $val['sort_id'], 'misort' => $v['sort_id']), self::$specialsaleParam));
|
|
|
$sortList[$key]['childList'][$k+1]['childActive'] = isset(self::$params['misort']) && self::$params['misort'] == $v['sort_id'] ? true : false;
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -1037,6 +1048,7 @@ class HelperSearch |
|
|
if ($data) {
|
|
|
$result['conditions'] = $data;
|
|
|
$result['clearUrl'] = self::current();
|
|
|
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
@@ -1046,7 +1058,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();
|
...
|
...
|
@@ -1085,7 +1097,7 @@ class HelperSearch |
|
|
$data[$i]['active'] = true;
|
|
|
}
|
|
|
$data[$i]['href'] = self::buildUrl($query);
|
|
|
$data[$i]['name'] = $k;
|
|
|
$data[$i]['name'] = date('m月d日', strtotime($k));
|
|
|
$i++;
|
|
|
}
|
|
|
$result = array(
|
...
|
...
|
@@ -1093,6 +1105,7 @@ class HelperSearch |
|
|
);
|
|
|
unset($data);
|
|
|
unset($query);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
/**
|
...
|
...
|
@@ -1101,6 +1114,9 @@ class HelperSearch |
|
|
public static function current()
|
|
|
{
|
|
|
$url = explode('?', 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
|
|
if (!empty(self::$specialsaleParam)) {
|
|
|
$url[0] .= '?' . http_build_query(self::$specialsaleParam);
|
|
|
}
|
|
|
return $url[0];
|
|
|
}
|
|
|
/**
|
...
|
...
|
@@ -1377,4 +1393,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);'",
|
|
|
"'ß'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;
|
|
|
}
|
|
|
} |
...
|
...
|
|