Initial commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace Admin\Controller;
|
||||
use Think\Controller;
|
||||
class PagesController extends AdminController{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->table=D("pages");
|
||||
$where["type"]="list";
|
||||
if($this->admin_lang){
|
||||
$where["lang"]=$this->admin_lang;
|
||||
}
|
||||
$this->pagetemplate=M("template")->where($where)->order("template_id desc")->select();
|
||||
}
|
||||
public function index(){
|
||||
if($this->admin_lang){
|
||||
$where["lang"]=$this->admin_lang;
|
||||
}
|
||||
$data=$this->table->where($where)->order('pages_id desc')->select();
|
||||
$this->assign("data",$data);
|
||||
$this->display();
|
||||
}
|
||||
public function add(){
|
||||
if(IS_POST){
|
||||
$data=$this->table->create();
|
||||
if (!$data){//验证
|
||||
$this->error($this->table->getError());
|
||||
}
|
||||
$data[pages_id]=$this->table->add();
|
||||
D("UserLog")->add("add",$this->table->getTableName(),$data[pages_id]);
|
||||
$this->success($data);
|
||||
}else{
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
public function editor(){
|
||||
if(IS_POST){
|
||||
$data=$this->table->create();
|
||||
if (!$data){//验证
|
||||
$this->error($this->table->getError());
|
||||
}
|
||||
$this->table->save($data);
|
||||
D("UserLog")->add("update",$this->table->getTableName(),$data[pages_id]);
|
||||
$this->success($data);
|
||||
|
||||
}else{
|
||||
$pages_id=I("get.pages_id",0,"int");
|
||||
$r=$this->table->find($pages_id);
|
||||
$this->assign("r",$r);
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
//删除页面
|
||||
public function delete(){
|
||||
$pages_id=I("pages_id",0,'intval');
|
||||
$this->table->delete($pages_id);
|
||||
D("UserLog")->add("delete",$this->table->getTableName(),$pages_id);
|
||||
$this->success("删除成功");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user