-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathcategory.app.php
executable file
·97 lines (93 loc) · 3.91 KB
/
category.app.php
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
<?php
/*
* This file is part of the phpems/phpems.
*
* (c) oiuv <[email protected]>
*
* 项目维护:oiuv(QQ:7300637) | 定制服务:火眼(QQ:278768688)
*
* This source file is subject to the MIT license that is bundled.
*/
class action extends app
{
public function display()
{
$action = $this->ev->url(3);
if (!method_exists($this, $action)) {
$action = 'index';
}
$this->$action();
exit;
}
private function needmore()
{
$page = $this->ev->get('page');
$catid = intval($this->ev->get('catid'));
if ($catid) {
$cat = $this->category->getCategoryById($catid);
}
$catbread = $this->category->getCategoryPos($catid);
if ($cat) {
if ($cat['catuseurl'] && $cat['caturl']) {
header('location:'.html_entity_decode($cat['caturl']));
}
if ($cat['catparent']) {
$catparent = $this->category->getCategoryById($cat['catparent']);
}
$catstring = $this->category->getChildCategoryString($catid);
if ($cat['cattpl']) {
$template = $cat['cattpl'];
} else {
$template = 'category_default';
}
$this->tpl->assign('cat', $cat);
$this->tpl->assign('catparent', $catparent);
$this->tpl->assign('catbread', $catbread);
}
$args = [];
$args[] = ['AND', 'docneedmore = 1'];
if ($catid) {
$args[] = ['AND', 'find_in_set(doccatid,:doccatid)', 'doccatid', $catstring];
}
$catchildren = $this->category->getCategoriesByArgs([['AND', 'catparent = :catparent', 'catparent', $catid], ['AND', "catinmenu = '0'"], ['AND', "catapp = 'docs'"]]);
$catbrother = $this->category->getCategoriesByArgs([['AND', 'catparent = :catparent', 'catparent', intval($cat['catparent'])], ['AND', "catinmenu = '0'"], ['AND', "catapp = 'docs'"]]);
$docs = $this->doc->getDocList($args, $page);
$this->tpl->assign('catbrother', $catbrother);
$this->tpl->assign('catchildren', $catchildren);
$this->tpl->assign('categories', $this->category->categories);
$this->tpl->assign('page', $page);
$this->tpl->assign('docs', $docs);
$this->tpl->display('needmore');
}
private function index()
{
$page = $this->ev->get('page');
$catid = $this->ev->get('catid');
$cat = $this->category->getCategoryById($catid);
if ($cat['catuseurl'] && $cat['caturl']) {
header('location:'.html_entity_decode($cat['caturl']));
}
if ($cat['catparent']) {
$catparent = $this->category->getCategoryById($cat['catparent']);
}
$catbread = $this->category->getCategoryPos($catid);
$catstring = $this->category->getChildCategoryString($catid);
$catchildren = $this->category->getCategoriesByArgs([['AND', 'catparent = :catparent', 'catparent', $catid], ['AND', "catinmenu = '0'"], ['AND', "catapp = 'docs'"]]);
$docs = $this->doc->getDocList([['AND', 'find_in_set(doccatid,:doccatid)', 'doccatid', $catstring]], $page);
$catbrother = $this->category->getCategoriesByArgs([['AND', 'catparent = :catparent', 'catparent', $cat['catparent']], ['AND', "catinmenu = '0'"], ['AND', "catapp = 'docs'"]]);
if ($cat['cattpl']) {
$template = $cat['cattpl'];
} else {
$template = 'category_default';
}
$this->tpl->assign('cat', $cat);
$this->tpl->assign('page', $page);
$this->tpl->assign('categories', $this->category->categories);
$this->tpl->assign('catbrother', $catbrother);
$this->tpl->assign('catchildren', $catchildren);
$this->tpl->assign('catparent', $catparent);
$this->tpl->assign('catbread', $catbread);
$this->tpl->assign('docs', $docs);
$this->tpl->display($template);
}
}