diff --git a/application/admin/controller/home/Encyclopedia.php b/application/admin/controller/home/Encyclopedia.php new file mode 100644 index 0000000..f4b24c1 --- /dev/null +++ b/application/admin/controller/home/Encyclopedia.php @@ -0,0 +1,38 @@ +model = new \app\admin\model\home\Encyclopedia; + $this->view->assign("typeList", $this->model->getTypeList()); + $this->view->assign("recommendList", $this->model->getRecommendList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/controller/home/Information.php b/application/admin/controller/home/Information.php new file mode 100644 index 0000000..b853b41 --- /dev/null +++ b/application/admin/controller/home/Information.php @@ -0,0 +1,38 @@ +model = new \app\admin\model\home\Information; + $this->view->assign("typeList", $this->model->getTypeList()); + $this->view->assign("recommendList", $this->model->getRecommendList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/controller/home/News.php b/application/admin/controller/home/News.php index 8a31833..6579fe0 100644 --- a/application/admin/controller/home/News.php +++ b/application/admin/controller/home/News.php @@ -22,7 +22,10 @@ class News extends Backend { parent::_initialize(); $this->model = new \app\admin\model\home\News; + $this->view->assign("typeList", $this->model->getTypeList()); $this->view->assign("recommendList", $this->model->getRecommendList()); + $this->view->assign("hotList", $this->model->getHotList()); + $this->view->assign("fineList", $this->model->getFineList()); } diff --git a/application/admin/controller/home/NewsCate.php b/application/admin/controller/home/NewsCate.php index f0c849d..63f2774 100644 --- a/application/admin/controller/home/NewsCate.php +++ b/application/admin/controller/home/NewsCate.php @@ -22,6 +22,7 @@ class NewsCate extends Backend { parent::_initialize(); $this->model = new \app\admin\model\home\NewsCate; + $this->view->assign("homeList", $this->model->getHomeList()); $this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("hotList", $this->model->getHotList()); } diff --git a/application/admin/lang/zh-cn/home/encyclopedia.php b/application/admin/lang/zh-cn/home/encyclopedia.php new file mode 100644 index 0000000..8f140d8 --- /dev/null +++ b/application/admin/lang/zh-cn/home/encyclopedia.php @@ -0,0 +1,23 @@ + '标题', + 'Subtitle' => '副标题', + 'Source' => '来源', + 'Image' => '封面', + 'Type' => '文章类型', + 'Type 1' => '富文本', + 'Type 2' => 'PDF文档', + 'Content' => '内容', + 'File' => '附件', + 'Recommend' => '置顶', + 'Recommend 0' => '否', + 'Recommend 1' => '是', + 'Weigh' => '权重', + 'Release_time' => '发布时间', + 'Views' => '浏览量', + 'Virtual_views' => '虚拟浏览量', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Deletetime' => '删除时间' +]; diff --git a/application/admin/lang/zh-cn/home/information.php b/application/admin/lang/zh-cn/home/information.php new file mode 100644 index 0000000..8f140d8 --- /dev/null +++ b/application/admin/lang/zh-cn/home/information.php @@ -0,0 +1,23 @@ + '标题', + 'Subtitle' => '副标题', + 'Source' => '来源', + 'Image' => '封面', + 'Type' => '文章类型', + 'Type 1' => '富文本', + 'Type 2' => 'PDF文档', + 'Content' => '内容', + 'File' => '附件', + 'Recommend' => '置顶', + 'Recommend 0' => '否', + 'Recommend 1' => '是', + 'Weigh' => '权重', + 'Release_time' => '发布时间', + 'Views' => '浏览量', + 'Virtual_views' => '虚拟浏览量', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Deletetime' => '删除时间' +]; diff --git a/application/admin/lang/zh-cn/home/news.php b/application/admin/lang/zh-cn/home/news.php index 85f22b0..6f5f5fc 100644 --- a/application/admin/lang/zh-cn/home/news.php +++ b/application/admin/lang/zh-cn/home/news.php @@ -1,19 +1,32 @@ '新闻类目', - 'Title' => '新闻标题', - 'Subtitle' => '新闻副标题', - 'Image' => '封面', - 'Content' => '内容', - 'Recommend' => '置顶', - 'Recommend 0' => '否', - 'Recommend 1' => '是', - 'Weigh' => '权重', - 'Release_time' => '发布时间', - 'Views' => '浏览量', - 'Createtime' => '创建时间', - 'Updatetime' => '修改时间', - 'Deletetime' => '删除时间', - 'Cate.name' => '类目名' + 'Cate_id' => '新闻类目', + 'Flag' => '分类标识', + 'Title' => '新闻标题', + 'Subtitle' => '新闻副标题', + 'Source' => '来源', + 'Image' => '封面', + 'Type' => '文章类型', + 'Type 1' => '富文本', + 'Type 2' => 'PDF文档', + 'Content' => '内容', + 'File' => '附件', + 'Recommend' => '置顶', + 'Recommend 0' => '否', + 'Recommend 1' => '是', + 'Hot' => '热门', + 'Hot 0' => '否', + 'Hot 1' => '是', + 'Fine' => '精选', + 'Fine 0' => '否', + 'Fine 1' => '是', + 'Weigh' => '权重', + 'Release_time' => '发布时间', + 'Views' => '浏览量', + 'Virtual_views' => '虚拟浏览量', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Deletetime' => '删除时间', + 'Cate.name' => '类目名' ]; diff --git a/application/admin/lang/zh-cn/home/news_cate.php b/application/admin/lang/zh-cn/home/news_cate.php index ac48c12..7445bea 100644 --- a/application/admin/lang/zh-cn/home/news_cate.php +++ b/application/admin/lang/zh-cn/home/news_cate.php @@ -3,6 +3,10 @@ return [ 'Image' => 'icon', 'Name' => '类目名', + 'Flag' => '分类标识', + 'Home' => '首页', + 'Home 0' => '否', + 'Home 1' => '是', 'Status' => '状态', 'Status 1' => '上架', 'Set status to 1'=> '设为上架', diff --git a/application/admin/model/home/Encyclopedia.php b/application/admin/model/home/Encyclopedia.php new file mode 100644 index 0000000..0829b91 --- /dev/null +++ b/application/admin/model/home/Encyclopedia.php @@ -0,0 +1,84 @@ +getPk(); + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); + } + }); + } + + + public function getTypeList() + { + return ['1' => __('Type 1'), '2' => __('Type 2')]; + } + + public function getRecommendList() + { + return ['0' => __('Recommend 0'), '1' => __('Recommend 1')]; + } + + + public function getTypeTextAttr($value, $data) + { + $value = $value ?: ($data['type'] ?? ''); + $list = $this->getTypeList(); + return $list[$value] ?? ''; + } + + + public function getRecommendTextAttr($value, $data) + { + $value = $value ?: ($data['recommend'] ?? ''); + $list = $this->getRecommendList(); + return $list[$value] ?? ''; + } + + + public function getReleaseTimeTextAttr($value, $data) + { + $value = $value ?: ($data['release_time'] ?? ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + protected function setReleaseTimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + +} diff --git a/application/admin/model/home/Information.php b/application/admin/model/home/Information.php new file mode 100644 index 0000000..3e97a4c --- /dev/null +++ b/application/admin/model/home/Information.php @@ -0,0 +1,84 @@ +getPk(); + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); + } + }); + } + + + public function getTypeList() + { + return ['1' => __('Type 1'), '2' => __('Type 2')]; + } + + public function getRecommendList() + { + return ['0' => __('Recommend 0'), '1' => __('Recommend 1')]; + } + + + public function getTypeTextAttr($value, $data) + { + $value = $value ?: ($data['type'] ?? ''); + $list = $this->getTypeList(); + return $list[$value] ?? ''; + } + + + public function getRecommendTextAttr($value, $data) + { + $value = $value ?: ($data['recommend'] ?? ''); + $list = $this->getRecommendList(); + return $list[$value] ?? ''; + } + + + public function getReleaseTimeTextAttr($value, $data) + { + $value = $value ?: ($data['release_time'] ?? ''); + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + protected function setReleaseTimeAttr($value) + { + return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); + } + + +} diff --git a/application/admin/model/home/News.php b/application/admin/model/home/News.php index 857d225..44d1b1f 100644 --- a/application/admin/model/home/News.php +++ b/application/admin/model/home/News.php @@ -25,7 +25,10 @@ class News extends Model // 追加属性 protected $append = [ + 'type_text', 'recommend_text', + 'hot_text', + 'fine_text', 'release_time_text' ]; @@ -41,11 +44,34 @@ class News extends Model } + public function getTypeList() + { + return ['1' => __('Type 1'), '2' => __('Type 2')]; + } + public function getRecommendList() { return ['0' => __('Recommend 0'), '1' => __('Recommend 1')]; } + public function getHotList() + { + return ['0' => __('Hot 0'), '1' => __('Hot 1')]; + } + + public function getFineList() + { + return ['0' => __('Fine 0'), '1' => __('Fine 1')]; + } + + + public function getTypeTextAttr($value, $data) + { + $value = $value ?: ($data['type'] ?? ''); + $list = $this->getTypeList(); + return $list[$value] ?? ''; + } + public function getRecommendTextAttr($value, $data) { @@ -55,6 +81,22 @@ class News extends Model } + public function getHotTextAttr($value, $data) + { + $value = $value ?: ($data['hot'] ?? ''); + $list = $this->getHotList(); + return $list[$value] ?? ''; + } + + + public function getFineTextAttr($value, $data) + { + $value = $value ?: ($data['fine'] ?? ''); + $list = $this->getFineList(); + return $list[$value] ?? ''; + } + + public function getReleaseTimeTextAttr($value, $data) { $value = $value ?: ($data['release_time'] ?? ''); @@ -69,6 +111,6 @@ class News extends Model public function cate() { - return $this->belongsTo(NewsCate::class, 'cate_id', 'id', [], 'LEFT')->setEagerlyType(0); + return $this->belongsTo('app\admin\model\news\Cate', 'cate_id', 'id', [], 'LEFT')->setEagerlyType(0); } } diff --git a/application/admin/model/home/NewsCate.php b/application/admin/model/home/NewsCate.php index 79aaf9b..c0cc35c 100644 --- a/application/admin/model/home/NewsCate.php +++ b/application/admin/model/home/NewsCate.php @@ -25,6 +25,7 @@ class NewsCate extends Model // 追加属性 protected $append = [ + 'home_text', 'status_text', 'hot_text' ]; @@ -41,6 +42,11 @@ class NewsCate extends Model } + public function getHomeList() + { + return ['0' => __('Home 0'), '1' => __('Home 1')]; + } + public function getStatusList() { return ['1' => __('Status 1'), '2' => __('Status 2')]; @@ -52,6 +58,14 @@ class NewsCate extends Model } + public function getHomeTextAttr($value, $data) + { + $value = $value ?: ($data['home'] ?? ''); + $list = $this->getHomeList(); + return $list[$value] ?? ''; + } + + public function getStatusTextAttr($value, $data) { $value = $value ?: ($data['status'] ?? ''); diff --git a/application/admin/validate/home/Encyclopedia.php b/application/admin/validate/home/Encyclopedia.php new file mode 100644 index 0000000..bffbd4f --- /dev/null +++ b/application/admin/validate/home/Encyclopedia.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/validate/home/Information.php b/application/admin/validate/home/Information.php new file mode 100644 index 0000000..cf5ba7f --- /dev/null +++ b/application/admin/validate/home/Information.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/home/encyclopedia/add.html b/application/admin/view/home/encyclopedia/add.html new file mode 100644 index 0000000..a0a4293 --- /dev/null +++ b/application/admin/view/home/encyclopedia/add.html @@ -0,0 +1,112 @@ +
diff --git a/application/admin/view/home/encyclopedia/edit.html b/application/admin/view/home/encyclopedia/edit.html new file mode 100644 index 0000000..95b26af --- /dev/null +++ b/application/admin/view/home/encyclopedia/edit.html @@ -0,0 +1,113 @@ + diff --git a/application/admin/view/home/encyclopedia/index.html b/application/admin/view/home/encyclopedia/index.html new file mode 100644 index 0000000..edab78d --- /dev/null +++ b/application/admin/view/home/encyclopedia/index.html @@ -0,0 +1,29 @@ +