SuccessorController.class.php
3.9 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
<?php
/**
* Created by PhpStorm.
* User: 29925
* Date: 2018/4/2
* Time: 13:34
*/
namespace Portal\Controller;
use Common\Controller\HomebaseController;
class SuccessorController extends HomebaseController {
protected $successor_model;
protected $successor_produce_model;
function _initialize() {
parent::_initialize();
$this->successor_model = D("Common/Successor");
$this->successor_produce_model = D("Common/SuccessorProduct");
}
// 传承人列表
public function index(){
$this->region();
$this->nation();
$this->product();
if(I('get.product',0,'intval')) {
$this->product_son(I('get.product'));
}
$this->assign('sex', array('1'=>'男', '2'=>'女'));
$this->assign('level', array('国家级', '省市级', '地区级', '县级'));
$this->assign('search',I('get.'));
$where['is_del'] = 0;
if(I('get.product')){
$where['sort_path'] = array('like','0-'.I('get.product').'%');
}
if(I('get.product_son')){
$where['sort_id'] = I('get.product_son');
}
if(I('get.sex')){
$where['sex'] = I('get.sex');
}
if(I('get.level')){
$where['level'] = I('get.level');
}
if(I('get.region')){
$where['region'] = I('get.region');
}
if(I('get.nation')){
$where['nation'] = I('get.nation');
}
$this->searchArray(I('get.'));
$this->_lists($where);
$this->display();
}
// 处理搜索条件数据
private function searchArray($get) {
// 各筛选条件url处理
// 一级分类
$url['product_all'] = $get;
unset($url['product_all']['product']);
unset($url['product_all']['product_son']);
$url['product_search'] = $get;
unset($url['product_search']['product']);
// 二级分类
$url['son_all'] = $get;
unset($url['son_all']['product_son']);
$url['son_search'] = $get;
unset($url['son_search']['product_son']);
// 性别
$url['sex_all'] = $get;
unset($url['sex_all']['sex']);
$url['sex_search'] = $get;
unset($url['sex_search']['sex']);
// 级别
$url['level_all'] = $get;
unset($url['level_all']['level']);
$url['level_search'] = $get;
unset($url['level_search']['level']);
// 区域
$url['region_all'] = $get;
unset($url['region_all']['region']);
$url['region_search'] = $get;
unset($url['region_search']['region']);
// 民族
$url['nation_all'] = $get;
unset($url['nation_all']['nation']);
$url['nation_search'] = $get;
unset($url['nation_search']['nation']);
$this->assign('search_url',$url);
return $url;
}
// 传承人详情
public function detail(){
$id = I('get.id',0,'intval');
if(!$id) {
$this->error('参数错误');
}
$productList = $this->successor_produce_model->getAllList($id);
$info = $this->successor_model->getInfo($id);
$this->assign($info);
$this->assign('productList',$productList);
$this->display();
}
/**
* 地方非遗列表处理方法,根据不同条件显示不同的列表
* @param array $where 查询条件
*/
private function _lists($where=array()){
$where['is_del'] = 0;
$this->successor_model
->where($where);
$count = $this->successor_model->count();
$page = $this->pages($count, 9);
$posts = $this->successor_model
->where($where)
->limit($page->firstRow , $page->listRows)
->order("ctime DESC")
->select();
$this->assign("page", $page->show('new'));
$this->assign("posts",$posts);
}
}