BoxOrderBy.php
1.95 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
<?php
/**
*
* @author liuziyang
* @version
*/
/**
* BoxOrderBy helper
*
* @uses viewHelper Zend_View_Helper
*/
class Web_View_Helper_BoxOrderBy {
/**
* @var Zend_View_Interface
*/
public $view;
/**
*
*/
public function boxOrderBy(array $order_list) {
$this->view->s_t_class = isset($order_list['s_t']) ? $this->selectOreder($order_list['s_t']) : $this->selectOreder();
$this->view->s_t_url = isset($order_list['s_t']) ? $this->getOrder($order_list['s_t']) : $this->getOrder();
$orderData = array(
'class' => '',
'name_txt' => '默认排序'
);
if (isset($order_list['s_p'])) {
$orderData = $this->getClass($order_list['s_p']);
}
elseif (isset($order_list['s_n'])) {
$orderData = $this->getClass($order_list['s_n'], 's_n');
}
$this->view->order_by_default = $orderData;
return $this->view->render('box/orderby.phtml');
}
public function getClass($order = '', $act = 's_p') {
$data = array(
'class' => '',
'name_txt' => '默认排序'
);
$act_txt = ($act == 's_p') ? '价格' : '销量';
switch ($order) {
case 'asc' :
$data = array(
'class' => 'pr_up',
'name_txt' => $act_txt . '由低到高'
);
break;
case 'desc' :
$data = array(
'class' => 'pr_down',
'name_txt' => $act_txt . '由高到低'
);
break;
}
return $data;
}
public function getOrder($opt = '') {
$order = '';
switch ($opt) {
case 'asc' :
$order = 'desc';
break;
case 'desc' :
$order = 'asc';
break;
default :
$order = 'desc';
}
return $order;
}
public function selectOreder($select = '') {
$class = 'p_up';
switch ($select) {
case 'asc' :
$class = 'p_down_act';
break;
case 'desc' :
$class = 'p_up_act';
break;
default :
$class = 'p_up';
}
return $class;
}
/**
* Sets the view field
* @param $view Zend_View_Interface
*/
public function setView(Zend_View_Interface $view) {
$this->view = $view;
}
}