BoxBrand.php
1.89 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
<?php
/**
*
* @author liuziyang
* @version
*/
/**
* BoxBrand helper
*
* @uses viewHelper Zend_View_Helper
*/
class Web_View_Helper_BoxBrand extends Zend_View_Helper_Abstract {
/**
* @var Zend_View_Interface
*/
public $view;
/**
*
*/
public function boxBrand($sort_ids, $brand_id = 0) {
$max_sort_id = empty($sort_ids['msort']) ? 0 : $sort_ids['msort'];
$middle_sort_id = empty($sort_ids['misort']) ? 0 : $sort_ids['misort'];
$small_sort_id = empty($sort_ids['sort']) ? 0 : $sort_ids['sort'];
#获取所有品牌
$boxBrandAll = QINProduct_Models_Brand_Client::getAllBaseBrand();
$sortBrands = $this->getBrandsByOneSort($boxBrandAll, $max_sort_id, $middle_sort_id, $small_sort_id);
if (isset($this->view->view_is_promotion)) {
$promotionBrands = QModels_Product_Client::getPromotionBrandIds($this->view->view_is_promotion);
foreach ($sortBrands as $k => $v) {
if (!in_array($k, $promotionBrands, true)) {
unset($sortBrands[$k]);
}
}
}
$this->view->brands = $brands = $sortBrands;
$boxBrand = array_slice($brands, 0, 10);
if ($brand_id > 0 && !empty($boxBrandAll[$brand_id])) {
$this->view->nowBrand = $boxBrandAll[$brand_id];
}
$this->view->boxBrand = $boxBrand;
$this->view->boxBrandAll = $boxBrandAll = QModels_Brand_Sort_Client::makeBrandsAlifGroup(array_keys($brands), $boxBrandAll);
return $this->view->render('box/brand.phtml');
}
public function getBrandsByOneSort(array $brand, $max_sort_id, $middle_sort_id = 0, $small_sort_id = 0) {
$brandIds = QModels_Brand_Sort_Client::getBrandIdsByOneSort($max_sort_id, $middle_sort_id, $small_sort_id);
$result = array();
foreach ($brandIds as $k => $v) {
if (isset($brand[$k])) {
$result[$k] = $brand[$k];
}
}
return $result;
}
/**
* Sets the view field
* @param $view Zend_View_Interface
*/
public function setView(Zend_View_Interface $view) {
$this->view = $view;
}
}