Initial commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace Member\Controller;
|
||||
use Think\Controller;
|
||||
class TougaoController extends BaseController{
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->modelid=I("modelid",0,"int");
|
||||
$this->table=D("Tougao");
|
||||
//
|
||||
$this->modelform=APP_PATH.'Data/modelTempMember/'.$this->modelid.".php";
|
||||
|
||||
}
|
||||
//首页
|
||||
public function index(){
|
||||
$this->data=M("model")->where("contribute=1 and status=1")->order("sort asc,modelid desc")->select();
|
||||
$this->display();
|
||||
}
|
||||
public function add(){
|
||||
if(IS_POST){
|
||||
if (!$this->table->relation(true)->create()){//验证
|
||||
$this->error($this->table->relation(true)->getError());
|
||||
}
|
||||
$result=$this->table->data_add();
|
||||
if(!$result){
|
||||
$this->error($this->table->getError());
|
||||
}
|
||||
$this->success($result);
|
||||
}else{
|
||||
$this->pubid=make_pubid();
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
public function editor(){
|
||||
if(IS_POST){
|
||||
if (!$this->table->create()){//验证
|
||||
$this->error($this->table->getError());
|
||||
}
|
||||
$result=$this->table->data_editor();
|
||||
if(!$result){
|
||||
$this->error($this->table->getError());
|
||||
}
|
||||
$this->success($data);
|
||||
|
||||
}else{
|
||||
$id=I("get.id",0,"int");
|
||||
$r=$this->table->relation(true)->find($id);
|
||||
if(!$r){$this->error("信息不存在");};
|
||||
//副表数据合并
|
||||
if($r["cms_".$this->modelinfo[table_name]."_data"]){
|
||||
$newdata=array_merge($r,$r["cms_".$this->modelinfo[table_name]."_data"]);
|
||||
unset($newdata["cms_".$this->modelinfo[table_name]."_data"]);
|
||||
$r=$newdata;
|
||||
}
|
||||
//选中分类
|
||||
$this->catid=$r[catid];
|
||||
$this->cat=$this->getCat();
|
||||
//
|
||||
$this->assign("r",$r);
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
//删除
|
||||
public function delete(){
|
||||
$ids=I("ids");
|
||||
$result=$this->table->data_delete($ids);
|
||||
if(!$result){
|
||||
$this->error($this->table->getError());
|
||||
}
|
||||
$this->success("删除成功");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user