This commit is contained in:
Default
2025-04-19 16:50:08 +08:00
parent aafd25260a
commit 4299706868
7 changed files with 300 additions and 216 deletions

View File

@@ -808,4 +808,22 @@ namespace {
} }
} }
} }
/**
* generate string
*
* @param integer $length
* @return string
*/
function randomString(int $length): string {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$max = 51; // 字符集长度减1 (0-51)
$result = '';
for ($i = 0; $i < $length; $i++) {
$result .= $chars[random_int(0, $max)];
}
return $result;
}
} }

View File

@@ -9,9 +9,9 @@ use app\services\SiteContext;
use think\facade\Route; use think\facade\Route;
// Route::get('/article/fenlei/:category', function (\think\Request $Request, SiteContext $SiteContext) { Route::get('/article/fenlei/:category', function (\think\Request $Request, SiteContext $SiteContext) {
// return view($SiteContext->getHomeView()); return view('test/test01/index.html');
// }); });

View File

@@ -1,3 +1,24 @@
{novel:pagerexp page="1" limit="10" n_category="$Request.route.category" d_key="d_key" d_val="novel" p_val="page_data"
cache_life="1000" func="generateSearchPager" export_name="fadfads" /}
{php}var_dump($fadfads['p_data']);{/php}
<!-- {novel:pager page="1" limit="10" n_category="$Request.route.category" d_key="d_key" d_val="novel" p_val="page_data"
cache_life="1000" func="generateSearchPager"}
<li>
Index: {$d_key}
Title: {$novel.n_name}
Author: {$novel.n_category}
</li>
{/novel:pager}
{php}var_dump($page_data);{/php} -->
<!-- {site:grm page_code="fdasfadsf" diff="fadsfdsa" num="10" g_key="arrGrm" /} <!-- {site:grm page_code="fdasfadsf" diff="fadsfdsa" num="10" g_key="arrGrm" /}
{php}var_dump($arrGrm);{/php} --> {php}var_dump($arrGrm);{/php} -->
@@ -49,9 +70,9 @@
{/novel:sort} --> {/novel:sort} -->
<!--
{novel:info n_id="33" n_key="arrNovel01" n_forge_id="1125940" /} {novel:info n_id="33" n_key="arrNovel01" n_forge_id="1125940" /}
{$arrNovel01.n_name} {$arrNovel01.n_name} -->
<!-- {$DomainModel->d_domain} --> <!-- {$DomainModel->d_domain} -->
@@ -66,17 +87,3 @@
</li> </li>
{/novel:list} --> {/novel:list} -->
<!--
{novel:pager page="1" limit="10" n_category="$Request.route.category" d_key="d_key" d_val="novel" p_val="page_data"
cache_life="1000" func="generateSearchPager"}
<li>
Index: {$d_key}
Title: {$novel.n_name}
Author: {$novel.n_category}
</li>
{/novel:pager}
{php}var_dump($page_data);{/php}
-->

View File

