This commit is contained in:
make
2025-04-21 17:47:12 +08:00
parent 24cef96a26
commit 7ef217c1b9
523 changed files with 0 additions and 93250 deletions

View File

@@ -1,215 +0,0 @@
<?php
namespace template\page;
use think\Paginator;
class CusteomPage extends Paginator
{
/**
* 上一页按钮
* @param string $text
* @return string
*/
protected function getPreviousButton(string $text = "上一页"): string
{
if ($this->currentPage() <= 1) {
return $this->getDisabledTextWrapper($text);
}
$url = $this->url(
$this->currentPage() - 1
);
return $this->getPageLinkWrapper($url, $text);
}
/**
* 下一页按钮
* @param string $text
* @return string
*/
protected function getNextButton(string $text = '下一页'): string
{
if (!$this->hasMore) {
return $this->getDisabledTextWrapper($text);
}
$url = $this->url($this->currentPage() + 1);
return $this->getPageLinkWrapper($url, $text);
}
/**
* 页码按钮
* @return string
*/
/**
* 页码按钮
* @return string
*/
protected function getLinks(): string
{
if ($this->simple) {
return '';
}
$block = [
'first' => null,
'slider' => null,
'last' => null,
];
if ($this->lastPage <= 3) {
// 如果总页数少于或等于3显示所有页码
$block['first'] = $this->getUrlRange(1, $this->lastPage);
} else {
if ($this->currentPage == 1) {
// 如果当前页码是第一页,显示前两页和第三页
$block['first'] = $this->getUrlRange(1, 3);
} elseif ($this->currentPage == $this->lastPage) {
// 如果当前页码是最后一页,显示最后三页
$block['first'] = $this->getUrlRange($this->lastPage - 2, $this->lastPage);
} else {
// 否则,显示当前页码及其前后各一页
$block['first'] = $this->getUrlRange($this->currentPage - 1, $this->currentPage + 1);
}
}
$html = '';
if (is_array($block['first'])) {
$html .= $this->getUrlLinks($block['first']);
}
return $html;
}
/**
* 渲染分页html
* @return mixed
*/
public function render()
{
if ($this->hasPages()) {
if ($this->simple) {
return sprintf(
'<ul class="pager">%s %s</ul>',
$this->getPreviousButton(),
$this->getNextButton()
);
} else {
return sprintf(
'<ul class="pagination justify-content-center">%s %s %s %s</ul>%s',
$this->getPreviousButton(),
$this->getLinks(),
$this->getNextButton(),
$this->getTotalInfo(),
$this->getTargePage(),
);
}
}
}
/**
* 跳转
*
* @return string
*/
protected function getTargePage(): string
{
return '<div class="jump-box">
<input type="number" name="page" class="page-link pagination-num" placeholder="跳转页">
<button type="button" data-url="" data-max="' . $this->lastPage() . '"
class="btn btn-primary btn-sm pagination-click">跳转</button>
</div>';
}
/**
* 统计
*
* @return string
*/
protected function getTotalInfo(): string
{
return '<li class="page-item"><span class="page-link">' . $this->currentPage() . '/' . $this->lastPage() . '</span></li>';
}
/**
* 生成一个可点击的按钮
*
* @param string $url
* @param string $page
* @return string
*/
protected function getAvailablePageWrapper(string $url, string $page): string
{
return '<li class="page-item"><a class="page-link" href="' . htmlentities($url) . '">' . $page . '</a></li>';
}
/**
* 生成一个禁用的按钮
*
* @param string $text
* @return string
*/
protected function getDisabledTextWrapper(string $text): string
{
return '<li class="page-item"><span class="page-link">' . $text . '</span></li>';
}
/**
* 生成一个激活的按钮
*
* @param string $text
* @return string
*/
protected function getActivePageWrapper(string $text): string
{
return '<li class="page-item active"><span class="page-link">' . $text . '</span></li>';
}
/**
* 生成省略号按钮
*
* @return string
*/
protected function getDots(): string
{
return $this->getDisabledTextWrapper('...');
}
/**
* 批量生成页码按钮.
*
* @param array $urls
* @return string
*/
protected function getUrlLinks(array $urls): string
{
$html = '';
foreach ($urls as $page => $url) {
$html .= $this->getPageLinkWrapper($url, $page);
}
return $html;
}
/**
* 生成普通页码按钮
*
* @param string $url
* @param string $page
* @return string
*/
protected function getPageLinkWrapper(string $url, string $page): string
{
if ($this->currentPage() == $page) {
return $this->getActivePageWrapper($page);
}
return $this->getAvailablePageWrapper($url, $page);
}
}

