From 759fe7fa06f1ce1cb68ba47cfa8bb60004975a1f Mon Sep 17 00:00:00 2001 From: yumo Date: Tue, 19 Dec 2023 16:34:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84ape=E6=8B=93=E5=B1=95?= =?UTF-8?q?=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/taglib/Ape.php | 52 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/app/common/taglib/Ape.php b/app/common/taglib/Ape.php index d17f2bb..c64ad1c 100644 --- a/app/common/taglib/Ape.php +++ b/app/common/taglib/Ape.php @@ -25,6 +25,7 @@ class Ape extends TagLib 'tags' => ['attr' => 'tags,void', 'close' => 1], 'archive' => ['attr' => 'type,format,void', 'close' => 1], 'nav' => ['attr' => 'type,typeId,row,void,where,orderBy,display', 'close' => 1], + 'table' => ['attr' => 'name,where,orderby,row,pagesize,void', 'close' => 1] ]; /** @@ -129,7 +130,7 @@ class Ape extends TagLib * @param $content * @return string */ - public function tagList($tag, $content): string + public function tagList($tag, $content) { $orderBy = $tag['orderBy'] ?? 'sort desc,create_time desc'; $pageSize = $tag['pageSize'] ?? 15; @@ -193,6 +194,24 @@ class Ape extends TagLib return $parse; } + /** + * 执行SQL + */ + public function tagSql($tag,$content) + { + if(!isset($tag['sql'])){ + return ''; + } + $sql=$tag['sql']; + $parse = 'query(\"$sql\");"; + $parse .= ' ?>'; + $parse .= '{volist name="__LIST__" id="field"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; + } + /** * tagAdvert 广告 * @param $tag @@ -371,4 +390,35 @@ class Ape extends TagLib $parse .= '{/volist}'; return $parse; } + + /** + * 表数据读取 + */ + public function tagTable($tag, $content) + { + $name = isset($tag['name']) ? $tag['name'] : false; + if (!$name) { + return ''; + } + $orderby = isset($tag['orderby']) ? $tag['orderby'] : ''; + $pagesize = isset($tag['pagesize']) ? $tag['pagesize'] : ''; + $void = isset($tag['void']) ? $tag['void'] : 'field'; + $where = isset($tag['where']) ? $tag['where'] : ''; + $row = isset($tag['row']) ? $tag['row'] : '100'; + + $parse = 'render();'; + } else { + $parse .= '$__LIST__ =$__FUN__;'; + } + + $parse .= ' ?>'; + $parse .= '{volist name="__LIST__" id="' . $void . '"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; + } + } \ No newline at end of file