debug
This commit is contained in:
@@ -204,13 +204,13 @@ class Novel extends BaseController
|
||||
$arrPage = $NovelModel->getCustomPage01($strKey, $intPage, $intLimit, $intLifeTime, $intGender, $strSearchStatus);
|
||||
|
||||
$strTemplate = '';
|
||||
$intButtomNum = 5;
|
||||
$intButtonNum = 5;
|
||||
if ($boolIsMobile == false) {
|
||||
$intButtomNum = 10;
|
||||
$intButtonNum = 10;
|
||||
$strTemplate = 'pc/getLibrary';
|
||||
}
|
||||
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtomNum);
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtonNum);
|
||||
|
||||
// 更新值
|
||||
ConverterMovel::setVal([
|
||||
@@ -855,13 +855,13 @@ class Novel extends BaseController
|
||||
|
||||
$arrPage = $ChapterModel->findPaginatedWithCache($arrFilter, $intPage, $intLimit, $arrSort, $strKey, $intLifeTime);
|
||||
|
||||
$intButtomNum = 5;
|
||||
$intButtonNum = 5;
|
||||
if ($boolIsMobile == false) {
|
||||
$intButtomNum = 10;
|
||||
$intButtonNum = 10;
|
||||
}
|
||||
|
||||
$strBaseUrl = app(NovelService::class)->getNovelCatalogUrl($intNId, $arrNovel['n_name_pinyin'], $strOrder, '{page}');
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtomNum);
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtonNum);
|
||||
|
||||
// 更新值
|
||||
ConverterMovel::setVal([
|
||||
@@ -941,11 +941,11 @@ class Novel extends BaseController
|
||||
|
||||
$arrPage = $NovelModel->findPaginatedWithCache($arrFilter, $intPage, $intLimit, [], $strKey);
|
||||
|
||||
$intButtomNum = 10;
|
||||
$intButtonNum = 10;
|
||||
|
||||
|
||||
$strBaseUrl = app(NovelService::class)->getNovelSearchUrl($strSearchKeywords, '{page}');
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtomNum);
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrPage['total'], $intLimit, $strBaseUrl, $intButtonNum);
|
||||
|
||||
// 更新值
|
||||
ConverterMovel::setVal([
|
||||
|
||||
@@ -1,8 +1,57 @@
|
||||
{site:grm page_code="fdasfadsf" diff="fadsfdsa" num="10" g_key="arrGrm" /}
|
||||
{php}var_dump($arrGrm);{/php}
|
||||
|
||||
<!-- {chapter:info n_id="1" c_sort_num="200" c_page="0" c_key="arrChapter01" /}
|
||||
{$arrChapter01.c_name} -->
|
||||
|
||||
|
||||
{novel:info n_id="33" n_key="arrNovel01" n_forge_id="1125940" /}
|
||||
{$arrNovel01.n_name}
|
||||
<!-- {chapter:pager page="1" limit="10" n_id="$Request.get.n_id" d_key="d_key" d_val="chapter" cache_life="1000" button_num="3" sort_type="dao" p_val="page_data" func="generateChapterPager"}
|
||||
<li>
|
||||
Index: {$d_key}
|
||||
章节名称: {$chapter.c_name}
|
||||
章节序号: {$chapter.c_sort_num}
|
||||
</li>
|
||||
{/chapter:pager}
|
||||
{php}var_dump($page_data);{/php} -->
|
||||
|
||||
<!-- {chapter:list count="10" n_id="$Request.get.n_id" d_key="d_key" d_val="chapter" cache_life="1000"}
|
||||
<li>
|
||||
Index: {$d_key}
|
||||
章节名称: {$chapter.c_name}
|
||||
章节序号: {$chapter.c_sort_num}
|
||||
</li>
|
||||
{/chapter:list} -->
|
||||
|
||||
<!--
|
||||
{novel:category d_key="key" d_val="val"}
|
||||
<li>
|
||||
键: {$key} - 值: {$val}
|
||||
</li>
|
||||
{/novel:category} -->
|
||||
|
||||
<!-- {novel:sex d_key="key" d_val="val"}
|
||||
<li>
|
||||
键: {$key} - 值: {$val}
|
||||
</li>
|
||||
{/novel:sex} -->
|
||||
<!--
|
||||
{novel:status d_key="key" d_val="val"}
|
||||
<li>
|
||||
键: {$key} - 值: {$val}
|
||||
</li>
|
||||
{/novel:status} -->
|
||||
|
||||
<!--
|
||||
{novel:sort d_key="key" d_val="val"}
|
||||
<li>
|
||||
键: {$key} - 值: {$val}
|
||||
</li>
|
||||
{/novel:sort} -->
|
||||
|
||||
|
||||
|
||||
<!-- {novel:info n_id="33" n_key="arrNovel01" n_forge_id="1125940" /}
|
||||
{$arrNovel01.n_name} -->
|
||||
|
||||
<!-- {$DomainModel->d_domain} -->
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ class CategoryModel extends MongoModel
|
||||
return self::$arrCategory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
||||
@@ -209,6 +209,40 @@ class ChapterModel extends MongoModel
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $arrFilter
|
||||
* @param integer $intCount
|
||||
* @param array $arrSort
|
||||
* @param array $arrOptions
|
||||
* @param boolean $boolReadContent
|
||||
* @return null|array
|
||||
*/
|
||||
public function findManyShuffledWithCache(
|
||||
array $arrFilter,
|
||||
int $intCount = 0,
|
||||
array $arrSort = ['c_sort_num' => -1],
|
||||
string $strKey = '',
|
||||
int $intLifeTime = 24 * 3600,
|
||||
bool $boolReadContent = false
|
||||
): null|array {
|
||||
$arrResult = $this->checkCacheByKey($strKey);
|
||||
if ($arrResult !== NULL) {
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
if (empty($arrOptions)) {
|
||||
$arrOptions = self::$arrChapterOptions;
|
||||
}
|
||||
|
||||
$arrResult = $this->findMany($arrFilter, $intCount, $arrSort, [], $boolReadContent);
|
||||
|
||||
$this->setCacheByKey($strKey, $arrResult, $intLifeTime);
|
||||
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
||||
@@ -204,7 +204,7 @@ class GanRaoMaModel extends MongoModel
|
||||
* @param string $strPageCode 视图编码
|
||||
* @param string $strDifference 差异
|
||||
* @param int $intNum 生成数量
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
static public function getGrmCode($strDomain, $strPageCode, $strDifference, $intNum)
|
||||
{
|
||||
|
||||
@@ -149,7 +149,6 @@ class NovelModel extends MongoModel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find one novel
|
||||
*
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
namespace app\services;
|
||||
|
||||
use app\model\ChapterModel;
|
||||
use app\model\ConverterMovel;
|
||||
use app\model\NovelModel;
|
||||
use template\page\CusteomPage02;
|
||||
use think\facade\View;
|
||||
|
||||
class ChapterService
|
||||
{
|
||||
@@ -20,9 +24,259 @@ class ChapterService
|
||||
*/
|
||||
public $ChapterModel;
|
||||
|
||||
/**
|
||||
* NovelModel
|
||||
*
|
||||
* @var NovelModel
|
||||
*/
|
||||
public $NovelModel;
|
||||
|
||||
public function __construct(SiteContext $SiteContext)
|
||||
{
|
||||
$this->SiteContext = $SiteContext;
|
||||
$this->NovelModel = NovelModel::getInstance();
|
||||
$this->ChapterModel = ChapterModel::getInstance();
|
||||
}
|
||||
|
||||
public $arrSortType = [
|
||||
'zheng' => '正序',
|
||||
'dao' => '倒叙',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 获取小说数据
|
||||
*
|
||||
* @param array $arrParams
|
||||
* @return array
|
||||
*/
|
||||
public function getChapterList(array $arrParams): array
|
||||
{
|
||||
$intCount = (int)$arrParams['count'] ?? 10;
|
||||
$intNId = (int)$arrParams['n_id'] ?? 0;
|
||||
$strSortType = (string)$arrParams['sort_type'] ?? '';
|
||||
$strDiffKey = (string) $arrParams['diff_key'] ?? '';
|
||||
$intCacheLifeTime = (int)$arrParams['cache_life'] ?? 0;
|
||||
|
||||
$arrFilter = [
|
||||
'n_id' => $intNId,
|
||||
'c_page' => 0,
|
||||
];
|
||||
|
||||
$arrFilter['n_id'] = $intNId;
|
||||
|
||||
$arrSort = [];
|
||||
|
||||
# sort filter
|
||||
if (!empty($strSortType)) {
|
||||
switch ($strSortType) {
|
||||
case 'zheng':
|
||||
$arrSort['c_sort_num'] = 1;
|
||||
break;
|
||||
case 'dao':
|
||||
$arrSort['c_sort_num'] = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$strCacheKey = '';
|
||||
$intLifeTime = 0;
|
||||
|
||||
# cache filter
|
||||
if ($intCacheLifeTime > 0) {
|
||||
$strCacheKey = sprintf(
|
||||
'ChapterService:getChapterList:%s:%s:%s:%s:%s',
|
||||
$this->SiteContext->DomainModel->d_domain,
|
||||
md5(serialize($arrFilter)),
|
||||
md5(serialize($arrSort)),
|
||||
$intCount,
|
||||
$strDiffKey,
|
||||
);
|
||||
|
||||
$intLifeTime = $intLifeTime;
|
||||
}
|
||||
|
||||
$arrChapter = $this->ChapterModel->findManyShuffledWithCache(
|
||||
$arrFilter,
|
||||
$intCount,
|
||||
$arrSort,
|
||||
$strCacheKey,
|
||||
$intLifeTime,
|
||||
);
|
||||
|
||||
return $arrChapter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取小说分页数据
|
||||
*
|
||||
* @param array $arrParams
|
||||
* @return array
|
||||
*/
|
||||
public function getNovelPager(array $arrParams): array
|
||||
{
|
||||
$arrParams = [
|
||||
'page' => max((int)($arrParams['page'] ?? 1), 1),
|
||||
'limit' => (int)($arrParams['limit'] ?? 10),
|
||||
'n_id' => (int)($arrParams['n_id'] ?? 0),
|
||||
'button_num' => (int)($arrParams['button_num'] ?? 0),
|
||||
'sort_type' => (string)($arrParams['sort_type'] ?? ''),
|
||||
'diff_key' => (string)($arrParams['diff_key'] ?? ''),
|
||||
'key' => (string)($arrParams['key'] ?? ''),
|
||||
'cache_life' => (int)($arrParams['cache_life'] ?? 0),
|
||||
'func' => (string)($arrParams['func']),
|
||||
];
|
||||
|
||||
if (!in_array($arrParams['sort_type'], array_keys($this->arrSortType))) {
|
||||
$arrParams['sort_type'] = 'zheng';
|
||||
}
|
||||
|
||||
$intPage = $arrParams['page'];
|
||||
$intLimit = $arrParams['limit'];
|
||||
$intNId = $arrParams['n_id'];
|
||||
|
||||
$strSortType = $arrParams['sort_type'];
|
||||
$strDiffKey = $arrParams['diff_key'];
|
||||
$intCacheLifeTime = $arrParams['cache_life'];
|
||||
$Func = $arrParams['func'];
|
||||
|
||||
if ($intPage <= 0) {
|
||||
$intPage = 1;
|
||||
}
|
||||
|
||||
$arrFilter = [
|
||||
'$and' => [],
|
||||
];
|
||||
|
||||
$arrFilter['$and'][] = ['n_id' => $intNId];
|
||||
$arrFilter['$and'][] = ['c_page' => 0];
|
||||
|
||||
$arrSort = [];
|
||||
|
||||
# sort filter
|
||||
if (!empty($strSortType)) {
|
||||
switch ($strSortType) {
|
||||
case 'zheng':
|
||||
$arrSort['c_sort_num'] = 1;
|
||||
break;
|
||||
case 'dao':
|
||||
$arrSort['c_sort_num'] = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$strCacheKey = '';
|
||||
$intLifeTime = 0;
|
||||
|
||||
# cache filter
|
||||
if ($intCacheLifeTime > 0) {
|
||||
$strCacheKey = sprintf(
|
||||
'Service:getNovelList:%s:%s:%s:%s:%s:%s',
|
||||
$this->SiteContext->DomainModel->d_domain,
|
||||
md5(serialize($arrFilter)),
|
||||
md5(serialize($arrSort)),
|
||||
$intPage,
|
||||
$intLimit,
|
||||
$strDiffKey,
|
||||
);
|
||||
|
||||
$intLifeTime = $intLifeTime;
|
||||
}
|
||||
|
||||
$arrNovel = $this->ChapterModel->findPaginatedWithCache(
|
||||
$arrFilter,
|
||||
$intPage,
|
||||
$intLimit,
|
||||
$arrSort,
|
||||
$strCacheKey,
|
||||
$intLifeTime,
|
||||
);
|
||||
|
||||
$arrPager = call_user_func([$this, $Func], $arrParams, $arrSort, $arrNovel);
|
||||
|
||||
$arrResult = [
|
||||
'data' => $arrNovel['data'],
|
||||
'p_data' => $arrPager,
|
||||
];
|
||||
|
||||
return $arrResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据NId获取小说详情
|
||||
*
|
||||
* @param integer $intNId
|
||||
* @return void
|
||||
*/
|
||||
public function getChapterInfo(int $intNId, int $intCSortNum, int $intCPage)
|
||||
{
|
||||
// 小说详情
|
||||
$arrNovel = $this->NovelModel->getNovelByNId($intNId);
|
||||
|
||||
// 章节
|
||||
$ChapterModel = ChapterModel::getInstance();
|
||||
$arrFilter = ['n_id' => $intNId, 'c_sort_num' => $intCSortNum, 'c_page' => $intCPage];
|
||||
|
||||
|
||||
$arrChapter = $ChapterModel->findOne($arrFilter);
|
||||
$strChapterDescription = '';
|
||||
|
||||
// 上一章节和下一章节
|
||||
$arrPreChapter = $arrNextChapter = [];
|
||||
|
||||
if ($arrChapter) {
|
||||
$arrPreChapter = $ChapterModel->getPreChapter($arrChapter['n_id'], $arrChapter['c_sort_num'], $arrChapter['c_page']);
|
||||
$arrNextChapter = $ChapterModel->getNextChapter($arrChapter['n_id'], $arrChapter['c_sort_num'], $arrChapter['c_page']);
|
||||
|
||||
// 要点-先从章节随机截取,后面如果用上ai,看看使用ai 提炼 精简内容
|
||||
$strChapterDescription = strip_tags($arrChapter['c_content']);
|
||||
$intCount = mb_strlen($strChapterDescription);
|
||||
$strChapterDescription = ($intCount > 50) ? mb_substr($strChapterDescription, 0, 50) : $strChapterDescription;
|
||||
|
||||
$arrChapter['c_content'] = base64_encode($arrChapter['c_content']);
|
||||
}
|
||||
|
||||
$arrChapter['pre_chapter'] = $arrPreChapter;
|
||||
$arrChapter['next_chapter'] = $arrNextChapter;
|
||||
|
||||
// 更新值
|
||||
ConverterMovel::setVal([
|
||||
'intPage' => 1,
|
||||
'strNovelName' => $arrNovel['n_name'],
|
||||
'strNovelAuthor' => $arrNovel['n_author'],
|
||||
'strNovelCategoryName' => $arrNovel['n_category'],
|
||||
'strNovelStatus' => $arrNovel['n_status'],
|
||||
'strNovelDescription' => $arrNovel['n_description'],
|
||||
'strChapterDescription' => $strChapterDescription,
|
||||
'strNovelChapterName' => $arrChapter['c_name'],
|
||||
'strNovelChapterSort' => $arrChapter['c_sort_num'],
|
||||
]);
|
||||
|
||||
return $arrChapter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 搜索定制分页
|
||||
*
|
||||
* @param array $arrFilter 查询条件字段
|
||||
* @param array $arrSort 查询排序字段
|
||||
* @param array $arrChapter 查询出来的数据
|
||||
* @return array
|
||||
*/
|
||||
public function generateChapterPager(array $arrParams, array $arrSort, array $arrChapter): array
|
||||
{
|
||||
|
||||
$arrNovel = $this->NovelModel->getNovelByNId($arrParams['n_id']);
|
||||
$intButtonNum = $arrParams['button_num'];
|
||||
$intPage = $arrChapter['page'];
|
||||
$intLimit = $arrChapter['limit'];
|
||||
|
||||
$strBaseUrl = app(NovelService::class)->getNovelCatalogUrl($arrParams['n_id'], $arrNovel['n_name_pinyin'], $arrParams['sort_type'], '{page}');
|
||||
$arrPaginator = CusteomPage02::generate($intPage, $arrChapter['total'], $intLimit, $strBaseUrl, $intButtonNum);
|
||||
|
||||
return $arrPaginator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,27 +209,36 @@ class NovelService
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected $arrSortType = [
|
||||
public $arrSortType = [
|
||||
'all' => '全部排序',
|
||||
'news' => '最新入库',
|
||||
'tuijian' => '推荐',
|
||||
'update' => '最新更新',
|
||||
];
|
||||
|
||||
protected $arrStatus = [
|
||||
public $arrStatus = [
|
||||
'all' => '所有',
|
||||
'lianzai' => '连载中',
|
||||
'wanjie' => '已完结',
|
||||
];
|
||||
|
||||
protected $arrSex = [
|
||||
public $arrSex = [
|
||||
'all' => '所有',
|
||||
'man' => '男生',
|
||||
'women' => '女生',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* GetCategoryFilter
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCategoryFilter(): array
|
||||
{
|
||||
return array_combine(CategoryModel::$arrCategoryPinYin, CategoryModel::$arrCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小说数据
|
||||
*
|
||||
@@ -518,7 +527,6 @@ class NovelService
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 分类拼音
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace app\services;
|
||||
|
||||
use app\model\ConverterMovel;
|
||||
use app\model\DomainModel;
|
||||
use app\model\GanRaoMaModel;
|
||||
use app\model\TemplatesModel;
|
||||
use think\facade\Request;
|
||||
use think\facade\Config;
|
||||
@@ -109,4 +110,19 @@ class SiteContext
|
||||
|
||||
return ConverterMovel::convert($strTitleTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取干扰码
|
||||
*
|
||||
* @param string $strPageCode
|
||||
* @param string $strDiff
|
||||
* @param integer $intNum
|
||||
* @return array
|
||||
*/
|
||||
public function generateGrm(string $strPageCode, string $strDiff, int $intNum): array
|
||||
{
|
||||
$strDomain = $this->DomainModel->d_domain;
|
||||
|
||||
return GanRaoMaModel::getGrmCode($strDomain, $strPageCode, $strDiff, $intNum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ return [
|
||||
|
||||
|
||||
// 自定义标签
|
||||
'taglib_pre_load' => '\\template\\taglib\\Ad,\\template\\taglib\\Site,\\template\\taglib\\Rs,\\template\\taglib\\Novel',
|
||||
'taglib_pre_load' => '\\template\\taglib\\Ad,\\template\\taglib\\Site,\\template\\taglib\\Rs,\\template\\taglib\\Novel,\\template\\taglib\\Chapter',
|
||||
|
||||
// 模板渲染缓存
|
||||
'display_cache' => env('VIEW_DISPLAY_CACHE', false),
|
||||
|
||||
166
code/extend/template/taglib/Chapter.php
Normal file
166
code/extend/template/taglib/Chapter.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace template\taglib;
|
||||
|
||||
use think\template\TagLib;
|
||||
|
||||
class Chapter extends TagLib
|
||||
{
|
||||
protected $tags = [
|
||||
'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)
|
||||
{
|
||||
if (substr($mixedArgs, 0, 1) == '$') {
|
||||
return $this->autoBuildVar($mixedArgs);
|
||||
} else {
|
||||
return is_numeric($mixedArgs) ? $mixedArgs : "'" . $mixedArgs . "'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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'];
|
||||
|
||||
$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);
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$arrChapter = 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},
|
||||
]);
|
||||
|
||||
if (isset(\$arrChapter['data']) && is_array(\$arrChapter['data'])):
|
||||
\${$p_val} = \$arrChapter['p_data'] ?? [];
|
||||
?>
|
||||
EOT;
|
||||
$strParse .= <<<EOT
|
||||
<?php foreach (\$arrChapter['data'] as \${$d_key} => \${$d_val}): ?>
|
||||
EOT;
|
||||
$strParse .= $content;
|
||||
$strParse .= <<<EOT
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
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);
|
||||
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$arrChapter = 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(\$arrChapter) && is_array(\$arrChapter)):
|
||||
|
||||
?>
|
||||
EOT;
|
||||
$strParse .= <<<EOT
|
||||
<?php foreach (\$arrChapter 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;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,10 @@ class Novel extends TagLib
|
||||
'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],
|
||||
'sort' => ['attr' => 'd_key,d_val'],
|
||||
'status' => ['attr' => 'd_key,d_val'],
|
||||
'sex' => ['attr' => 'd_key,d_val'],
|
||||
'category' => ['attr' => 'd_key,d_val'],
|
||||
];
|
||||
|
||||
private function customBuildVar($mixedArgs)
|
||||
@@ -165,4 +169,133 @@ 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';
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$arrCategory = app(\\app\\services\\NovelService::class)->getCategoryFilter();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,14 @@ class Site extends TagLib
|
||||
'replace' => ['attr' => 'code', 'close' => 0],
|
||||
];
|
||||
|
||||
private function customBuildVar($mixedArgs)
|
||||
{
|
||||
if (substr($mixedArgs, 0, 1) == '$') {
|
||||
return $this->autoBuildVar($mixedArgs);
|
||||
} else {
|
||||
return is_numeric($mixedArgs) ? $mixedArgs : "'" . $mixedArgs . "'";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cfg 标签处理函数-系统配置
|
||||
@@ -215,31 +223,7 @@ EOD;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 干扰码
|
||||
*
|
||||
* @param array
|
||||
* @return string
|
||||
*/
|
||||
public function tagGrm($tag)
|
||||
{
|
||||
$strDomain = isset($tag['domain']) ? $tag['domain'] : '';
|
||||
$strPageCode = isset($tag['code']) ? $tag['code'] : '';
|
||||
$intLine = isset($tag['line']) ? $tag['line'] : 0;
|
||||
$strDifference = isset($tag['diff']) ? $tag['diff'] : '';
|
||||
$intStartNumber = isset($tag['start']) ? (int)$tag['start'] : 10;
|
||||
$intEndNumber = isset($tag['end']) ? (int)$tag['end'] : 30;
|
||||
$intIndex = isset($tag['index']) ? (int)$tag['index'] : 10;
|
||||
$intType = isset($tag['type']) ? (int)$tag['type'] : 2;
|
||||
|
||||
$strParse = <<<EOD
|
||||
<?php
|
||||
\$strUrl = \\app\\model\\GanRaoMaModel::getGrmCode("{$strDomain}","{$strPageCode}","{$intLine}","{$strDifference}",{$intStartNumber},{$intEndNumber},{$intIndex},{$intType});
|
||||
echo \$strUrl;
|
||||
?>
|
||||
EOD;
|
||||
return $strParse;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -261,4 +245,39 @@ EOD;
|
||||
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);
|
||||
|
||||
$strParse = <<<EOT
|
||||
<?php
|
||||
\$arrChapter = app(\\app\\services\\SiteContext::class)->generateGrm(
|
||||
{$page_code},
|
||||
{$diff},
|
||||
{$num}
|
||||
);
|
||||
|
||||
\${$g_key} = \$arrChapter ?? [];
|
||||
?>
|
||||
EOT;
|
||||
|
||||
return $strParse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +142,112 @@
|
||||
{novel:info n_id="33" n_key="arrNovel01" n_forge_id="1125940" /}
|
||||
{$arrNovel01.n_name}
|
||||
|
||||
# 05、获取小说状态筛选条件
|
||||
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||
$d_key ?? 'd_key'; # 查询出来的数据遍历的时候, 下标键变量的名称
|
||||
$d_val ?? 'd_val'; # 查询出来的数据遍历的时候, 值的名称
|
||||
# 样例
|
||||
{novel:status d_key="key" d_val="val"}
|
||||
<li> 键: {$key} - 值: {$val} </li>
|
||||
{/novel:status}
|
||||
|
||||
# 06、获取小说性别筛选条件
|
||||
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||
$d_key ?? 'd_key'; # 查询出来的数据遍历的时候, 下标键变量的名称
|
||||
$d_val ?? 'd_val'; # 查询出来的数据遍历的时候, 值的名称
|
||||
# 样例
|
||||
{novel:sex d_key="key" d_val="val"}
|
||||
<li> 键: {$key} - 值: {$val} </li>
|
||||
{/novel:sex}
|
||||
|
||||
# 07、获取小说排序筛选条件
|
||||
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||
$d_key ?? 'd_key'; # 查询出来的数据遍历的时候, 下标键变量的名称
|
||||
$d_val ?? 'd_val'; # 查询出来的数据遍历的时候, 值的名称
|
||||
# 样例
|
||||
{novel:sort d_key="key" d_val="val"}
|
||||
<li> 键: {$key} - 值: {$val} </li>
|
||||
{/novel:sort}
|
||||
|
||||
|
||||
# 08、获取小说分类筛选条件
|
||||
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||
$d_key ?? 'd_key'; # 查询出来的数据遍历的时候, 下标键变量的名称
|
||||
$d_val ?? 'd_val'; # 查询出来的数据遍历的时候, 值的名称
|
||||
# 样例
|
||||
{novel:category d_key="key" d_val="val"}
|
||||
<li> 键: {$key} - 值: {$val} </li>
|
||||
{/novel:category}
|
||||
|
||||
|
||||
# 09、 获取指定小说多个章节数据并且遍历
|
||||
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||
$count ?? '10'; # 查询条数
|
||||
$n_id ; # 小说ID
|
||||
$sort_type ?? "all"; # 排序方式
|
||||
$diff_key ?? ""; # 缓存键值差异
|
||||
$cache_life ?? '0'; # 缓存时间,如果需要开启缓存,这个字段必须传,而且必须大于0
|
||||
$d_key ?? 'd_key'; # 查询出来的数据遍历的时候, 下标键变量的名称
|
||||
$d_val ?? 'd_val'; # 查询出来的数据遍历的时候, 值的名称
|
||||
# 样例
|
||||
{chapter:list count="10" n_id="$Request.get.n_id" d_key="d_key" d_val="chapter" cache_life="1000"}
|
||||
<li>
|
||||
Index: {$d_key}
|
||||
章节名称: {$chapter.c_name}
|
||||
章节序号: {$chapter.c_sort_num}
|
||||
</li>
|
||||
{/chapter:list}
|
||||
|
||||
|
||||
# 10、 获取指定小说多个章节数据并且遍历
|
||||
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||
$count ?? '10'; # 查询条数
|
||||
$n_id ; # 小说ID
|
||||
$sort_type ?? "all"; # 排序方式
|
||||
$diff_key ?? ""; # 缓存键值差异
|
||||
$cache_life ?? '0'; # 缓存时间,如果需要开启缓存,这个字段必须传,而且必须大于0
|
||||
$d_key ?? 'd_key'; # 查询出来的数据遍历的时候, 下标键变量的名称
|
||||
$d_val ?? 'd_val'; # 查询出来的数据遍历的时候, 值的名称
|
||||
# 样例
|
||||
{chapter:list count="10" n_id="$Request.get.n_id" d_key="d_key" d_val="chapter" cache_life="1000"}
|
||||
<li>
|
||||
Index: {$d_key}
|
||||
章节名称: {$chapter.c_name}
|
||||
章节序号: {$chapter.c_sort_num}
|
||||
</li>
|
||||
{/chapter:list}
|
||||
|
||||
|
||||
# 11、 获取指定小说分页数据并且遍历
|
||||
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||
$page ?? '1'; # 页码
|
||||
$limit ?? '10'; # 查询条数
|
||||
$n_id ; # 小说ID
|
||||
$sort_type ?? "all"; # 排序方式
|
||||
$button_num ?? "10"; # 分页按钮数量
|
||||
|
||||
$diff_key ?? ""; # 缓存键值差异
|
||||
$cache_life ?? '0'; # 缓存时间,如果需要开启缓存,这个字段必须传,而且必须大于0
|
||||
$d_key ?? 'd_key'; # 查询出来的数据遍历的时候, 下标键变量的名称
|
||||
$d_val ?? 'd_val'; # 查询出来的数据遍历的时候, 值的名称
|
||||
$p_val ?? 'p_val'; # 分页页码数据,这是一个数组。和之前控制器渲染的那个数组一致的。
|
||||
$func ; # 这个参数是一个回调方法名,用来渲染分页页码数据的,该方法需要在 NovelService 类里面实现,func(array $arrParams, array $arrSort, array $arrNovel)
|
||||
# 样例
|
||||
{chapter:pager page="1" limit="10" n_id="$Request.get.n_id" d_key="d_key" d_val="chapter" cache_life="1000" button_num="3" sort_type="dao" func="generateChapterPager"}
|
||||
<li>
|
||||
Index: {$d_key}
|
||||
章节名称: {$chapter.c_name}
|
||||
章节序号: {$chapter.c_sort_num}
|
||||
</li>
|
||||
{/chapter:pager}
|
||||
|
||||
# 12、 获取干扰码
|
||||
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||
|
||||
$page_code ?? ""; # 页面编码
|
||||
$diff ?? ""; # 差异值
|
||||
$limit ?? '1'; # 查询条数
|
||||
# 样例
|
||||
{site:grm page_code="fdasfadsf" diff="fadsfdsa" num="10" g_key="arrGrm" /}
|
||||
{php}var_dump($arrGrm);{/php}
|
||||
```
|
||||
Reference in New Issue
Block a user