View File

@@ -1,152 +0,0 @@
<?php
namespace template\page;
use think\Paginator;
class CusteomPage02
{
/**
* 生成分页按钮数据
* @param int $currentPage 当前页码
* @param int $totalItems 总数据量
* @param int $itemsPerPage 每页条数
* @param string $baseUrl 基础 URL 模板(如 /male/xuanhuan-xiuzhen/finished/page{page}
* @param int $totalButtons 总按钮数量必须大于3
* @param array $buttonLabels 按钮文本配置
* @return array 分页按钮数据
*/
public static function generate(
$currentPage,
$totalItems,
$itemsPerPage,
$baseUrl,
$totalButtons = 5,
$buttonLabels = []
) {
// 默认按钮文本
$defaultLabels = [
'prev' => '上一页',
'next' => '下一页',
'ellipsis' => '...'
];
$labels = array_merge($defaultLabels, $buttonLabels);
// 验证 totalButtons 必须大于 3
if ($totalButtons < 3) {
throw new \InvalidArgumentException('Total buttons must be greater than 3');
}
// 计算总页数
$totalPages = ceil($totalItems / $itemsPerPage);
if ($totalPages <= 1) return []; // 只有一页时返回空数组
// 确保当前页码在有效范围内
$currentPage = max(1, min($currentPage, $totalPages));
// 计算除去“上一页”和“下一页”后可显示的页码按钮数
$pageButtons = $totalButtons - 2; // 减去“上一页”和“下一页”
// 初始化按钮数组
$buttons = [];
// 上一页按钮
$buttons[] = [
'type' => 'prev',
'label' => $labels['prev'],
'url' => $currentPage > 1 ? str_replace('{page}', $currentPage - 1, $baseUrl) : null,
'rel' => $currentPage > 1 ? 'prev' : null,
'disabled' => $currentPage <= 1
];
// 计算页码范围
$half = floor($pageButtons / 2);
$start = max(1, $currentPage - $half);
$end = $start + $pageButtons - 1;
// 调整范围,确保不超过总页数
if ($end > $totalPages) {
$end = $totalPages;
$start = max(1, $end - $pageButtons + 1);
}
// 如果总页数大于可显示的页码数,添加省略号逻辑
if ($totalPages > $pageButtons) {
if ($start > 1) {
$buttons[] = [
'type' => 'page',
'label' => '1',
'url' => str_replace('{page}', 1, $baseUrl),
'current' => false
];
if ($start > 2) {
$buttons[] = [
'type' => 'ellipsis',
'label' => $labels['ellipsis'],
'url' => null
];
}
}
// 添加页码按钮
for ($i = $start; $i <= $end; $i++) {
$buttons[] = [
'type' => 'page',
'label' => (string)$i,
'url' => str_replace('{page}', $i, $baseUrl),
'current' => $i === $currentPage
];
}
if ($end < $totalPages) {
if ($end < $totalPages - 1) {
$buttons[] = [
'type' => 'ellipsis',
'label' => $labels['ellipsis'],
'url' => null
];
}
$buttons[] = [
'type' => 'page',
'label' => (string)$totalPages,
'url' => str_replace('{page}', $totalPages, $baseUrl),
'current' => false
];
}
} else {
// 总页数少于等于可显示页码数,直接全部显示
for ($i = 1; $i <= $totalPages; $i++) {
$buttons[] = [
'type' => 'page',
'label' => (string)$i,
'url' => str_replace('{page}', $i, $baseUrl),
'current' => $i === $currentPage
];
}
}
// 下一页按钮
$buttons[] = [
'type' => 'next',
'label' => $labels['next'],
'url' => $currentPage < $totalPages ? str_replace('{page}', $currentPage + 1, $baseUrl) : null,
'rel' => $currentPage < $totalPages ? 'next' : null,
'disabled' => $currentPage >= $totalPages
];
return $buttons;
}
}
// // 测试示例 1显示 5 个按钮
// $currentPage = 3;
// $totalItems = 100;
// $itemsPerPage = 10;
// $baseUrl = '/male/xuanhuan-xiuzhen/finished/page{page}';
// $buttons = Pagination::generate($currentPage, $totalItems, $itemsPerPage, $baseUrl, 5);
// print_r($buttons);
// // 测试示例 2显示 7 个按钮
// $buttons = Pagination::generate($currentPage, $totalItems, $itemsPerPage, $baseUrl, 7);
// print_r($buttons);
//