@@ -168,7 +168,7 @@ class ChapterService
$strCacheKey = ''; $strCacheKey = '';
$intLifeTime = 0; $intLifeTime = 0;
if (empty($arrFilter['$and'])) { if (empty($arrFilter['$and'])) {
$arrFilter = []; $arrFilter = [];
} }
@@ -188,7 +188,7 @@ class ChapterService
$intLifeTime = $intLifeTime; $intLifeTime = $intLifeTime;
} }
$arrNovel = $this->ChapterModel->findPaginatedWithCache( $arrChapter = $this->ChapterModel->findPaginatedWithCache(
$arrFilter, $arrFilter,
$intPage, $intPage,
$intLimit, $intLimit,
@@ -197,10 +197,14 @@ class ChapterService
$intLifeTime, $intLifeTime,
); );
$arrPager = call_user_func([$this, $Func], $arrParams, $arrSort, $arrNovel); $arrPager = call_user_func([$this, $Func], $arrParams, $arrSort, $arrChapter);
$arrPager = $arrChapter;
unset($arrPager['data']);
$arrPager['pager'] = call_user_func([$this, $Func], $arrParams, $arrSort, $arrChapter);
$arrResult = [ $arrResult = [
'data' => $arrNovel['data'], 'data' => $arrChapter['data'],
'p_data' => $arrPager, 'p_data' => $arrPager,
]; ];
@@ -218,7 +222,7 @@ class ChapterService
{ {
// 小说详情 // 小说详情
$arrNovel = $this->NovelModel->getNovelByNId($intNId); $arrNovel = $this->NovelModel->getNovelByNId($intNId);
// 章节 // 章节
$ChapterModel = ChapterModel::getInstance(); $ChapterModel = ChapterModel::getInstance();
$arrFilter = ['n_id' => $intNId, 'c_sort_num' => $intCSortNum, 'c_page' => $intCPage]; $arrFilter = ['n_id' => $intNId, 'c_sort_num' => $intCSortNum, 'c_page' => $intCPage];

View File

@@ -416,8 +416,8 @@ class NovelService
} }
} }
# n_category_sex_zh filter # key filter
if (!empty($strNSex)) { if (!empty($strKey)) {
$strKey = mb_substr($strKey, 0, 30); $strKey = mb_substr($strKey, 0, 30);
$arrFilter['$and'][] = [ $arrFilter['$and'][] = [
@@ -468,7 +468,11 @@ class NovelService
$intLifeTime = $intLifeTime; $intLifeTime = $intLifeTime;
} }
if (empty($arrFilter['$and'])) {
$arrFilter = [];
}
$arrNovel = $this->NovelModel->findPaginatedWithCache( $arrNovel = $this->NovelModel->findPaginatedWithCache(
$arrFilter, $arrFilter,
$intPage, $intPage,
@@ -478,11 +482,12 @@ class NovelService
$intLifeTime, $intLifeTime,
); );
$arrPager = call_user_func([$this, $Func], $arrParams, $arrSort, $arrNovel); $arrPager = $arrNovel;
unset($arrPager['data']);
$arrPager['pager'] = call_user_func([$this, $Func], $arrParams, $arrSort, $arrNovel);
$arrResult = [ $arrResult = [
'data' => $arrNovel['data'] ?? [], 'data' => $arrNovel['data'],
'pages' => $arrNovel['pages'] ?? 0,
'p_data' => $arrPager, 'p_data' => $arrPager,
]; ];

View File

@@ -8,7 +8,8 @@ class Chapter extends TagLib
{ {
protected $tags = [ protected $tags = [
'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val'], 'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val'],
'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val'], 'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,export_name'],
'pagerexp' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 0],
'info' => ['attr' => 'n_id,n_key', 'close' => 0], 'info' => ['attr' => 'n_id,n_key', 'close' => 0],
]; ];
@@ -22,6 +23,19 @@ class Chapter extends TagLib
} }
/**
* pagerexp tag code
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagPagerExp($tag, $content)
{
return $this->tagPager($tag, $content);
}
/** /**
* chapter pager * chapter pager
* *
@@ -42,6 +56,7 @@ class Chapter extends TagLib
$d_val = $tag['d_val'] ?? 'd_val'; $d_val = $tag['d_val'] ?? 'd_val';
$p_val = $tag['p_val'] ?? 'p_val'; $p_val = $tag['p_val'] ?? 'p_val';
$func = $tag['func']; $func = $tag['func'];
$export_name = $tag['export_name'] ?? '';
$n_id = $this->customBuildVar($n_id); $n_id = $this->customBuildVar($n_id);
$sort_type = $this->customBuildVar($sort_type); $sort_type = $this->customBuildVar($sort_type);
@@ -53,9 +68,11 @@ class Chapter extends TagLib
$cache_life = $this->customBuildVar($cache_life); $cache_life = $this->customBuildVar($cache_life);
$func = $this->customBuildVar($func); $func = $this->customBuildVar($func);
$arrDataName = randomString(5);
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrChapter = app(\\app\\services\\ChapterService::class)->getNovelPager([ \${$arrDataName} = app(\\app\\services\\ChapterService::class)->getNovelPager([
'page' => {$page}, 'page' => {$page},
'limit' => {$limit}, 'limit' => {$limit},
'button_num' => {$button_num}, 'button_num' => {$button_num},
@@ -65,19 +82,27 @@ class Chapter extends TagLib
'cache_life' => {$cache_life}, 'cache_life' => {$cache_life},
'func' => {$func}, 'func' => {$func},
]); ]);
EOT;
if (isset(\$arrChapter['data']) && is_array(\$arrChapter['data'])): if (empty($export_name)) {
\${$p_val} = \$arrChapter['p_data'] ?? []; $strParse .= <<<EOT
if (isset(\${$arrDataName}['data']) && is_array(\${$arrDataName}['data'])):
\${$p_val} = \${$arrDataName}['p_data'] ?? [];
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$arrChapter['data'] as \${$d_key} => \${$d_val}): ?> <?php foreach (\${$arrDataName}['data'] as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
} else {
$strParse .= <<<EOT
\${$export_name} = \${$arrDataName};
EOT;
}
return $strParse; return $strParse;
} }
@@ -97,17 +122,17 @@ EOT;
$cache_life = $tag['cache_life'] ?? '0'; $cache_life = $tag['cache_life'] ?? '0';
$d_key = $tag['d_key'] ?? 'd_key'; $d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val'; $d_val = $tag['d_val'] ?? 'd_val';
$count = $this->customBuildVar($count); $count = $this->customBuildVar($count);
$n_id = $this->customBuildVar($n_id); $n_id = $this->customBuildVar($n_id);
$sort_type = $this->customBuildVar($sort_type); $sort_type = $this->customBuildVar($sort_type);
$diff_key = $this->customBuildVar($diff_key); $diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life); $cache_life = $this->customBuildVar($cache_life);
$arrDataName = randomString(5);
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrChapter = app(\\app\\services\\ChapterService::class)->getChapterList([ \${$arrDataName} = app(\\app\\services\\ChapterService::class)->getChapterList([
'n_id' => {$n_id}, 'n_id' => {$n_id},
'count' => {$count}, 'count' => {$count},
'sort_type' => {$sort_type}, 'sort_type' => {$sort_type},
@@ -115,12 +140,12 @@ EOT;
'cache_life' => {$cache_life}, 'cache_life' => {$cache_life},
]); ]);
if (!empty(\$arrChapter) && is_array(\$arrChapter)): if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$arrChapter as \${$d_key} => \${$d_val}): ?> <?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
@@ -148,7 +173,7 @@ EOT;
$n_id = $this->customBuildVar($n_id); $n_id = $this->customBuildVar($n_id);
$c_sort_num = $this->customBuildVar($c_sort_num); $c_sort_num = $this->customBuildVar($c_sort_num);
$c_page = $this->customBuildVar($c_page); $c_page = $this->customBuildVar($c_page);
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrChapter = app(\\app\\services\\ChapterService::class)->getChapterInfo( \$arrChapter = app(\\app\\services\\ChapterService::class)->getChapterInfo(

View File

@@ -6,62 +6,75 @@ use think\template\TagLib;
class Novel extends TagLib class Novel extends TagLib
{ {
protected $tags = [ protected $tags = [
'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val'], 'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val', 'close' => 1],
'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val'], 'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 1],
'info' => ['attr' => 'n_id,n_key', 'close' => 0], 'pagerexp' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 0],
'sort' => ['attr' => 'd_key,d_val'], 'info' => ['attr' => 'n_id,n_key', 'close' => 0],
'status' => ['attr' => 'd_key,d_val'], 'sort' => ['attr' => 'd_key,d_val'],
'sex' => ['attr' => 'd_key,d_val'], 'status' => ['attr' => 'd_key,d_val'],
'category' => ['attr' => 'd_key,d_val'], 'sex' => ['attr' => 'd_key,d_val'],
]; 'category' => ['attr' => 'd_key,d_val'],
];
private function customBuildVar($mixedArgs) private function customBuildVar($mixedArgs)
{ {
if (substr($mixedArgs, 0, 1) == '$') { if (substr($mixedArgs, 0, 1) == '$') {
return $this->autoBuildVar($mixedArgs); return $this->autoBuildVar($mixedArgs);
} else { } else {
return is_numeric($mixedArgs) ? $mixedArgs : "'" . $mixedArgs . "'"; return is_numeric($mixedArgs) ? $mixedArgs : "'" . $mixedArgs . "'";
}
} }
}
/** /**
* novel 自定义标签 * novel 自定义标签
*/ */
public function tagPager($tag, $content) public function tagPagerExp($tag, $content)
{ {
$page = $tag['page'] ?? '0'; return $this->tagPager($tag, $content);
$limit = $tag['limit'] ?? '10'; }
$button_num = $tag['button_num'] ?? '10';
$n_category = $tag['n_category'] ?? "all";
$sort_type = $tag['sort_type'] ?? "";
$n_status = $tag['n_status'] ?? "";
$n_sex = $tag['n_sex'] ?? "";
$key = $tag['key'] ?? "";
$diff_key = $tag['diff_key'] ?? "";
$cache_life = $tag['cache_life'] ?? '0';
$d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val';
$p_val = $tag['p_val'] ?? 'p_val';
$n_num = $tag['n_num'] ?? 'n_num';
$func = $tag['func'];
$page = $this->customBuildVar($page); /**
$limit = $this->customBuildVar($limit); * novel 自定义标签
$button_num = $this->customBuildVar($button_num); */
$n_category = $this->customBuildVar($n_category); public function tagPager($tag, $content)
$sort_type = $this->customBuildVar($sort_type); {
$n_status = $this->customBuildVar($n_status); $page = $tag['page'] ?? '0';
$n_sex = $this->customBuildVar($n_sex); $limit = $tag['limit'] ?? '10';
$key = $this->customBuildVar($key); $button_num = $tag['button_num'] ?? '10';
$diff_key = $this->customBuildVar($diff_key); $n_category = $tag['n_category'] ?? "all";
$cache_life = $this->customBuildVar($cache_life); $sort_type = $tag['sort_type'] ?? "";
$func = $this->customBuildVar($func); $n_status = $tag['n_status'] ?? "";
$n_sex = $tag['n_sex'] ?? "";
$key = $tag['key'] ?? "";
$diff_key = $tag['diff_key'] ?? "";
$cache_life = $tag['cache_life'] ?? '0';
$d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val';
$p_val = $tag['p_val'] ?? 'p_val';
$strParse = <<<EOT $export_name = $tag['export_name'] ?? '';
$func = $tag['func'];
$page = $this->customBuildVar($page);
$limit = $this->customBuildVar($limit);
$button_num = $this->customBuildVar($button_num);
$n_category = $this->customBuildVar($n_category);
$sort_type = $this->customBuildVar($sort_type);
$n_status = $this->customBuildVar($n_status);
$n_sex = $this->customBuildVar($n_sex);
$key = $this->customBuildVar($key);
$diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life);
$func = $this->customBuildVar($func);
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php <?php
\$novelData = app(\\app\\services\\NovelService::class)->getNovelPager([ \${$arrDataName} = app(\\app\\services\\NovelService::class)->getNovelPager([
'page' => {$page}, 'page' => {$page},
'limit' => {$limit}, 'limit' => {$limit},
'button_num' => {$button_num}, 'button_num' => {$button_num},
@@ -74,49 +87,61 @@ class Novel extends TagLib
'cache_life' => {$cache_life}, 'cache_life' => {$cache_life},
'func' => {$func}, 'func' => {$func},
]); ]);
EOT;
if (isset(\$novelData['data']) && is_array(\$novelData['data'])):
\${$p_val} = \$novelData['p_data'] ?? []; if (empty($export_name)) {
\${$n_num} = \$novelData['pages'] ?? []; $strParse .= <<<EOT
if (isset(\${$arrDataName}['data']) && is_array(\${$arrDataName}['data'])):
\${$p_val} = \${$arrDataName}['p_data'] ?? [];
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$novelData['data'] as \${$d_key} => \${$d_val}): ?> <?php foreach (\${$arrDataName}['data'] as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
return $strParse; } else {
} $strParse .= <<<EOT
\${$export_name} = \${$arrDataName};
?>
EOT;
}
/** return $strParse;
* novel 自定义标签 }
*/
public function tagList($tag, $content) /**
{ * novel 自定义标签
$count = $tag['count'] ?? '10'; */
$n_category = $tag['n_category'] ?? "all"; public function tagList($tag, $content)
$sort_type = $tag['sort_type'] ?? ""; {
$n_status = $tag['n_status'] ?? "all"; $count = $tag['count'] ?? '10';
$n_sex = $tag['n_sex'] ?? "all"; $n_category = $tag['n_category'] ?? "all";
$diff_key = $tag['diff_key'] ?? ""; $sort_type = $tag['sort_type'] ?? "";
$cache_life = $tag['cache_life'] ?? '0'; $n_status = $tag['n_status'] ?? "all";
$d_key = $tag['d_key'] ?? 'd_key'; $n_sex = $tag['n_sex'] ?? "all";
$d_val = $tag['d_val'] ?? 'd_val'; $diff_key = $tag['diff_key'] ?? "";
$cache_life = $tag['cache_life'] ?? '0';
$d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val';
$n_category = $this->customBuildVar($n_category); $n_category = $this->customBuildVar($n_category);
$sort_type = $this->customBuildVar($sort_type); $sort_type = $this->customBuildVar($sort_type);
$n_status = $this->customBuildVar($n_status); $n_status = $this->customBuildVar($n_status);
$n_sex = $this->customBuildVar($n_sex); $n_sex = $this->customBuildVar($n_sex);
$diff_key = $this->customBuildVar($diff_key); $diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life); $cache_life = $this->customBuildVar($cache_life);
$strParse = <<<EOT $arrDataName = randomString(5);
$strParse = <<<EOT
<?php <?php
\$novelData = app(\\app\\services\\NovelService::class)->getNovelList([ \${$arrDataName} = app(\\app\\services\\NovelService::class)->getNovelList([
'count' => {$count}, 'count' => {$count},
'n_category' => {$n_category}, 'n_category' => {$n_category},
'sort_type' => {$sort_type}, 'sort_type' => {$sort_type},
@@ -126,42 +151,42 @@ EOT;
'cache_life' => {$cache_life} 'cache_life' => {$cache_life}
]); ]);
if (!empty(\$novelData) && is_array(\$novelData)): if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$novelData as \${$d_key} => \${$d_val}): ?> <?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
return $strParse; return $strParse;
} }
/** /**
* 获取小说详情 * 获取小说详情
* *
* @param array $tag * @param array $tag
* @param string $content * @param string $content
* @return void * @return void
*/ */
public function tagInfo($tag) public function tagInfo($tag)
{ {
$n_id = $tag['n_id'] ?? '0'; $n_id = $tag['n_id'] ?? '0';
$n_forge_id = $tag['n_forge_id'] ?? 0; $n_forge_id = $tag['n_forge_id'] ?? 0;
$n_key = $tag['n_key'] ?? 'arrNovel'; $n_key = $tag['n_key'] ?? 'arrNovel';
$n_id = $this->customBuildVar($n_id); $n_id = $this->customBuildVar($n_id);
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$novelData = app(\\app\\services\\NovelService::class)->getNovelByNId( \$novelData = app(\\app\\services\\NovelService::class)->getNovelByNId(
{$n_id}, {$n_id},
@@ -172,23 +197,23 @@ EOT;
?> ?>
EOT; EOT;
return $strParse; return $strParse;
} }
/** /**
* 获取排序筛选参数 * 获取排序筛选参数
* *
* @param array $tag * @param array $tag
* @param string $content * @param string $content
* @return string * @return string
*/ */
public function tagSort($tag, $content) public function tagSort($tag, $content)
{ {
$d_key = $tag['d_key'] ?? 'd_key'; $d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val'; $d_val = $tag['d_val'] ?? 'd_val';
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrSort = app(\\app\\services\\NovelService::class)->arrSortType; \$arrSort = app(\\app\\services\\NovelService::class)->arrSortType;
@@ -196,31 +221,31 @@ if (!empty(\$arrSort) && is_array(\$arrSort)):
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$arrSort as \${$d_key} => \${$d_val}): ?> <?php foreach (\$arrSort as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
return $strParse; return $strParse;
} }
/** /**
* 获取状态筛选参数 * 获取状态筛选参数
* *
* @param array $tag * @param array $tag
* @param string $content * @param string $content
* @return string * @return string
*/ */
public function tagStatus($tag, $content) public function tagStatus($tag, $content)
{ {
$d_key = $tag['d_key'] ?? 'd_key'; $d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val'; $d_val = $tag['d_val'] ?? 'd_val';
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrStatus = app(\\app\\services\\NovelService::class)->arrStatus; \$arrStatus = app(\\app\\services\\NovelService::class)->arrStatus;
@@ -228,32 +253,32 @@ if (!empty(\$arrStatus) && is_array(\$arrStatus)):
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$arrStatus as \${$d_key} => \${$d_val}): ?> <?php foreach (\$arrStatus as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
return $strParse; return $strParse;
} }
/** /**
* 获取状态筛选参数 * 获取状态筛选参数
* *
* @param array $tag * @param array $tag
* @param string $content * @param string $content
* @return string * @return string
*/ */
public function tagSex($tag, $content) public function tagSex($tag, $content)
{ {
$d_key = $tag['d_key'] ?? 'd_key'; $d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val'; $d_val = $tag['d_val'] ?? 'd_val';
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrSex = app(\\app\\services\\NovelService::class)->arrSex; \$arrSex = app(\\app\\services\\NovelService::class)->arrSex;
@@ -261,31 +286,31 @@ if (!empty(\$arrSex) && is_array(\$arrSex)):
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$arrSex as \${$d_key} => \${$d_val}): ?> <?php foreach (\$arrSex as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
return $strParse; return $strParse;
} }
/** /**
* 获取状态筛选参数 * 获取状态筛选参数
* *
* @param array $tag * @param array $tag
* @param string $content * @param string $content
* @return string * @return string
*/ */
public function tagCategory($tag, $content) public function tagCategory($tag, $content)
{ {
$d_key = $tag['d_key'] ?? 'd_key'; $d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val'; $d_val = $tag['d_val'] ?? 'd_val';
$strParse = <<<EOT $strParse = <<<EOT
<?php <?php
\$arrCategory = app(\\app\\services\\NovelService::class)->getCategoryFilter(); \$arrCategory = app(\\app\\services\\NovelService::class)->getCategoryFilter();
@@ -293,14 +318,14 @@ if (!empty(\$arrCategory) && is_array(\$arrCategory)):
?> ?>
EOT; EOT;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php foreach (\$arrCategory as \${$d_key} => \${$d_val}): ?> <?php foreach (\$arrCategory as \${$d_key} => \${$d_val}): ?>
EOT; EOT;
$strParse .= $content; $strParse .= $content;
$strParse .= <<<EOT $strParse .= <<<EOT
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
EOT; EOT;
return $strParse; return $strParse;
} }
} }