RouteController.class.php
2.4 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
<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
class RouteController extends AdminbaseController{
protected $route_model;
public function _initialize() {
parent::_initialize();
$this->route_model = D("Common/Route");
}
// url规则列表
public function index(){
$routes=$this->route_model->order("listorder asc")->select();
sp_get_routes(true);
$this->assign("routes",$routes);
$this->display();
}
// url规则添加
public function add(){
$this->display();
}
// url规则添加提交
public function add_post(){
if(IS_POST){
if ($this->route_model->create()!==false){
if ($this->route_model->add()!==false) {
$this->success("添加成功!", U("route/index"));
} else {
$this->error("添加失败!");
}
} else {
$this->error($this->route_model->getError());
}
}
}
// url规则编辑
public function edit(){
$id=I("get.id",0,'intval');
$route=$this->route_model->where(array('id'=>$id))->find();
$this->assign($route);
$this->display();
}
// url规则编辑提交
public function edit_post(){
if (IS_POST) {
if ($this->route_model->create()!==false) {
if ($this->route_model->save()!==false) {
$this->success("保存成功!", U("route/index"));
} else {
$this->error("保存失败!");
}
} else {
$this->error($this->route_model->getError());
}
}
}
// url规则删除
public function delete(){
$id = I("get.id",0,"intval");
if ($this->route_model->delete($id)!==false) {
$this->success("删除成功!");
} else {
$this->error("删除失败!");
}
}
// url规则禁用
public function ban(){
$id = I("get.id",0,"intval");
$data=array();
$data['status']=0;
$data['id']=$id;
if ($this->route_model->save($data)!==false) {
$this->success("禁用成功!");
} else {
$this->error("禁用失败!");
}
}
// url规则启用
public function open(){
$id = I("get.id",0,"intval");
$data=array();
$data['status']=1;
$data['id']=$id;
if ($this->route_model->save($data)!==false) {
$this->success("启用成功!");
} else {
$this->error("启用失败!");
}
}
// url规则排序
public function listorders() {
$status = parent::_listorders($this->route_model);
if ($status) {
$this->success("排序更新成功!");
} else {
$this->error("排序更新失败!");
}
}
}