View File

@@ -1,36 +0,0 @@
<?php
namespace template\taglib;
use think\template\TagLib;
class Ad extends TagLib
{
protected $tags = [
'list' => ['attr' => 'code,order,limit,id', 'close' => 1]
];
/**
* list标签处理函数
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagList($tag, $content)
{
$code = $tag['code'] ?? '';
$order = $tag['order'] ?? 'asc';
$limit = isset($tag['limit']) ? (int)$tag['limit'] : 10;
$id = $tag['id'] ?? 'ad';
$parse = <<<EOD
<?php
\$adList = \\app\\admin\\model\\GuangGaoModel::getAdByCache("{$code}", {$limit}, "{$order}");
?>
{volist name="adList" id="{$id}"}
$content
{/volist}
EOD;
return $parse;
}
}

View File

@@ -1,193 +0,0 @@
<?php
namespace template\taglib;
use think\template\TagLib;
class Chapter extends TagLib
{
protected $tags = [
'list' => ['attr' => 'count,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,export_name', 'close' => 1],
'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],
];
private function customBuildVar($mixedArgs)
{
if (substr($mixedArgs, 0, 1) == '$') {
return $this->autoBuildVar($mixedArgs);
} else {
return is_numeric($mixedArgs) ? $mixedArgs : "'" . $mixedArgs . "'";
}
}
/**
* pagerexp tag code
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagPagerExp($tag, $content)
{
return $this->tagPager($tag, $content);
}
/**
* chapter pager
*
* @param arrya $tag
* @param string $content
* @return void
*/
public function tagPager($tag, $content)
{
$page = $tag['page'] ?? '0';
$limit = $tag['limit'] ?? '100';
$button_num = $tag['button_num'] ?? '10';
$n_id = $tag['n_id'] ?? '0';
$sort_type = $tag['sort_type'] ?? "";
$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';
$func = $tag['func'];
$export_name = $tag['export_name'] ?? '';
$n_id = $this->customBuildVar($n_id);
$sort_type = $this->customBuildVar($sort_type);
$button_num = $this->customBuildVar($button_num);
$page = $this->customBuildVar($page);
$limit = $this->customBuildVar($limit);
$diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life);
$func = $this->customBuildVar($func);
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php
\${$arrDataName} = app(\\app\\services\\ChapterService::class)->getNovelPager([
'page' => {$page},
'limit' => {$limit},
'button_num' => {$button_num},
'n_id' => {$n_id},
'sort_type' => {$sort_type},
'diff_key' => {$diff_key},
'cache_life' => {$cache_life},
'func' => {$func},
]);
EOT;
if (empty($export_name)) {
$strParse .= <<<EOT
if (isset(\${$arrDataName}['data']) && is_array(\${$arrDataName}['data'])):
\${$p_val} = \${$arrDataName}['p_data'] ?? [];
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\${$arrDataName}['data'] as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
} else {
$strParse .= <<<EOT
\${$export_name} = \${$arrDataName};
?>
EOT;
}
return $strParse;
}
/**
* chapter list
*
* @param arrya $tag
* @param string $content
* @return void
*/
public function tagList($tag, $content)
{
$count = $tag['count'] ?? '100';
$n_id = $tag['n_id'] ?? '0';
$sort_type = $tag['sort_type'] ?? "";
$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';
$count = $this->customBuildVar($count);
$n_id = $this->customBuildVar($n_id);
$sort_type = $this->customBuildVar($sort_type);
$diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life);
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php
\${$arrDataName} = app(\\app\\services\\ChapterService::class)->getChapterList([
'n_id' => {$n_id},
'count' => {$count},
'sort_type' => {$sort_type},
'diff_key' => {$diff_key},
'cache_life' => {$cache_life},
]);
if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
return $strParse;
}
/**
* chapter info
*
* @param arrya $tag
* @param string $content
* @return void
*/
public function tagInfo($tag)
{
$n_id = $tag['n_id'] ?? '0';
$c_sort_num = $tag['c_sort_num'] ?? 0;
$c_page = $tag['c_page'] ?? 0;
$c_key = $tag['c_key'] ?? 'arrChapter';
$n_id = $this->customBuildVar($n_id);
$c_sort_num = $this->customBuildVar($c_sort_num);
$c_page = $this->customBuildVar($c_page);
$strParse = <<<EOT
<?php
\$arrChapter = app(\\app\\services\\ChapterService::class)->getChapterInfo(
{$n_id},
{$c_sort_num},
{$c_page}
);
\${$c_key} = \$arrChapter ?? [];
?>
EOT;
return $strParse;
}
}

