You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
4.9 KiB
145 lines
4.9 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: rainfer <81818832@qq.com>
|
|
// +----------------------------------------------------------------------
|
|
namespace app\admin\controller;
|
|
|
|
use think\Db;
|
|
|
|
class Culture extends Base
|
|
{
|
|
/**
|
|
* 栏目列表
|
|
*/
|
|
public function culture_list()
|
|
{
|
|
$cu_cid=input('cid',0,'intval');
|
|
$cultures=Db::name('culture')->where('cu_cid',$cu_cid)->order('cu_time desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
$show = $cultures->render();
|
|
$show=preg_replace("(<a[^>]*page[=|/](\d+).+?>(.+?)<\/a>)","<a href='javascript:ajax_page($1);'>$2</a>",$show);
|
|
$this->assign('cu_cid',$cu_cid);
|
|
$this->assign('cultures',$cultures);
|
|
$this->assign('page',$show);
|
|
if(request()->isAjax()){
|
|
return $this->fetch('ajax_culture_list');
|
|
}else{
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
/**
|
|
* 添加显示
|
|
*/
|
|
public function culture_add()
|
|
{
|
|
$cu_cid=input('cid',0,'intval');
|
|
if (!request()->isAjax()){
|
|
$this->assign('cu_cid',$cu_cid);
|
|
return $this->fetch();
|
|
}else{
|
|
$sl_data=array(
|
|
'cu_dw'=>htmlspecialchars_decode(input('cu_dw')),
|
|
'cu_status'=>input('cu_status',0),
|
|
'cu_uid'=>session('admin_auth.aid'),
|
|
'cu_time'=>time(),
|
|
'cu_dy'=>htmlspecialchars_decode(input('cu_dy')),
|
|
'cu_fw'=>htmlspecialchars_decode(input('cu_fw')),
|
|
'cu_cid'=>$cu_cid
|
|
);
|
|
$rst=Db::name('culture')->insert($sl_data);
|
|
if($rst){
|
|
$this->success('添加成功',url('admin/Culture/culture_list',['cid'=>$cu_cid]));
|
|
}else{
|
|
$this->error('添加失败',url('admin/Culture/culture_list',['cid'=>$cu_cid]));
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* 编辑显示
|
|
*/
|
|
public function culture_edit()
|
|
{
|
|
$cu_cid=input('cid',0,'intval');
|
|
if (!request()->isAjax()) {
|
|
$d_id = input('cu_id');
|
|
if (empty($d_id)) {
|
|
$this->error('参数错误', url('admin/Culture/culture_list',['cid'=>$cu_cid]));
|
|
}
|
|
$culture_list = Db::name('culture')->find($d_id);
|
|
$this->assign('culture_list', $culture_list);
|
|
$this->assign('cu_cid',$cu_cid);
|
|
return $this->fetch();
|
|
}else{
|
|
$sl_data=array(
|
|
'cu_id'=>input('cu_id'),
|
|
'cu_dw'=>htmlspecialchars_decode(input('cu_dw')),
|
|
'cu_status'=>input('cu_status',0),
|
|
'cu_dy'=>htmlspecialchars_decode(input('cu_dy')),
|
|
'cu_fw'=>htmlspecialchars_decode(input('cu_fw'))
|
|
);
|
|
$rst=Db::name('culture')->update($sl_data);
|
|
if($rst!==false){
|
|
$this->success('修改成功',url('admin/Culture/culture_list',['cid'=>$cu_cid]));
|
|
}else{
|
|
$this->error('修改失败',url('admin/Culture/culture_list',['cid'=>$cu_cid]));
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* 删除(单个)
|
|
*/
|
|
public function culture_del()
|
|
{
|
|
$cu_cid=input('cid',0,'intval');
|
|
$p=input('p');
|
|
$rst=Db::name('culture')->delete(input('cu_id'));
|
|
if($rst!==false){
|
|
$this->success('删除成功',url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
|
|
}else{
|
|
$this -> error("删除失败!",url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
|
|
}
|
|
}
|
|
/**
|
|
* 删除(全选)
|
|
*/
|
|
public function culture_alldel()
|
|
{
|
|
$p = input('p');
|
|
$ids = input('cu_id/a');
|
|
$cu_cid=input('cid',0,'intval');
|
|
if(empty($ids)){
|
|
$this -> error("请选择待删除数据",url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
|
|
}
|
|
if(is_array($ids)){
|
|
$where = 'cu_id in('.implode(',',$ids).')';
|
|
}else{
|
|
$where = 'cu_id='.$ids;
|
|
}
|
|
$rst=Db::name('culture')->where($where)->delete();
|
|
if($rst!==false){
|
|
$this->success("删除成功",url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
|
|
}else{
|
|
$this -> error("删除失败!",url('admin/Culture/culture_list',array('p'=>$p,'cid'=>$cu_cid)));
|
|
}
|
|
}
|
|
/**
|
|
* 审核/取消审核
|
|
*/
|
|
public function culture_state()
|
|
{
|
|
$id=input('x');
|
|
$status=Db::name('culture')->where(array('cu_id'=>$id))->value('cu_status');
|
|
if($status==1){
|
|
$statedata = array('cu_status'=>0);
|
|
Db::name('culture')->where(array('cu_id'=>$id))->setField($statedata);
|
|
$this->success('未审');
|
|
}else{
|
|
$statedata = array('cu_status'=>1);
|
|
Db::name('culture')->where(array('cu_id'=>$id))->setField($statedata);
|
|
$this->success('已审');
|
|
}
|
|
}
|
|
}
|