Brand.class.php
2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* 默认控制器
*/
class Controller_Brand extends Controller_Abstract
{
public function indexAction()
{
$banners = Facade_Index::getIndex(3);
$this->_view['banners'] = $banners;
$this->_view['brandTotal'] = Facade_Brand::getBrandTotal(1);
}
/**
* 详情页
*/
public function detailAction()
{
$id = intval($this->_request->id);
$info = Facade_Brand::getBrandbyID($id);
$client = $this->_request->query('client', 0);
if($client || $this->_platform != 'web')
{
$yohobuyBrands = Facade_Brand::getYohobuyBrand();
$yohobuyBrandId = '0';
foreach($yohobuyBrands as $yohobuyBrand)
{
$yohobuyBrand['brand_name'] = trim(strtolower($yohobuyBrand['brand_name']));
if(strtolower($info['name']) == $yohobuyBrand['brand_name'])
{
$yohobuyBrandId = $yohobuyBrand['brand_id'];
break;
}
}
if($client)
{
$info['link'] = 'openby:'.urlencode('yohobuy={"action":"go.brand","params":{"brand_id":"'.$yohobuyBrandId.'"}}');
}
}
$relas = Facade_Brand::getBrandNewsRelaByBrandID($id);
$news = array();
foreach ($relas as $rela)
{
$new = Facade_News::getOneById($rela['news_id']);
if($new)
{
$news[] = $new;
}
}
$news = array_slice($news, 0, 3);
$this->_view['info'] = $info;
$this->_view['news'] = $news;
}
/**
* 获取品牌
*
* @return json
*/
public function getbrandAction()
{
$brand = trim($this->_request->query('brand', ''));
$brand = str_replace(array('%'), array('\%'), $brand);
$brands = $list = array();
if($brand == '')
{
$brands = Facade_Brand::getBrandByState(0, 200, 1);
}
else
{
$brands = Facade_Brand::getBrandByName($brand, 1);
}
foreach($brands as $key => $brand)
{
$list[$key] = array('id' => $brand['id'], 'name' => $brand['name'],'logo'=> $brand['logo']);
}
return $this->returnJson(true, 200, array_values($list));
}
}