View File

@@ -1,403 +0,0 @@
<?php
namespace template\taglib;
use think\template\TagLib;
class Novel extends TagLib
{
protected $tags = [
'list' => ['attr' => 'count,n_category,sort_type,n_status,n_sex,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,func,export_name', 'close' => 1],
'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],
'sort' => ['attr' => 'd_key,d_val'],
'status' => ['attr' => 'd_key,d_val'],
'sex' => ['attr' => 'd_key,d_val'],
'category' => ['attr' => 'd_key,d_val,n_sex'],
'ranklist' => ['attr' => 'count,sort_type,n_status,n_sex,diff_key,cache_life,d_key,d_val', 'close' => 1],
];
private function customBuildVar($mixedArgs)
{
if (substr($mixedArgs, 0, 1) == '$') {
return $this->autoBuildVar($mixedArgs);
} else {
return is_numeric($mixedArgs) ? $mixedArgs : "'" . $mixedArgs . "'";
}
}
/**
* tagRankList
*
* @param array $tag
* @param string $content
* @return void
*/
public function tagRankList($tag, $content)
{
$count = $tag['count'] ?? '10';
$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';
$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);
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php
\${$arrDataName} = app(\\app\\services\\NovelService::class)->getRankList([
'count' => {$count},
'sort_type' => {$sort_type},
'n_status' => {$n_status},
'n_sex' => {$n_sex},
'diff_key' => {$diff_key},
'cache_life' => {$cache_life}
]);
if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
return $strParse;
}
/**
* tagPagerExp
*
* @param array $tag
* @param string $content
* @return void
*/
public function tagPagerExp($tag, $content)
{
return $this->tagPager($tag, $content);
}
/**
* tagPager
*
* @param array $tag
* @param string $content
* @return void
*/
public function tagPager($tag, $content)
{
$page = $tag['page'] ?? '0';
$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';
$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
\${$arrDataName} = app(\\app\\services\\NovelService::class)->getNovelPager([
'page' => {$page},
'limit' => {$limit},
'button_num' => {$button_num},
'n_category' => {$n_category},
'sort_type' => {$sort_type},
'n_status' => {$n_status},
'n_sex' => {$n_sex},
'key' => {$key},
'diff_key' => {$diff_key},
'cache_life' => {$cache_life},
'func' => {$func},
]);
EOT;
if (empty($export_name)) {
$strParse .= <<<EOT
if (isset(\${$arrDataName}['data']) && is_array(\${$arrDataName}['data'])):
\${$p_val} = \${$arrDataName}['p_data'] ?? [];
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\${$arrDataName}['data'] as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
} else {
$strParse .= <<<EOT
\${$export_name} = \${$arrDataName};
?>
EOT;
}
return $strParse;
}
/**
* tagList
*
* @param array $tag
* @param string $content
* @return void
*/
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);
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php
\${$arrDataName} = 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(\${$arrDataName}) && is_array(\${$arrDataName})):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\${$arrDataName} 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;
}
/**
* 获取排序筛选参数
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagSort($tag, $content)
{
$d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val';
$strParse = <<<EOT
<?php
\$arrSort = app(\\app\\services\\NovelService::class)->arrSortType;
if (!empty(\$arrSort) && is_array(\$arrSort)):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\$arrSort as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
return $strParse;
}
/**
* 获取状态筛选参数
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagStatus($tag, $content)
{
$d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val';
$strParse = <<<EOT
<?php
\$arrStatus = app(\\app\\services\\NovelService::class)->arrStatus;
if (!empty(\$arrStatus) && is_array(\$arrStatus)):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\$arrStatus as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
return $strParse;
}
/**
* 获取状态筛选参数
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagSex($tag, $content)
{
$d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val';
$strParse = <<<EOT
<?php
\$arrSex = app(\\app\\services\\NovelService::class)->arrSex;
if (!empty(\$arrSex) && is_array(\$arrSex)):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\$arrSex as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
return $strParse;
}
/**
* 获取状态筛选参数
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagCategory($tag, $content)
{
$d_key = $tag['d_key'] ?? 'd_key';
$d_val = $tag['d_val'] ?? 'd_val';
$n_sex = $tag['n_sex'] ?? '';
$n_sex = $this->customBuildVar($n_sex);
$strParse = <<<EOT
<?php
\$arrCategory = app(\\app\\services\\NovelService::class)->getCategoryFilter( {$n_sex});
if (!empty(\$arrCategory) && is_array(\$arrCategory)):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\$arrCategory as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
return $strParse;
}
}

View File

@@ -1,35 +0,0 @@
<?php
namespace template\taglib;
use think\template\TagLib;
class Rs extends TagLib
{
protected $tags = [
'list' => ['attr' => 'order,limit,id', 'close' => 1]
];
/**
* list标签处理函数
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagList($tag, $content)
{
$order = $tag['order'] ?? 'asc';
$limit = isset($tag['limit']) ? (int)$tag['limit'] : 10;
$id = $tag['id'] ?? 'vo';
$parse = <<<EOD
<?php
\$adRs = \\app\\admin\\model\\ReSouModel::getRsByCache( {$limit}, "{$order}");
?>
{volist name="adRs" id="{$id}"}
$content
{/volist}
EOD;
return $parse;
}
}

View File

@@ -1,364 +0,0 @@
<?php
namespace template\taglib;
use think\template\TagLib;
class Site extends TagLib
{
protected $tags = [
'cfg' => ['attr' => 'code,encode', 'close' => 0],
'wz' => ['attr' => 'wz', 'close' => 0],
'nurl' => ['attr' => 'n_id,n_py', 'close' => 0],
'nnurl' => ['attr' => 'n_id,n_py,n_fid', 'close' => 0],
'souurl' => ['attr' => 'key', 'close' => 0],
'cpurl' => ['attr' => 'n_id,n_py,c_sort,c_page', 'close' => 0],
'lcpurl' => ['attr' => 'n_id,n_py', 'close' => 0],
'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],
'forgelist' => ['attr' => 'count,diff_key,cache_life,d_key,d_val', 'close' => 1],
];
private function customBuildVar($mixedArgs)
{
if (substr($mixedArgs, 0, 1) == '$') {
return $this->autoBuildVar($mixedArgs);
} else {
return is_numeric($mixedArgs) ? $mixedArgs : "'" . $mixedArgs . "'";
}
}
/**
* tagRankList
*
* @param array $tag
* @param string $content
* @return void
*/
public function tagForgeList($tag, $content)
{
$count = $tag['count'] ?? '10';
$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';
$diff_key = $this->customBuildVar($diff_key);
$cache_life = $this->customBuildVar($cache_life);
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php
\${$arrDataName} = app(\\app\\services\\SiteContext::class)->getForgeList([
'count' => {$count},
'diff_key' => {$diff_key},
'cache_life' => {$cache_life}
]);
if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
?>
EOT;
$strParse .= <<<EOT
<?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
EOT;
$strParse .= $content;
$strParse .= <<<EOT
<?php endforeach; ?>
<?php endif; ?>
EOT;
return $strParse;
}
/**
* cfg 标签处理函数-系统配置
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagCfg($tag)
{
$code = isset($tag['code']) ? $tag['code'] : '';
$encode = isset($tag['encode']) ? $tag['encode'] : 'false';
$parse = <<<EOD
<?php
\$strCfgVal = \\app\\model\\SystemConfigModel::getValByCode("{$code}");
if ("{$encode}" === "true") {
echo customEntities(\$strCfgVal);
} else {
echo \$strCfgVal;
}
?>
EOD;
return $parse;
}
/**
* 文字处理函数
*
* @param array $tag
* @param string $content
* @return string
*/
public function tagWz($tag)
{
$strWords = isset($tag['wz']) ? $tag['wz'] : '';
$parse = <<<EOD
<?php
\$strEncodeWords = \\app\\model\\DomainModel::wordsEncode("{$strWords}");
echo \$strEncodeWords;
?>
EOD;
return $parse;
}
/**
* 小说详情URL生成器
*
* @param array $n_id
* @return string
*/
public function tagNUrl($tag)
{
$intNId = isset($tag['n_id']) ? $tag['n_id'] : '';
$strNPy = isset($tag['n_py']) ? $tag['n_py'] : '';
$intNId = $this->customBuildVar($intNId);
$strNPy = $this->customBuildVar($strNPy);
$strParse = <<<EOD
<?php
\$strUrl = app(\\app\\services\\NovelService::class)->getNovelInfoUrl({$intNId},{$strNPy});
echo \$strUrl;
?>
EOD;
return $strParse;
}
/**
* 伪小说详情URL生成器
*
* @param array $n_id
* @return string
*/
public function tagNNUrl($tag)
{
$intNId = isset($tag['n_id']) ? $tag['n_id'] : '';
$strNPy = isset($tag['n_py']) ? $tag['n_py'] : '';
$intNForgeId = isset($tag['n_fid']) ? $tag['n_fid'] : '';
$intNId = $this->customBuildVar($intNId);
$strNPy = $this->customBuildVar($strNPy);
$intNForgeId = $this->customBuildVar($intNForgeId);
$strParse = <<<EOD
<?php
\$strUrl = app(\\app\\services\\NovelService::class)->getForgeNovelInfoUrl({$intNId},{$strNPy},{$intNForgeId});
echo \$strUrl;
?>
EOD;
return $strParse;
}
/**
* 小说章节URL生成器
*
* @param array $n_id
* @return string
*/
public function tagCPUrl($tag)
{
$intNId = isset($tag['n_id']) ? $tag['n_id'] : '';
$strNPy = isset($tag['n_py']) ? $tag['n_py'] : '';
$intChapterSort = isset($tag['c_sort']) ? $tag['c_sort'] : '';
$intChapterPage = isset($tag['c_page']) ? $tag['c_page'] : 0;
$intNId = $this->customBuildVar($intNId);
$strNPy = $this->customBuildVar($strNPy);
$intChapterSort = $this->customBuildVar($intChapterSort);
$intChapterPage = $this->customBuildVar($intChapterPage);
$strParse = <<<EOD
<?php
\$strUrl = app(\\app\\services\\NovelService::class)->getNovelChapterUrl({$intNId},{$strNPy},{$intChapterSort},{$intChapterPage});
echo \$strUrl;
?>
EOD;
return $strParse;
}
/**
* 小说最新章节URL生成器
*
* @param array $n_id
* @return string
*/
public function tagLCPUrl($tag)
{
$intNId = isset($tag['n_id']) ? $tag['n_id'] : '';
$strNPy = isset($tag['n_py']) ? $tag['n_py'] : '';
$intNId = $this->customBuildVar($intNId);
$strNPy = $this->customBuildVar($strNPy);
$strParse = <<<EOD
<?php
\$strUrl = app(\\app\\services\\NovelService::class)->getNovelLasterChapterUrl({$intNId},{$strNPy});
echo \$strUrl;
?>
EOD;
return $strParse;
}
/**
* 小说目录URL生成器
*
* @param array $n_id
* @return string
*/
public function tagNClUrl($tag)
{
$intNId = isset($tag['n_id']) ? $tag['n_id'] : '';
$strNPy = isset($tag['n_py']) ? $tag['n_py'] : '';
$strOrder = isset($tag['order']) ? $tag['order'] : '';
$intPage = isset($tag['page']) ? $tag['page'] : '';
$intNId = $this->customBuildVar($intNId);
$strNPy = $this->customBuildVar($strNPy);
$strOrder = $this->customBuildVar($strOrder);
$intPage = $this->customBuildVar($intPage);
$strParse = <<<EOD
<?php
\$strUrl = app(\\app\\services\\NovelService::class)->getNovelCatalogUrl({$intNId},{$strNPy},{$strOrder},{$intPage});
echo \$strUrl;
?>
EOD;
return $strParse;
}
/**
* 小说书库/分类 URL生成器
*
* @param array $n_id
* @return string
*/
public function tagNFLUrl($tag)
{
$strGender = isset($tag['gender']) ? $tag['gender'] : 'all';
$strCategory = isset($tag['category']) ? $tag['category'] : 'all';
$strStatus = isset($tag['status']) ? $tag['status'] : 'all';
$strOrder = isset($tag['order']) ? $tag['order'] : 'all';
$intPage = isset($tag['page']) ? $tag['page'] : 1;
$strGender = $this->customBuildVar($strGender);
$strCategory = $this->customBuildVar($strCategory);
$strStatus = $this->customBuildVar($strStatus);
$strOrder = $this->customBuildVar($strOrder);
$intPage = $this->customBuildVar($intPage);
$strParse = <<<EOD
<?php
\$strUrl = app(\\app\\services\\NovelService::class)->getNovelCategoryUrl({$strGender},{$strCategory},{$strStatus},{$strOrder},{$intPage});
echo \$strUrl;
?>
EOD;
return $strParse;
}
/**
* 搜索页URL生成器
*
* @param array $key
* @return string
*/
public function tagSouUrl($tag)
{
$strKey = isset($tag['key']) ? $tag['key'] : '';
$intPage = isset($tag['p']) ? $tag['p'] : '';
$strKey = $this->customBuildVar($strKey);
$intPage = $this->customBuildVar($intPage);
$strParse = <<<EOD
<?php
\$strUrl = app(\\app\\services\\NovelService::class)->getNovelSearchUrl({$strKey},{$intPage});
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;
}
/**
* get grm
*
* @param arrya $tag
* @param string $content
* @return void
*/
public function tagGrm($tag)
{
$page_code = $tag['page_code'] ?? '';
$diff = $tag['diff'] ?? '';
$num = $tag['num'] ?? 1;
$g_key = $tag['g_key'] ?? 'arrGrm';
$page_code = $this->customBuildVar($page_code);
$diff = $this->customBuildVar($diff);
$num = $this->customBuildVar($num);
// var_dump($page_code);
// var_dump($diff);
// var_dump($num);
// exit;
$arrDataName = randomString(5);
$strParse = <<<EOT
<?php
\${$arrDataName} = app(\\app\\services\\SiteContext::class)->generateGrm(
{$page_code},
{$diff},
{$num}
);
\${$g_key} = \${$arrDataName} ?? [];
?>
EOT;
return $strParse;
}
}

View File

@@ -1,17 +0,0 @@
<?php
namespace template\ziku;
class WordsEntities
{
static $arrZiKu = [];
static public function getWords($strWords)
{
if (!isset(self::$arrZiKu[$strWords])) {
self::$arrZiKu[$strWords] = customEntities($strWords);
}
return self::$arrZiKu[$strWords];
}
}