feature view tag get data
This commit is contained in:
@@ -7,7 +7,9 @@ use think\template\TagLib;
|
||||
class Novel extends TagLib
|
||||
{
|
||||
protected $tags = [
|
||||
'list' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_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'],
|
||||
'info' => ['attr' => 'n_id,n_key', 'close' => 0],
|
||||
];
|
||||
|
||||
private function customBuildVar($mixedArgs)
|
||||
@@ -19,10 +21,11 @@ class Novel extends TagLib
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* novel 自定义标签
|
||||
*/
|
||||
public function tagList($tag, $content)
|
||||
public function tagPager($tag, $content)
|
||||
{
|
||||
$page = $tag['page'] ?? '0';
|
||||
$limit = $tag['limit'] ?? '10';
|
||||
@@ -36,6 +39,7 @@ class Novel extends TagLib
|
||||
$d_key = $tag['d_key'] ?? 'd_key';
|
||||
$d_val = $tag['d_val'] ?? 'd_val';
|
||||
$p_val = $tag['p_val'] ?? 'p_val';
|
||||
$func = $tag['func'];
|
||||
|
||||
$page = $this->customBuildVar($page);
|
||||
$limit = $this->customBuildVar($limit);
|
||||
@@ -46,10 +50,11 @@ class Novel extends TagLib
|
||||
$key = $this->customBuildVar($key);
|
||||
$diff_key = $this->customBuildVar($diff_key);
|
||||
$cache_life = $this->customBuildVar($cache_life);
|
||||
$func = $this->customBuildVar($func);
|
||||
|
||||
$parse = <<<EOT
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$novelData = app(\\app\\services\\NovelService::class)->getNovelData([
|
||||
\$novelData = app(\\app\\services\\NovelService::class)->getNovelPager([
|
||||
'page' => {$page},
|
||||
'limit' => {$limit},
|
||||
'n_category' => {$n_category},
|
||||
@@ -58,21 +63,106 @@ class Novel extends TagLib
|
||||
'n_sex' => {$n_sex},
|
||||
'key' => {$key},
|
||||
'diff_key' => {$diff_key},
|
||||
'cache_life' => {$cache_life}
|
||||
'cache_life' => {$cache_life},
|
||||
'func' => {$func},
|
||||
]);
|
||||
|
||||
if (isset(\$novelData['data']) && is_array(\$novelData['data'])):
|
||||
\${$p_val} = \$novelData['p_data'] ?? [];
|
||||
?>
|
||||
EOT;
|
||||
$parse .= <<<EOT
|
||||
$strParse .= <<<EOT
|
||||
<?php foreach (\$novelData['data'] as \${$d_key} => \${$d_val}): ?>
|
||||
EOT;
|
||||
$parse .= $content;
|
||||
$parse .= <<<EOT
|
||||
$strParse .= $content;
|
||||
$strParse .= <<<EOT
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
EOT;
|
||||
return $parse;
|
||||
return $strParse;
|
||||
}
|
||||
|
||||
/**
|
||||
* novel 自定义标签
|
||||
*/
|
||||
public function tagList($tag, $content)
|
||||
{
|
||||
$count = $tag['count'] ?? '10';
|
||||
$n_category = $tag['n_category'] ?? "all";
|
||||
$sort_type = $tag['sort_type'] ?? "";
|
||||
$n_status = $tag['n_status'] ?? "all";
|
||||
$n_sex = $tag['n_sex'] ?? "all";
|
||||
$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);
|
||||
$sort_type = $this->customBuildVar($sort_type);
|
||||
$n_status = $this->customBuildVar($n_status);
|
||||
$n_sex = $this->customBuildVar($n_sex);
|
||||
$diff_key = $this->customBuildVar($diff_key);
|
||||
$cache_life = $this->customBuildVar($cache_life);
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$novelData = app(\\app\\services\\NovelService::class)->getNovelList([
|
||||
'count' => {$count},
|
||||
'n_category' => {$n_category},
|
||||
'sort_type' => {$sort_type},
|
||||
'n_status' => {$n_status},
|
||||
'n_sex' => {$n_sex},
|
||||
'diff_key' => {$diff_key},
|
||||
'cache_life' => {$cache_life}
|
||||
]);
|
||||
|
||||
if (!empty(\$novelData) && is_array(\$novelData)):
|
||||
|
||||
?>
|
||||
EOT;
|
||||
$strParse .= <<<EOT
|
||||
<?php foreach (\$novelData as \${$d_key} => \${$d_val}): ?>
|
||||
EOT;
|
||||
$strParse .= $content;
|
||||
$strParse .= <<<EOT
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
EOT;
|
||||
return $strParse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取小说详情
|
||||
*
|
||||
* @param array $tag
|
||||
* @param string $content
|
||||
* @return void
|
||||
*/
|
||||
public function tagInfo($tag)
|
||||
{
|
||||
$n_id = $tag['n_id'] ?? '0';
|
||||
$n_forge_id = $tag['n_forge_id'] ?? 0;
|
||||
|
||||
$n_key = $tag['n_key'] ?? 'arrNovel';
|
||||
|
||||
$n_id = $this->customBuildVar($n_id);
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$novelData = app(\\app\\services\\NovelService::class)->getNovelByNId(
|
||||
{$n_id},
|
||||
{$n_forge_id}
|
||||
);
|
||||
|
||||
\${$n_key} = \$novelData ?? [];
|
||||
?>
|
||||
EOT;
|
||||
|
||||
return $strParse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class Site extends TagLib
|
||||
'nclurl' => ['attr' => 'n_id,n_py,order,page', 'close' => 0],
|
||||
'nflurl' => ['attr' => 'gender,category,status,order,page', 'close' => 0],
|
||||
'grm' => ['attr' => 'domain,code,line,diff,start,end,index,type', 'close' => 0],
|
||||
'replace' => ['attr' => 'code', 'close' => 0],
|
||||
];
|
||||
|
||||
|
||||
@@ -217,7 +218,7 @@ EOD;
|
||||
/**
|
||||
* 干扰码
|
||||
*
|
||||
* @param array $n_id
|
||||
* @param array
|
||||
* @return string
|
||||
*/
|
||||
public function tagGrm($tag)
|
||||
@@ -236,6 +237,27 @@ EOD;
|
||||
\$strUrl = \\app\\model\\GanRaoMaModel::getGrmCode("{$strDomain}","{$strPageCode}","{$intLine}","{$strDifference}",{$intStartNumber},{$intEndNumber},{$intIndex},{$intType});
|
||||
echo \$strUrl;
|
||||
?>
|
||||
EOD;
|
||||
return $strParse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 内容替换
|
||||
*
|
||||
* @param array
|
||||
* @return string
|
||||
*/
|
||||
public function tagReplace($tag)
|
||||
{
|
||||
$strCode = isset($tag['code']) ? $tag['code'] : '';
|
||||
|
||||
$strParse = <<<EOD
|
||||
<?php
|
||||
\$strUrl = app(\\app\\services\\SiteContext::class)->converterTemplate("{$strCode}");
|
||||
echo \$strUrl;
|
||||
?>
|
||||
EOD;
|
||||
return $strParse;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user