Brand.class.php
4.18 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
/**
* 品牌控制器
*/
class Controller_Admin_Brand extends Controller_Admin_Base
{
/**
* 品牌列表Index
*/
public function indexAction()
{
$state = $this->_request->query('state',1);
$limit = 20 ;
$total = Facade_Brand::getBrandTotal($state);
$page = new Lib_Helper_Pagination($total,$limit);
$offset = $page->getOffset() ;
$info = Facade_Brand::getBrandByState($offset, $limit, $state);
$relas = Facade_Brand::getBrandNewsRelaByBrandID(array_keys($info));
$brandRelas = array();
foreach($relas as $rela)
{
if(!isset($brandRelas[$rela['brand_id']]))
{
$brandRelas[$rela['brand_id']] = '';
}
$brandRelas[$rela['brand_id']] .= $rela['news_id'].',';
}
$page->setParames(array('state'=>$state));
$this->_view['pagination'] = $page->getPagination();
$this->_view['data'] = $info;
$this->_view['brandRelas'] = $brandRelas;
$this->_view['state'] = $state;
$this->_view['key'] = Lib_Images::genKey('fragmentimg');
}
/**
* 获取所有品牌
*
* @return json
*/
public function getallbrandAction()
{
$list = Facade_Brand::getBrandByState(0, 1000, 1);
$brands = array();
foreach ($list as $brand)
{
$index = Lib_Utils_StringHelper::getFirstLetter($brand['name']);
if(empty($index))
{
$index = substr($brand['name'], 0, 1);
}
if(is_numeric($index))
{
$index = '0-9';
}
$brands[$index][] = $brand;
}
ksort($brands);
return $this->returnJson(true,200, $brands);
}
/**
* 获取品牌详情
*/
public function detailAction()
{
$id = $this->_request->query('id',0);
$info = Facade_Brand::getBrandbyID($id);
if(info)
{
return $this->returnJson(true,200,info);
}
else
{
return $this->returnJson(false,404,null);
}
}
/**
* 编号
*/
public function boothAction()
{
$this->_view['boothList'] = Facade_Brand::getBoothList();
}
/**
* 设置booth编号
*
* @return json
*/
public function setboothAction()
{
$booth_id = $this->_request->query('booth_id', '');
$position = $this->_request->query('position', '');
$status = Facade_Brand::setBooth($booth_id, $position);
if($status)
{
return $this->returnJson(true, 200);
}
else
{
return $this->returnJson(false, 403);
}
}
/**
* 删除booth编号
*
* @return json
*/
public function delboothAction()
{
$booth_id = $this->_request->query('booth_id', '');
$status = Facade_Brand::delBooth($booth_id);
if($status)
{
return $this->returnJson(true, 200);
}
else
{
return $this->returnJson(false, 403);
}
}
/**
* 提交品牌
*/
public function submitAction()
{
$id = $this->_request->query('id',0);
$name = $this->_request->query('name','');
$logo = $this->_request->query('logo','');
$description = $this->_request->query('description','');
$state = $this->_request->query('state','');
$pics = $this->_request->query('pics','');
$person = $this->_request->query('person','');
$seq = $this->_request->query('seq','');
$news_ids = $this->_request->query('news_ids','');
$boothId = $this->_request->query('boothId', '');
$link = $this->_request->query('link', '');
$ret = false;
if($id)
{
$ret = Facade_Brand::updateBrand($id, $name, $logo, $description, $state, $pics, $person, $seq, $news_ids, $boothId, $link);
}
else
{
$ret = Facade_Brand::submitBrand($name, $logo, $description, $state, $pics, $person, $seq, $news_ids, $boothId, $link);
}
if($ret)
{
return $this->returnJson(true,200,null);
}
else
{
return $this->returnJson(false,404,null);
}
}
}