You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.9 KiB
PHTML

5 years ago
<?php
namespace Admin\Controller;
use Admin\Model\AuthGroupModel;
class SelfbuiltController extends ThinkController {
private $model_name = 'Selfbuilt';
public function _initialize(){
parent::_initialize();
$menu = parent::getmenus();
foreach($menu['main'] as $key => $value){
$menu['main'][$key]['url'] = 'Admin/'.$value['url'];
if(strstr($value['url'],MODEL_NAME.CONTROLLER_NAME)){
$menu['main'][$key]['class'] = 'current';
}
}
$this->assign('__MENU__', $menu);
}
/*自建官网*/
public function index(){
$this->m_title = '自建官网';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Selfbuilt/index','status'=>1])->find());
parent::lists($this->model_name,$_GET["p"]);
}
/*添加游戏*/
public function add(){
if(IS_POST){
$tem=M("Selfbuilt");
if(empty(I('gameid')))$this->error("请选择游戏");
$game=$tem->where("gameid=".I('gameid'))->find();
if($game==null){
if($tem->create()&&$tem->add()){
$this->success("添加成功",U('index'));
}
}else{
$this->error("游戏已存在",U('index'));
}
}
else{
$this->assign("template",templatelist());
$this->assign("gamelist",get_game_list());
$this->meta_title = '新增自建官网';
$this->m_title = '自建官网';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Selfbuilt/index','status'=>1])->find());
$this->display();
}
}
/*编辑游戏*/
public function edit(){
if(IS_POST){
$map['id']=$_POST['id'];
$save=M('Selfbuilt')->where($map)->save($_POST);
if($save){
$this->success('编辑成功',U('index'));
}else{
$this->error('编辑失败',U('index'));
}
}else{
$this->assign("gamelist",get_game_list());
$this->assign("template",templatelist());
$map['id']=I('model');
$data=M('Selfbuilt')->where($map)->find();
$this->assign('data',$data);
$this->meta_title = '编辑自建官网';
$this->m_title = '自建官网';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Selfbuilt/index','status'=>1])->find());
$this->display();
}
}
/*删除数据*/
public function del($ids=0){
$model = M('Model')->getByName("Selfbuilt");
$model || $this->error('模型不存在!');
$ids = array_unique((array)I('ids',0));
if ( empty($ids) ) {
$this->error('请选择要操作的数据!');
}
$Model = M(get_table_name($model['id']));
$map = array('id' => array('in', $ids) );
if($Model->where($map)->delete()){
$this->success('删除成功',U('index'));
} else {
$this->error('删除失败!');
}
}
public function getgame_nme()
{
$map['id']=$_POST['gameid'];
$game=D("Game")->where($map)->find();
echo json_encode(array("data"=>$game['game_name']));
}
}
?>