EmptyController.php
5.48 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
<?php
namespace app\home\controller;
use think\Db;
use think\facade\Env;
class EmptyController extends Common{
protected $dao,$fields;
public function initialize()
{
parent::initialize();
$this->dao = Db::name(DBNAME);
}
public function index(){
$time = time();
if(DBNAME=='page'){
$info = Db::name(DBNAME)->where(['id'=>input('catId')])->find();
$this->assign('info',$info);
if($info['template']){
$template = $info['template'];
}else{
$info['template'] = Db::name('category')->where(['id'=>$info['id']])->value('template_show');
if($info['template']){
$template = $info['template'];
}else{
$template = DBNAME.'_show';
}
}
return $this->fetch($template);
}else{
if(DBNAME=='picture'){
$setup = Db::name('field')->where([['moduleid','eq',3],['field','eq','group']])->value('setup');
$setup=is_array($setup) ? $setup: string2array($setup);
$options = explode("\n",$setup['options']);
foreach($options as $r) {
$v = explode("|",$r);
$k = trim($v[1]);
$optionsarr[$k]['val'] = $v[0];
$optionsarr[$k]['key'] = $k;
}
$this->assign('options',$optionsarr);
}
//下载页面
if(DBNAME=='downapp'){
//手机
$Mobile = db('android')->where(array('flag'=>1))->order('version desc')->limit(1)->select();
//ipad
$IPad = db('android')->where(array('flag'=>2))->order('version desc')->limit(1)->select();
$Mobile=is_array($Mobile) ? $Mobile: NULL;
$IPad=is_array($IPad) ? $IPad: NULL;
$link = array($Mobile[0]['file_url'],$IPad[0]['file_url']);
$this->assign('link',$link);
}
$arrchildid = db('category')->where(['id'=>input('catId')])->value('arrchildid');
$map = ' ';
if($arrchildid!=input('catId')){
$map .= 'catid in ($arrchildid)';
}else{
$map .= 'catid = '.input("catId");
}
$map .= ' and (status = 1 or (status = 0 and createtime <'.time().'))';
if(DBNAME=='team'){
$donation = Db::name('donation')->order('id desc')->paginate($this->pagesize);
$dpage = $donation->render();
$dlist = $donation->toArray();
$this->assign('dlist',$dlist['data']);
$this->assign('dpage',$dpage);
$list = $this->dao->where($map)->order('sort asc,createtime desc')->select();
foreach ($list as $k=>$v){
$list_style = explode(';',$v['title_style']);
$list[$k]['title_color'] =$list_style[0];
$list[$k]['title_weight'] =$list_style[1];
$title_thumb = $v['thumb'];
$list[$k]['title_thumb'] = $title_thumb?$title_thumb:'/static/home/images/portfolio-thumb/p'.($k+1).'.jpg';
}
$this->assign('list',$list);
}else{
$list=$this->dao->alias('a')
->join(config('database.prefix').'category c','a.catid = c.id','left')
->where($map)
->field('a.*,c.catdir')
->order('sort asc,createtime desc')
->paginate($this->pagesize);
// 获取分页显示
$page = $list->render();
$list = $list->toArray();
foreach ($list['data'] as $k=>$v){
$list['data'][$k]['controller'] = $v['catdir'];
if(isset($v['thumb'])){
$list['data'][$k]['title_thumb'] =imgUrl($v['thumb'],'/static/home/images/portfolio-thumb/p'.($k+1).'.jpg');
}else{
$list['data'][$k]['title_thumb'] ='/static/home/images/portfolio-thumb/p'.($k+1).'.jpg';
}
}
$this->assign('list',$list['data']);
$this->assign('page',$page);
}
$cattemplate = db('category')->where('id',input('catId'))->value('template_list');
$template =$cattemplate ? $cattemplate : DBNAME.'_list';
return $this->fetch($template);
}
}
public function info(){
Db::name(DBNAME)->where('id',input('id'))->setInc('hits');
$info = Db::name(DBNAME)->where('id',input('id'))->find();
$info['pic'] = isset($info['pic'])?$info['pic']:"/static/home/images/sample-images/blog-post".rand(1,3).".jpg";
$title_thumb = $info['thumb'];
$info['title_thumb'] = $title_thumb?$title_thumb:'/static/home/images/sample-images/blog-post'.rand(1,3).'.jpg';
$this->assign('info',$info);
if($info['template']){
$template = $info['template'];
}else{
$cattemplate = Db::name('category')->where('id',$info['catid'])->value('template_show');
if($cattemplate){
$template = $cattemplate;
}else{
$template = DBNAME.'_show';
}
}
return $this->fetch($template);
}
public function down($id=''){
$map['id'] = $id;
$files = Db::name('download')->where($map)->find();
return download(Env::get('root_path').'public'.$files['files'], $files['title']);
}
}