AdminAboutusController.php
2.6 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
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <bronet@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\ArtModel;
use app\portal\model\BannerModel;
use cmf\controller\AdminBaseController;
use think\Db;
use think\Loader;
class AdminAboutusController extends AdminBaseController
{
/**
* 关于我们
* @adminMenu(
* 'name' => '关于我们',
* 'parent' => 'portal/AdminArt/default',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '关于我们',
* 'param' => ''
* )
*/
public function view()
{
$where_find['type'] = 3;
$where_find['status'] = array('neq',9);
$list = Db::name('Art')->where($where_find)->find();
if($list){
$list['content'] = htmlspecialchars_decode($list['content']);
$list['pic'] = cmf_get_image_url($list['pic']);
}
$this->assign('list',$list);
return $this->fetch();
}
/**
* 编辑文章
* @adminMenu(
* 'name' => '编辑文章',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '编辑文章',
* 'param' => ''
* )
*/
public function edit()
{
// 添加数据
$data = $this->request->post();
$change_add['title'] = $data['title'];
$change_add['type'] = 3;
$change_add['content'] = $data['content'];
if(!empty($data['pic'])){
$change_add['pic'] = $data['pic'];
}
$validate = Loader::validate('Art');
if(!$validate->scene('edit')->check($change_add)){
$mes = $validate->getError();
$this->error("$mes");
}
$change_add['id'] = $data['id'];
$model = new ArtModel();
$final = $model->isUpdate(true)->save($change_add);
if($final){
$this->success('成功');
}else{
$this->error('失败');
}
}
}