From 348c1d3c568511631c31ef221f2f89e285ef8cd1 Mon Sep 17 00:00:00 2001
From: 1099438829 <1099438829@qq.com>
Date: Sun, 21 Feb 2021 23:58:42 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=96=87=E7=AB=A0=E6=96=B0?=
=?UTF-8?q?=E5=A2=9E=E5=88=86=E7=B1=BB=E8=8E=B7=E5=8F=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/admin/common.php | 21 ++++++++++++++++++++-
app/admin/controller/Article.php | 16 ++++++++++++++--
app/admin/view/article/add.html | 2 +-
app/admin/view/article/edit.html | 2 +-
4 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/app/admin/common.php b/app/admin/common.php
index b8d6614..89f1f7a 100644
--- a/app/admin/common.php
+++ b/app/admin/common.php
@@ -130,4 +130,23 @@ if (!function_exists('get_dir'))
}
return $dirArray;
}
-}
\ No newline at end of file
+}
+
+if (!function_exists('get_tree_list'))
+{
+ /*无限分类*/
+ function get_tree_list(&$list,$pid=0,$level=0,$html='|—')
+ {
+ static $tree = array();
+ foreach ($list as $v) {
+ if ($v['pid'] == $pid) {
+ $v['sort'] = $level;
+ $v['html'] = str_repeat($html, $level);
+ $tree[] = $v;
+ get_tree_list($list, $v['id'], $level + 1);
+ }
+ }
+ return $tree;
+ }
+
+}
diff --git a/app/admin/controller/Article.php b/app/admin/controller/Article.php
index 0db71b5..06cf1b1 100644
--- a/app/admin/controller/Article.php
+++ b/app/admin/controller/Article.php
@@ -109,7 +109,13 @@ class Article extends AuthController
*/
public function add()
{
- $this->assign("category",cModel::selectByType(2));
+ $where = [
+ 'name' => '',
+ 'status' => ''
+ ];
+ $category = cModel::systemPage($where);
+ $category = get_tree_list($category);
+ $this->assign("category",$category);
return $this->fetch();
}
@@ -122,7 +128,13 @@ class Article extends AuthController
*/
public function edit(Request $request)
{
- $this->assign("category",CModel::selectByType(2));
+ $where = [
+ 'name' => '',
+ 'status' => ''
+ ];
+ $category = cModel::systemPage($where);
+ $category = get_tree_list($category);
+ $this->assign("category",$category);
$this->assign("info",aModel::get($request->param(['id'])));
return $this->fetch();
diff --git a/app/admin/view/article/add.html b/app/admin/view/article/add.html
index 7136ddc..83ef08f 100644
--- a/app/admin/view/article/add.html
+++ b/app/admin/view/article/add.html
@@ -38,7 +38,7 @@
diff --git a/app/admin/view/article/edit.html b/app/admin/view/article/edit.html
index 73c039b..fe4b4dd 100644
--- a/app/admin/view/article/edit.html
+++ b/app/admin/view/article/edit.html
@@ -38,7 +38,7 @@