commit | author | age
|
1c88ba
|
1 |
<?php |
Z |
2 |
/** |
|
3 |
* 微课堂搜索页 |
|
4 |
* ============================================================================ |
3e6546
|
5 |
* 版权所有 2015-2020 ,并保留所有权利。 |
Z |
6 |
* 网站地址: |
1c88ba
|
7 |
* ---------------------------------------------------------------------------- |
3e6546
|
8 |
|
1c88ba
|
9 |
* ============================================================================ |
Z |
10 |
*/ |
|
11 |
|
|
12 |
if((!$userAgent && in_array('search', $login_visit)) || ($userAgent && !$comsetting['hidden_login'])){ |
|
13 |
checkauth(); |
|
14 |
} |
|
15 |
|
|
16 |
$systemType = $site_common->checkSystenType(); /* 手机操作系统 */ |
|
17 |
$site_common->check_black_list('visit', $_W['member']['uid']); |
|
18 |
|
|
19 |
/* 自定义字体 */ |
|
20 |
$index_page = $common['index_page']; |
|
21 |
$already_study = $common['index_page']['studyNum'] ? $common['index_page']['studyNum'] : '人已学习'; |
|
22 |
|
|
23 |
/* 全部分类图标 */ |
|
24 |
$all_category_ico = $setting['category_ico'] ? $_W['attachurl'].$setting['category_ico'] : MODULE_URL."template/mobile/{$template}/images/ico-allcategory.png"; |
|
25 |
|
|
26 |
$pindex = max(1, intval($_GPC['page'])); |
|
27 |
$psize = 10; |
|
28 |
|
|
29 |
/* 全部分类 */ |
|
30 |
$hot_category = pdo_fetchall("SELECT * FROM " . tablename($this -> table_category) . " WHERE uniacid=:uniacid AND is_hot=:is_hot AND search_show=:search_show ORDER BY displayorder DESC", array(':uniacid' => $uniacid, ':is_hot' => 1,':search_show'=>1)); |
|
31 |
$categorylist = pdo_fetchall("SELECT * FROM " . tablename($this -> table_category) . " WHERE uniacid=:uniacid AND parentid=:parentid AND search_show=:search_show ORDER BY displayorder DESC", array(':uniacid'=>$uniacid, ':parentid'=>0,':search_show'=>1)); |
|
32 |
|
|
33 |
foreach ($categorylist as $k => $v) { |
|
34 |
$categorylist[$k]['child'] = pdo_fetchall("SELECT * FROM " . tablename($this -> table_category) . " WHERE uniacid=:uniacid AND parentid=:parentid AND search_show=:search_show ORDER BY displayorder DESC", array(':uniacid'=>$uniacid, ':parentid'=>$v['id'],':search_show'=>1)); |
|
35 |
} |
89c2b9
|
36 |
|
ec46c1
|
37 |
/* 知识点分类 */ |
89c2b9
|
38 |
if($_GPC['cat_id'] > 0){ |
Z |
39 |
$hot_knowledge = pdo_fetchall("SELECT * FROM " . tablename("fy_lesson_knowledge_point") . " WHERE uniacid=:uniacid AND is_hot=:is_hot AND search_show=:search_show AND catalog_id_2=:catalog_id_2 ORDER BY displayorder DESC", array(':uniacid' => $uniacid, ':is_hot' => 1,':search_show'=>1,'catalog_id_2'=>$_GPC['cat_id'])); |
|
40 |
$knowledgelist = pdo_fetchall("SELECT * FROM " . tablename("fy_lesson_knowledge_point") . " WHERE uniacid=:uniacid AND parentid=:parentid AND search_show=:search_show AND catalog_id_2=:catalog_id_2 ORDER BY displayorder DESC", array(':uniacid'=>$uniacid, ':parentid'=>0,':search_show'=>1,'catalog_id_2'=>$_GPC['cat_id'])); |
|
41 |
}else{ |
|
42 |
$hot_knowledge = pdo_fetchall("SELECT * FROM " . tablename("fy_lesson_knowledge_point") . " WHERE uniacid=:uniacid AND is_hot=:is_hot AND search_show=:search_show ORDER BY displayorder DESC", array(':uniacid' => $uniacid, ':is_hot' => 1,':search_show'=>1)); |
|
43 |
$knowledgelist = pdo_fetchall("SELECT * FROM " . tablename("fy_lesson_knowledge_point") . " WHERE uniacid=:uniacid AND parentid=:parentid AND search_show=:search_show ORDER BY displayorder DESC", array(':uniacid'=>$uniacid, ':parentid'=>0,':search_show'=>1)); |
|
44 |
} |
ec46c1
|
45 |
|
Z |
46 |
foreach ($knowledgelist as $k => $v) { |
80527f
|
47 |
$knowledgelist[$k]['child'] = pdo_fetchall("SELECT * FROM " . tablename("fy_lesson_knowledge_point") . " WHERE uniacid=:uniacid AND parentid=:parentid AND search_show=:search_show ORDER BY displayorder DESC", array(':uniacid'=>$uniacid, ':parentid'=>$v['id'],':search_show'=>1)); |
ec46c1
|
48 |
} |
Z |
49 |
|
1c88ba
|
50 |
if ($op == 'display') { |
ea7879
|
51 |
$searchtype = $_GPC['searchtype']; |
1c88ba
|
52 |
$keyword = trim($_GPC['keyword']); |
Z |
53 |
$pid = $_GPC['pid']; |
|
54 |
$cat_id = $_GPC['cat_id']; |
|
55 |
$sort = trim($_GPC['sort']); |
|
56 |
$attr1 = $_GPC['attr1']; |
|
57 |
$attr2 = $_GPC['attr2']; |
80527f
|
58 |
$know_id = $_GPC['knowledge_id']; |
1c88ba
|
59 |
|
Z |
60 |
$condition = " a.uniacid = '{$uniacid}' AND a.status=1 "; |
|
61 |
$order = " ORDER BY a.displayorder DESC, a.id DESC "; |
|
62 |
|
|
63 |
if (!empty($keyword)) { |
|
64 |
$condition .= " AND (a.bookname LIKE '%{$keyword}%' OR b.teacher LIKE '%{$keyword}%') "; |
|
65 |
} |
|
66 |
if ($cat_id > 0) { |
|
67 |
$condition .= " AND (a.pid='{$cat_id}' OR a.cid='{$cat_id}')"; |
|
68 |
$nowcat = pdo_fetch("SELECT name FROM " . tablename($this -> table_category) . " WHERE uniacid='{$uniacid}' AND id='{$cat_id}'"); |
|
69 |
$catname = $nowcat['name']; |
|
70 |
} else { |
|
71 |
$catname = $common['page_title']['search'] ? $common['page_title']['search'] : '全部分类'; |
|
72 |
} |
|
73 |
|
80527f
|
74 |
/* 按知识点搜索 */ |
Z |
75 |
if ($know_id > 0) { |
|
76 |
$condition .= " AND (a.knowledge_pid='{$know_id}' OR a.knowledge_id='{$know_id}')"; |
|
77 |
$nowknow = pdo_fetch("SELECT name FROM " . tablename("fy_lesson_knowledge_point") . " WHERE uniacid='{$uniacid}' AND id='{$know_id}'"); |
|
78 |
$knowledgename = $nowknow['name']; |
|
79 |
} else { |
|
80 |
$knowledgename = $common['page_title']['search'] ? $common['page_title']['search'] : '知识点'; |
|
81 |
} |
|
82 |
|
1c88ba
|
83 |
/* 综合排序 */ |
Z |
84 |
if ($sort == 'general') { |
|
85 |
$condition .= " AND a.lesson_type=0"; |
|
86 |
$sortname = '普通课程'; |
|
87 |
} elseif ($sort == 'apply') { |
|
88 |
$condition .= " AND a.lesson_type=1"; |
|
89 |
$sortname = '报名课程'; |
|
90 |
} elseif ($sort == 'live') { |
|
91 |
$condition .= " AND a.lesson_type=3"; |
|
92 |
$sortname = '直播课程'; |
80527f
|
93 |
} elseif ($sort == 'knowledge') { |
Z |
94 |
$condition .= " AND a.lesson_type=5"; |
|
95 |
$sortname = '知识点课'; |
1c88ba
|
96 |
} elseif ($sort == 'price') { |
Z |
97 |
$order = " ORDER BY a.price ASC, a.displayorder DESC "; |
|
98 |
$sortname = '价格优先'; |
|
99 |
} elseif ($sort == 'price') { |
|
100 |
$order = " ORDER BY a.price ASC, a.displayorder DESC "; |
|
101 |
$sortname = '价格优先'; |
|
102 |
} elseif ($sort == 'hot') { |
|
103 |
$order = " ORDER BY (a.buynum+a.virtual_buynum) DESC, a.displayorder DESC "; |
|
104 |
$sortname = '人气优先'; |
|
105 |
} elseif ($sort == 'score') { |
|
106 |
$order = " ORDER BY a.score DESC, a.displayorder DESC "; |
|
107 |
$sortname = '好评优先'; |
|
108 |
} else { |
|
109 |
$sortname = '综合排序'; |
|
110 |
} |
|
111 |
|
|
112 |
/* 课程属性 */ |
|
113 |
$lesson_attribute = $common['lesson_attribute']; |
|
114 |
$attribute1 = pdo_fetchall("SELECT * FROM " .tablename($this->table_attribute). " WHERE uniacid=:uniacid AND attr_type=:attr_type ORDER BY displayorder DESC", array(':uniacid'=>$uniacid,':attr_type'=>'attribute1')); |
|
115 |
$attribute2 = pdo_fetchall("SELECT * FROM " .tablename($this->table_attribute). " WHERE uniacid=:uniacid AND attr_type=:attr_type ORDER BY displayorder DESC", array(':uniacid'=>$uniacid,':attr_type'=>'attribute2')); |
|
116 |
if($attr1){ |
|
117 |
$condition .= " AND attribute1={$attr1}"; |
|
118 |
$now_attr1 = pdo_get($this->table_attribute, array('uniacid'=>$uniacid,'id'=>$attr1), array('name')); |
|
119 |
$attr1_name = $now_attr1['name']; |
|
120 |
}else{ |
|
121 |
$attr1_name = $lesson_attribute['attribute1']; |
|
122 |
} |
|
123 |
if($attr2){ |
|
124 |
$condition .= " AND attribute2={$attr2}"; |
|
125 |
$now_attr2 = pdo_get($this->table_attribute, array('uniacid'=>$uniacid,'id'=>$attr2), array('name')); |
|
126 |
$attr2_name = $now_attr2['name']; |
|
127 |
}else{ |
|
128 |
$attr2_name = $lesson_attribute['attribute2']; |
|
129 |
} |
|
130 |
|
|
131 |
$list = pdo_fetchall("SELECT a.* FROM " . tablename($this -> table_lesson_parent) . " a LEFT JOIN " . tablename($this -> table_teacher) . " b ON a.teacherid=b.id WHERE {$condition} {$order} LIMIT " . ($pindex - 1) * $psize . ',' . $psize); |
|
132 |
foreach ($list as $k=>$v) { |
|
133 |
$v['soncount'] = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this -> table_lesson_son) . " WHERE parentid=:parentid", array(':parentid'=>$v['id'])); |
|
134 |
if($v['price']>0){ |
|
135 |
$v['buyTotal'] = $v['buynum'] + $v['virtual_buynum'] + $v['vip_number'] + $v['teacher_number']; |
|
136 |
}else{ |
|
137 |
$v['buyTotal'] = $v['buynum'] + $v['virtual_buynum'] + $v['visit_number'] + $v['teacher_number'] + $v['vip_number']; |
|
138 |
} |
|
139 |
|
|
140 |
$v['score_rate'] = $v['score'] ? $v['score']*100 : ''; |
|
141 |
$v['score_rate'] = $v['score_rate']>100 ? 100 : $v['score_rate']; |
|
142 |
|
|
143 |
$v['discount'] = $site_common->getLessonDiscount($v['id']); |
|
144 |
$v['price'] = round($v['price']*$v['discount'], 2); |
|
145 |
if($v['discount']<1 && !$v['ico_name']){ |
|
146 |
$v['ico_name'] = 'ico-discount'; |
|
147 |
} |
|
148 |
|
|
149 |
if($v['lesson_type']==3){ |
|
150 |
$live_info = json_decode($v['live_info'], true); |
|
151 |
$starttime = strtotime($live_info['starttime']); |
|
152 |
$endtime = strtotime($live_info['endtime']); |
|
153 |
if(time() < $starttime){ |
|
154 |
$v['icon_live_status'] = 'icon-live-nostart'; |
|
155 |
}elseif(time() > $endtime){ |
|
156 |
$v['icon_live_status'] = 'icon-live-ended'; |
|
157 |
}elseif(time() > $starttime && time() < $endtime){ |
|
158 |
$v['icon_live_status'] = 'icon-live-starting'; |
|
159 |
} |
|
160 |
$v['learned_hide'] = 'hide'; |
|
161 |
unset($v['soncount']); |
|
162 |
} |
|
163 |
|
|
164 |
$list[$k] = $v; |
|
165 |
} |
|
166 |
|
|
167 |
$total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename($this->table_lesson_parent) . " a LEFT JOIN " .tablename($this->table_teacher). " b ON a.teacherid=b.id WHERE {$condition} "); |
|
168 |
|
|
169 |
if (!empty($keyword)) { |
|
170 |
$title = $keyword; |
|
171 |
} else{ |
|
172 |
$title = $catname; |
|
173 |
} |
|
174 |
|
|
175 |
if($_W['isajax']){ |
|
176 |
$this->resultJson($list); |
|
177 |
} |
|
178 |
|
|
179 |
}elseif ($op == 'allcategory') { |
|
180 |
$title = "全部分类"; |
|
181 |
} |
|
182 |
|
|
183 |
include $this->template("../mobile/{$template}/search"); |