内容模型功能完成

This commit is contained in:
2020-04-01 22:20:11 +08:00
parent 85d33da0d4
commit 9dafceb2eb
32 changed files with 415 additions and 339 deletions
+14 -21
View File
@@ -145,11 +145,7 @@ class Category extends Base {
if (!$child->isEmpty()) {
return $this->error('请先删除该分类下的子分类');
}
//判断该分类下有没有内容
// $document_list = db('Document')->where(array('category_id' => $id))->field('id')->select();
// if (!empty($document_list)) {
// return $this->error('请先删除该分类下的文章(包含回收站)');
// }
//删除该分类信息
$result = CategoryM::where('id', $id)->delete();
if ($result !== false) {
@@ -160,11 +156,13 @@ class Category extends Base {
}
/**
* 操作分类初始化
* 移动/合并分类
* @param string $type
* @author huajie <banhuajie@163.com>
*/
public function operate($type = 'move', $from = '') {
$map = [];
$map[] = ['status', '=', 1];
//检查操作参数
if ($type == 'move') {
$operate = '移动';
@@ -176,24 +174,19 @@ class Category extends Base {
if (empty($from)) {
return $this->error('参数错误!');
}else{
$map[] = ['id', '<>', $from];
}
//获取分类
$map = array('status' => 1, 'id' => array('neq', $from));
$list = db('Category')->where($map)->field('id,pid,title')->select();
//移动分类时增加移至根分类
if ($type == 'move') {
//不允许移动至其子孙分类
$list = tree_to_list(list_to_tree($list));
$list = CategoryM::where($map)->field('id,pid,title')->select();
$pid = db('Category')->getFieldById($from, 'pid');
$pid && array_unshift($list, array('id' => 0, 'title' => '根分类'));
}
$this->assign('type', $type);
$this->assign('operate', $operate);
$this->assign('from', $from);
$this->assign('list', $list);
$this->setMeta($operate . '分类');
$this->data = [
'type' => $type,
'operate' => $operate,
'from' => $from,
'list' => $list
];
return $this->fetch();
}