diff --git a/app/controller/front/Content.php b/app/controller/front/Content.php index 27a2bc12..e7bcbac0 100644 --- a/app/controller/front/Content.php +++ b/app/controller/front/Content.php @@ -61,6 +61,12 @@ class Content extends Base { $category = Category::where('model_id', $this->modelInfo['id'])->column("*", "id"); + //当前栏目 + $cate = isset($category[$param['id']]) ? $category[$param['id']] : []; + if(empty($cate)){ + return $this->error("当前栏目不能为空或无此栏目!"); + } + $ids = (new \sent\tree\Tree())->getChilds($category, (int) $param['id']); array_push($ids, (int) $param['id']); @@ -71,8 +77,6 @@ class Content extends Base { $list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig); - //当前栏目 - $cate = $category[$param['id']]; if (isset($cate['template_lists']) && $cate['template_lists']) { $teamplate = 'front@content/' . $this->modelInfo['name'] . '/' . $cate['template_lists']; } else { diff --git a/app/model/Action.php b/app/model/Action.php deleted file mode 100644 index c03ac32b..00000000 --- a/app/model/Action.php +++ /dev/null @@ -1,41 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\model; - -/** - * 分类模型 - */ -class Action { - - protected function getStatusTextAttr($value, $data) { - $status = array(-1 => '删除', 0 => '禁用', 1 => '正常', 2 => '待审核'); - return $status[$data['status']]; - } - - public $fieldlist = array( - array('name' => 'id', 'title' => 'ID', 'type' => 'hidden'), - array('name' => 'name', 'title' => '行为标识', 'type' => 'text', 'help' => '输入行为标识 英文字母'), - array('name' => 'title', 'title' => '行为名称', 'type' => 'text', 'help' => '输入行为名称'), - array('name' => 'type', 'title' => '行为类型', 'type' => 'select', 'help' => '选择行为类型', 'option' => ''), - array('name' => 'remark', 'title' => '行为描述', 'type' => 'textarea', 'help' => '输入行为描述'), - array('name' => 'rule', 'title' => '行为规则', 'type' => 'textarea', 'help' => '输入行为规则,不写则只记录日志'), - array('name' => 'log', 'title' => '日志规则', 'type' => 'textarea', 'help' => '记录日志备注时按此规则来生成,支持[变量|函数]。目前变量有:user,time,model,record,data'), - ); - - public function _initialize() { - parent::_initialize(); - foreach ($this->fieldlist as $key => $value) { - if ($value['name'] == 'type') { - $value['option'] = get_action_type(null, true); - } - $this->fieldlist[$key] = $value; - } - } -} \ No newline at end of file diff --git a/app/model/AuthRule.php b/app/model/AuthRule.php index 31d5b564..6b71f7eb 100644 --- a/app/model/AuthRule.php +++ b/app/model/AuthRule.php @@ -25,8 +25,8 @@ class AuthRule extends Model{ public $keyList = [ ['name'=>'module','title'=>'所属模块','type'=>'hidden'], - ['name'=>'title','title'=>'节点名称','type'=>'text','help'=>''], - ['name'=>'name','title'=>'节点标识','type'=>'text','help'=>''], + ['name'=>'title','title'=>'节点名称','type'=>'text', 'is_must'=>true,'help'=>''], + ['name'=>'name','title'=>'节点标识','type'=>'text', 'is_must'=>true,'help'=>''], ['name'=>'group','title'=>'功能组','type'=>'text','help'=>'功能分组'], ['name'=>'status','title'=>'状态','type'=>'select','option'=>[['key' => '0', 'label'=>'禁用'],['key' => '1', 'label'=>'启用']],'help'=>''], ['name'=>'condition','title'=>'条件','type'=>'text','help'=>''] diff --git a/app/model/Channel.php b/app/model/Channel.php index 93e6412d..53995557 100644 --- a/app/model/Channel.php +++ b/app/model/Channel.php @@ -18,22 +18,35 @@ class Channel extends \think\Model { 'id' => 'integer', ); - protected $auto = array('update_time', 'status' => 1); - protected $insert = array('create_time'); + protected function setStatusAttr($value){ + return ($value !== '') ? $value : 1; + } protected function getStatusTextAttr($value, $data){ $status = [0 => '禁用', 1 => '启用']; return isset($status[$data['status']]) ? $status[$data['status']] : '禁用'; } - public static function getChannelList($pid, $tree){ + public static function getChannelList($type, $pid = '', $tree = false){ $map = []; $map[] = ['status', '=', 1]; if ($pid !== '') { $map[] = ['pid', '=', $pid]; } - - $list = self::where($map)->order('sort asc, id desc')->column("*"); + if($type !== ''){ + $map[] = ['type', '=', $type]; + } + $list = self::where($map)->order('sort asc, id desc')->select()->each(function($item){ + if(strpos($item['url'], "?")){ + $url = parse_url($item['url']); + $param = []; + parse_str($url['query'], $param); + $item['url'] = url($url['path'], $param); + }else{ + $item['url'] = url($item['url']); + } + return $item; + })->toArray(); if ($tree) { $list = (new \sent\tree\Tree())->listToTree($list); } diff --git a/app/model/Record.php b/app/model/Record.php deleted file mode 100644 index 361cc301..00000000 --- a/app/model/Record.php +++ /dev/null @@ -1,85 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace app\model; - -/** - * 分类模型 - */ -class Record extends \think\Model { - - protected $type = [ - 'new_data' => 'json', - 'old_data' => 'json', - 'order_num' => 'float' - ]; - - public function getDataList($request) { - $map = []; - $order = "id desc"; - $param = $request->param(); - - if (isset($param['name']) && $param['name'] != '') { - $map[] = ['data_name', 'LIKE', '%' . $param['name'] . '%']; - } - if (isset($param['nickname']) && $param['nickname'] != '') { - $searchUser = db('Member')->where('nickname', $param['nickname'])->field('uid,department')->find(); - if ($searchUser) { - $map[] = ['uid', '=', $searchUser['uid']]; - } - } - if (isset($param['data']) && count($param['data']) == 2 && $param['data'][0] && $param['data'][1]) { - $data = [strtotime($param['data'][0]), strtotime($param['data'][1])]; - $map[] = ['create_time', 'between time', $data]; - } - //数据权限 - if ($request->user['role']['data_auth'] == 1) { - // 部门数据... - $user = Db::name('Member')->field('uid') - ->where('department', $request->user['department']) - ->buildSql(); - $map[] = ["uid", "EXP", "in " . $user]; - } elseif ($request->user['role']['data_auth'] == 2) { - // 个人数据... - $map[] = ['uid', '=', $request->user['uid']]; - } - - $list = self::with(['member'])->where($map) - ->order($order)->paginate($request->pageConfig); - return $list; - } - - /** - * title : 添加记录 - * param : old 旧数据,new 新数据 type 类型 - */ - public function adds($old = array(), $new = array(), $type = 'customer') { - $edit = array(); //修改过的字段 - foreach ($new as $key => $value) { - if (isset($old[$key]) && $value != $old[$key]) { - $edit[] = $key; - } - } - if (!empty($edit)) { - $data['data_id'] = $old['id']; - $data['data_name'] = $old['name']; - $data['type'] = $type; - $data['uid'] = session('user_auth.uid'); - $data['old_data'] = json_encode($old); - $data['new_data'] = json_encode($new); - $data['fields'] = json_encode($edit); - $data['create_time'] = time(); - return $this->insert($data); - } - } - - public function member() { - return $this->hasOne('Member', 'uid', 'uid')->field('uid,username,nickname'); - } -} \ No newline at end of file diff --git a/app/model/Rewrite.php b/app/model/Rewrite.php index aa3a0d4b..fd74ca1c 100644 --- a/app/model/Rewrite.php +++ b/app/model/Rewrite.php @@ -18,8 +18,8 @@ class Rewrite extends \think\Model { public static $keyList = array( array('name' => 'id', 'title' => '标识', 'type' => 'hidden'), - array('name' => 'rule', 'title' => '规则名称', 'type' => 'text', 'option' => '', 'help' => '规则名称,方便记忆'), - array('name' => 'url', 'title' => '规则地址', 'type' => 'text', 'option' => '', 'help' => '规则地址'), + array('name' => 'rule', 'title' => '规则名称', 'type' => 'text', 'is_must'=> true, 'option' => '', 'help' => '规则名称,方便记忆'), + array('name' => 'url', 'title' => '规则地址', 'type' => 'text', 'is_must'=> true, 'option' => '', 'help' => '规则地址'), ); /** diff --git a/app/model/SeoRule.php b/app/model/SeoRule.php index 1ba058ea..49e9f812 100644 --- a/app/model/SeoRule.php +++ b/app/model/SeoRule.php @@ -16,13 +16,13 @@ class SeoRule extends \think\Model { public static $keyList = [ ['name' => 'id', 'title' => '标识', 'type' => 'hidden'], - ['name' => 'title', 'title' => '规则名称', 'type' => 'text', 'option' => '', 'help' => '规则名称,方便记忆'], + ['name' => 'title', 'title' => '规则名称', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '规则名称,方便记忆'], ['name' => 'app', 'title' => '模块名', 'type' => 'select', 'option' => [['key'=>'*', 'label' => '-所有模块-'], ['key'=>'front', 'label' => '前台模块'], ['key'=>'user', 'label' => '用户中心']], 'help' => '不选表示所有模块'], ['name' => 'controller', 'title' => '控制器', 'type' => 'text', 'option' => '', 'help' => '不填表示所有控制器'], ['name' => 'action', 'title' => '方法', 'type' => 'text', 'option' => '', 'help' => '不填表示所有方法'], - ['name' => 'seo_title', 'title' => 'SEO标题', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'], - ['name' => 'seo_keywords', 'title' => 'SEO关键字', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'], - ['name' => 'seo_description', 'title' => 'SEO描述', 'type' => 'text', 'option' => '', 'help' => '不填表示使用默认'], + ['name' => 'seo_title', 'title' => 'SEO标题', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'], + ['name' => 'seo_keywords', 'title' => 'SEO关键字', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'], + ['name' => 'seo_description', 'title' => 'SEO描述', 'type' => 'text', 'is_must'=>true, 'option' => '', 'help' => '不填表示使用默认'], ['name' => 'status', 'title' => '状态', 'type' => 'select', 'option' => [['key'=>'0', 'label' => '禁用'], ['key'=>'1', 'label' => '启用']], 'help' => ''], ['name' => 'sort', 'title' => '排序', 'type' => 'text', 'option' => '', 'help' => ''], ]; diff --git a/extend/com/Sent.php b/extend/com/Sent.php index 82efdaad..12bb5eea 100644 --- a/extend/com/Sent.php +++ b/extend/com/Sent.php @@ -23,10 +23,11 @@ class Sent extends \think\template\TagLib { ); public function tagnav($tag, $content){ + $type = isset($tag['type']) ? $tag['type'] : ''; $pid = isset($tag['pid']) ? $tag['pid'] : ''; - $tree = isset($tag['tree']) ? $tag['tree'] : 1; + $tree = isset($tag['tree']) ? $tag['tree'] : false; $parse = ' $'.$tag['name'].') {'; $parse .= '?>'; $parse .= $content; diff --git a/public/template/default/front/content_article_list.html b/public/template/default/front/content_article_list.html index 847f3de1..d9e930a9 100644 --- a/public/template/default/front/content_article_list.html +++ b/public/template/default/front/content_article_list.html @@ -34,6 +34,7 @@ html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans
  • {$item['title']}
  • {/volist} + {$page|raw} diff --git a/public/template/default/front/content_topic.html b/public/template/default/front/content_topic.html new file mode 100644 index 00000000..e69de29b diff --git a/public/template/default/front/index_index.html b/public/template/default/front/index_index.html index 75e0c491..50c5cc37 100644 --- a/public/template/default/front/index_index.html +++ b/public/template/default/front/index_index.html @@ -27,6 +27,9 @@ html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans 注册 登录 + {sent:nav tree="false" type="1" name="item"} +
  • {$item['title']}
  • + {/sent:nav}
    diff --git a/view/admin/channel/edit.html b/view/admin/channel/edit.html index 75739f4f..ab5f0dc8 100644 --- a/view/admin/channel/edit.html +++ b/view/admin/channel/edit.html @@ -32,7 +32,7 @@