后台代码格式化,内核更新
This commit is contained in:
@@ -10,17 +10,17 @@
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
class Link extends Admin{
|
||||
class Link extends Admin {
|
||||
|
||||
public function index(){
|
||||
public function index() {
|
||||
$map = array();
|
||||
|
||||
$order = "id desc";
|
||||
$list = db('Link')->where($map)->order($order)->paginate(10);
|
||||
$list = db('Link')->where($map)->order($order)->paginate(10);
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render()
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("友情链接");
|
||||
@@ -28,24 +28,24 @@ class Link extends Admin{
|
||||
}
|
||||
|
||||
//添加
|
||||
public function add(){
|
||||
public function add() {
|
||||
$link = model('Link');
|
||||
if(IS_POST){
|
||||
if (IS_POST) {
|
||||
$data = input('post.');
|
||||
if ($data) {
|
||||
unset($data['id']);
|
||||
$result = $link->save($data);
|
||||
if ($result) {
|
||||
return $this->success("添加成功!",url('Link/index'));
|
||||
}else{
|
||||
return $this->success("添加成功!", url('Link/index'));
|
||||
} else {
|
||||
return $this->error($link->getError());
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return $this->error($link->getError());
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$data = array(
|
||||
'keyList' => $link->keyList
|
||||
'keyList' => $link->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("添加友链");
|
||||
@@ -54,28 +54,28 @@ class Link extends Admin{
|
||||
}
|
||||
|
||||
//修改
|
||||
public function edit(){
|
||||
public function edit() {
|
||||
$link = model('Link');
|
||||
$id = input('id','','trim,intval');
|
||||
if(IS_POST){
|
||||
$id = input('id', '', 'trim,intval');
|
||||
if (IS_POST) {
|
||||
$data = input('post.');
|
||||
if ($data) {
|
||||
$result = $link->save($data,array('id'=>$data['id']));
|
||||
$result = $link->save($data, array('id' => $data['id']));
|
||||
if ($result) {
|
||||
return $this->success("修改成功!",url('Link/index'));
|
||||
}else{
|
||||
return $this->success("修改成功!", url('Link/index'));
|
||||
} else {
|
||||
return $this->error("修改失败!");
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return $this->error($link->getError());
|
||||
}
|
||||
}else{
|
||||
$map = array('id'=>$id);
|
||||
} else {
|
||||
$map = array('id' => $id);
|
||||
$info = db('Link')->where($map)->find();
|
||||
|
||||
$data = array(
|
||||
'keyList' => $link->keyList,
|
||||
'info' => $info
|
||||
'keyList' => $link->keyList,
|
||||
'info' => $info,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑友链");
|
||||
@@ -84,18 +84,18 @@ class Link extends Admin{
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
public function delete() {
|
||||
$id = $this->getArrayParam('id');
|
||||
if (empty($id)) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
$link = db('Link');
|
||||
|
||||
$map = array('id'=>array('IN',$id));
|
||||
$map = array('id' => array('IN', $id));
|
||||
$result = $link->where($map)->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
}else{
|
||||
} else {
|
||||
return $this->error("删除失败!");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user