后台代码格式化,内核更新

This commit is contained in:
2016-08-29 16:51:13 +08:00
parent 1710eb742c
commit dff622f0ac
21 changed files with 842 additions and 838 deletions

View File

@@ -10,26 +10,26 @@
namespace app\admin\controller;
use app\common\controller\Admin;
class Channel extends Admin{
class Channel extends Admin {
public function _initialize(){
public function _initialize() {
parent::_initialize();
}
public function index(){
public function index() {
$pid = input('pid', 0);
/* 获取频道列表 */
//$map = array('status' => array('gt', -1), 'pid'=>$pid);
$map = array('status' => array('gt', -1));
$list = db('Channel')->where($map)->order('sort asc,id asc')->column('*','id');
$map = array('status' => array('gt', -1));
$list = db('Channel')->where($map)->order('sort asc,id asc')->column('*', 'id');
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
if (!empty($list)) {
$tree = new \com\Tree();
$list = $tree->toFormatTree($list);
}
config('_sys_get_channel_tree_', true);
$this->assign('tree', $list);
$this->assign('pid', $pid);
$this->setMeta('导航管理');
@@ -50,7 +50,7 @@ class Channel extends Admin{
public function add() {
if (IS_POST) {
$Channel = model('Channel');
$data = $this->request->post();
$data = $this->request->post();
if ($data) {
$id = $Channel->save($data);
if ($id) {
@@ -70,7 +70,7 @@ class Channel extends Admin{
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
$this->assign('parent', $parent);
}
$pnav = db('Channel')->where(array('pid' => '0'))->select();
$this->assign('pnav', $pnav);
$this->assign('pid', $pid);
@@ -86,9 +86,9 @@ class Channel extends Admin{
public function edit($id = 0) {
if (IS_POST) {
$Channel = model('Channel');
$data = $this->request->post();
$data = $this->request->post();
if ($data) {
if (false !== $Channel->save($data,array('id'=>$data['id']))) {
if (false !== $Channel->save($data, array('id' => $data['id']))) {
//记录行为
action_log('update_channel', 'channel', $data['id'], session('user_auth.uid'));
return $this->success('编辑成功', url('index'));
@@ -102,18 +102,18 @@ class Channel extends Admin{
$info = array();
/* 获取数据 */
$info = db('Channel')->find($id);
if (false === $info) {
return $this->error('获取配置信息错误');
}
$pid = input('pid', 0);
//获取父导航
if (!empty($pid)) {
$parent = db('Channel')->where(array('id' => $pid))->field('title')->find();
$this->assign('parent', $parent);
}
$pnav = db('Channel')->where(array('pid' => '0'))->select();
$this->assign('pnav', $pnav);
$this->assign('pid', $pid);
@@ -128,11 +128,11 @@ class Channel extends Admin{
*/
public function del() {
$id = $this->getArrayParam('id');
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map = array('id' => array('in', $id));
if (db('Channel')->where($map)->delete()) {
//记录行为
@@ -160,7 +160,7 @@ class Channel extends Admin{
}
}
$list = db('Channel')->where($map)->field('id,title')->order('sort asc,id asc')->select();
$this->assign('list', $list);
$this->setMeta('导航排序');
return $this->fetch();
@@ -171,7 +171,7 @@ class Channel extends Admin{
$res = db('Channel')->where(array('id' => $value))->setField('sort', $key + 1);
}
if ($res !== false) {
return $this->success('排序成功!',url('admin/channel/index'));
return $this->success('排序成功!', url('admin/channel/index'));
} else {
return $this->error('排序失败!');
}
@@ -180,19 +180,19 @@ class Channel extends Admin{
}
}
public function setStatus(){
$id = array_unique((array)input('ids', 0));
$status = input('status','0','trim');
public function setStatus() {
$id = array_unique((array) input('ids', 0));
$status = input('status', '0', 'trim');
if (empty($id)) {
return $this->error('请选择要操作的数据!');
}
$map = array('id' => array('in', $id));
$result = db('Channel')->where($map)->update(array('status'=>$status));
$map = array('id' => array('in', $id));
$result = db('Channel')->where($map)->update(array('status' => $status));
if ($result) {
return $this->success("操作成功!");
}else{
} else {
return $this->error("操作失败!");
}
}