fix
This commit is contained in:
@@ -131,16 +131,26 @@ class ConfigSubjectFomartModel extends MongoModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据小说ID查询指定小说
|
* 根据CSFKEY 获取模板数据
|
||||||
*
|
*
|
||||||
* @param integer $intNId
|
* @param string $strCsfKey
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getConfigSubjectFomartByCsfKey(string $intNId): null|array
|
public function getConfigSubjectFomartByCsfKey(string $strCsfKey): null|array
|
||||||
{
|
{
|
||||||
$arrFilter = ['csf_key' => $intNId];
|
$arrFilter = ['csf_key' => $strCsfKey];
|
||||||
return $this->findOne($arrFilter);
|
return $this->findOne($arrFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据CSFKEY 删除数据
|
||||||
|
*
|
||||||
|
* @param string $strCsfKey
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function delConfigSubjectFomartByCsfKey(string $strCsfKey): int
|
||||||
|
{
|
||||||
|
$arrFilter = ['csf_key' => $strCsfKey];
|
||||||
|
return $this->delete($arrFilter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ class DomainModel extends BaseModel
|
|||||||
|
|
||||||
$arrAllSubjectFomartModel = SubjectFomartModel::getAllSubjectFomartOnCacheBySfgId($intSfgId);
|
$arrAllSubjectFomartModel = SubjectFomartModel::getAllSubjectFomartOnCacheBySfgId($intSfgId);
|
||||||
if (empty($arrAllSubjectFomartModel)) {
|
if (empty($arrAllSubjectFomartModel)) {
|
||||||
return '';
|
$strError = sprintf("subject fomart [%s] not found !", $strKey);
|
||||||
|
throw new \Exception($strError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($boolJoin) {
|
if ($boolJoin) {
|
||||||
@@ -136,9 +137,20 @@ class DomainModel extends BaseModel
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# FIX 补丁,用于修复站点配置发生修改,但MONGO记录的数据无法找到MYSQL配置数据发生的异常
|
||||||
|
if ($SubjectFomartModel == NULL && count($arrAllSubjectFomartModel) > 0) {
|
||||||
|
ConfigSubjectFomartModel::getInstance()->delConfigSubjectFomartByCsfKey($strUUId);
|
||||||
|
return $this->getFomartSubjectEx($strKey, $strDomain, $strController, $strAction, $strDiff, $boolJoin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $SubjectFomartModel->sf_val ?? '';
|
if (empty($SubjectFomartModel)) {
|
||||||
|
$strError = sprintf("subject fomart [%s] not found !", $strKey);
|
||||||
|
throw new \Exception($strError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $SubjectFomartModel->sf_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -133,7 +133,6 @@ abstract class MongoModel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新单条数据
|
* 更新单条数据
|
||||||
* @param string $strColName 集合名称
|
|
||||||
* @param array $arrFilter 查询条件
|
* @param array $arrFilter 查询条件
|
||||||
* @param array $arrUpdate 更新内容
|
* @param array $arrUpdate 更新内容
|
||||||
* @param array $arrOptions 更新选项
|
* @param array $arrOptions 更新选项
|
||||||
@@ -144,4 +143,27 @@ abstract class MongoModel
|
|||||||
$Result = $this->getCol()->updateOne($arrFilter, $arrUpdate, $arrOptions);
|
$Result = $this->getCol()->updateOne($arrFilter, $arrUpdate, $arrOptions);
|
||||||
return $Result->getModifiedCount();
|
return $Result->getModifiedCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除单条数据
|
||||||
|
* @param array $arrFilter 查询条件
|
||||||
|
* @return int 受影响的文档数
|
||||||
|
*/
|
||||||
|
public function deleteOne(array $arrFilter, array $arrOptions = []): int
|
||||||
|
{
|
||||||
|
$Result = $this->getCol()->deleteOne($arrFilter, $arrOptions);
|
||||||
|
return $Result->getDeletedCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除多条数据
|
||||||
|
* @param array $arrFilter 查询条件
|
||||||
|
* @return int 受影响的文档数
|
||||||
|
*/
|
||||||
|
public function delete(array $arrFilter, array $arrOptions = []): int
|
||||||
|
{
|
||||||
|
$Result = $this->getCol()->deleteMany($arrFilter, $arrOptions);
|
||||||
|
return $Result->getDeletedCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class VideoModel extends MongoModel
|
|||||||
/**
|
/**
|
||||||
* 直接读库查询大量小说
|
* 直接读库查询大量小说
|
||||||
*
|
*
|
||||||
* @param integer $intNId
|
* @param integer $intVId
|
||||||
* @return null|array
|
* @return null|array
|
||||||
*/
|
*/
|
||||||
public function findMany(array $arrFilter, int $intCount = 10, array $arrSort = [], array $arrOptions = []): null|array
|
public function findMany(array $arrFilter, int $intCount = 10, array $arrSort = [], array $arrOptions = []): null|array
|
||||||
@@ -170,12 +170,12 @@ class VideoModel extends MongoModel
|
|||||||
/**
|
/**
|
||||||
* 根据小说ID查询指定小说
|
* 根据小说ID查询指定小说
|
||||||
*
|
*
|
||||||
* @param integer $intNId
|
* @param integer $intVId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getVideoByNId(int $intNId): null|array
|
public function getVideoByVId(int $intVId): null|array
|
||||||
{
|
{
|
||||||
$arrFilter = ['v_id' => $intNId];
|
$arrFilter = ['v_id' => $intVId];
|
||||||
return $this->findOne($arrFilter);
|
return $this->findOne($arrFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,12 +439,12 @@ class VideoModel extends MongoModel
|
|||||||
|
|
||||||
$Cursor = $VideoClicksModel->getCol()->find($arrFilter, $arrOptions);
|
$Cursor = $VideoClicksModel->getCol()->find($arrFilter, $arrOptions);
|
||||||
|
|
||||||
$arrNId = [];
|
$arrVId = [];
|
||||||
foreach ($Cursor as $Doc) {
|
foreach ($Cursor as $Doc) {
|
||||||
$arrNId[] = $Doc['v_id'];
|
$arrVId[] = $Doc['v_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$arrFilter = ['v_id' => ['$in' => $arrNId]];
|
$arrFilter = ['v_id' => ['$in' => $arrVId]];
|
||||||
$arrOptions = self::$arrOptions;
|
$arrOptions = self::$arrOptions;
|
||||||
unset($arrOptions['typeMap']);
|
unset($arrOptions['typeMap']);
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,19 @@ class StaticConfig
|
|||||||
'dao' => '倒叙',
|
'dao' => '倒叙',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
static $arrVideoStatus = [
|
||||||
|
'all' => '所有',
|
||||||
|
'lianzai' => '连载中',
|
||||||
|
'wanjie' => '已完结',
|
||||||
|
];
|
||||||
|
|
||||||
|
static $arrVideoSortType = [
|
||||||
|
'all' => '全部排序',
|
||||||
|
'news' => '最新入库',
|
||||||
|
'tuijian' => '推荐',
|
||||||
|
'update' => '最新更新',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetCategoryFilter
|
* GetCategoryFilter
|
||||||
*
|
*
|
||||||
|
|||||||
579
code/app/services/VideoService.php
Normal file
579
code/app/services/VideoService.php
Normal file
@@ -0,0 +1,579 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\services;
|
||||||
|
|
||||||
|
use app\model\CategoryModel;
|
||||||
|
use app\model\ChapterModel;
|
||||||
|
use app\model\ConverterMovel;
|
||||||
|
use app\model\DomainModel;
|
||||||
|
use app\model\VideoClicksModel;
|
||||||
|
use app\model\VideoModel;
|
||||||
|
use template\page\CusteomPage02;
|
||||||
|
|
||||||
|
class VideoService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* SiteContext
|
||||||
|
*
|
||||||
|
* @var SiteContext
|
||||||
|
*/
|
||||||
|
public $SiteContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VideoModel
|
||||||
|
*
|
||||||
|
* @var VideoModel
|
||||||
|
*/
|
||||||
|
public $VideoModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VideoClicksModel
|
||||||
|
*
|
||||||
|
* @var VideoClicksModel
|
||||||
|
*/
|
||||||
|
public $VideoClicksModel;
|
||||||
|
|
||||||
|
public function __construct(SiteContext $SiteContext)
|
||||||
|
{
|
||||||
|
$this->SiteContext = $SiteContext;
|
||||||
|
$this->VideoModel = VideoModel::getInstance();
|
||||||
|
$this->VideoClicksModel = VideoClicksModel::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @param int $intVId
|
||||||
|
* @param string $intPinYin
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getVideoInfoUrl($intVId, $intPinYin): string
|
||||||
|
{
|
||||||
|
$strKey = 'VIDEO_INFO_URL';
|
||||||
|
$strUrl = $this->SiteContext->DomainModel->getFomartUrl($strKey, [
|
||||||
|
'intVId' => $intVId,
|
||||||
|
'strPinYin' => $intPinYin
|
||||||
|
]);
|
||||||
|
return (string)$strUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取小说分类URl
|
||||||
|
*
|
||||||
|
* @param string $strGender
|
||||||
|
* @param string $strCategory
|
||||||
|
* @param string $strStatus
|
||||||
|
* @param string $strOrder
|
||||||
|
* @param integer $intPage
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getVideoCategoryUrl(string|NULL $strGender, string|NULL $strCategory, string|NULL $strStatus, string|NULL $strOrder, int|string|NULL $intPage): string
|
||||||
|
{
|
||||||
|
$strKey = 'CATEGORY_INFO_URL';
|
||||||
|
$strUrl = $this->SiteContext->DomainModel->getFomartUrl($strKey, [
|
||||||
|
'strGender' => !empty($strGender) ? $strGender : '',
|
||||||
|
'strCategory' => !empty($strCategory) ? $strCategory : 'all',
|
||||||
|
'strStatus' => !empty($strStatus) ? $strStatus : 'all',
|
||||||
|
'strOrder' => !empty($strOrder) ? $strOrder : 'all',
|
||||||
|
'intPage' => $intPage ?? 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$strUrl = preg_replace('#/{2,}#', '/', $strUrl);
|
||||||
|
return (string)$strUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排行榜url
|
||||||
|
*
|
||||||
|
* @param string $strGender
|
||||||
|
* @param string $strCategory
|
||||||
|
* @param string $strStatus
|
||||||
|
* @param string $strOrder
|
||||||
|
* @param integer $intPage
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getVideoRankUrl(string $strGender, string $strCategory, string $strStatus, string $strOrder, int $intPage): string
|
||||||
|
{
|
||||||
|
|
||||||
|
$strKey = 'RANK_LIST_URL';
|
||||||
|
$strUrl = $this->SiteContext->DomainModel->getFomartUrl($strKey, [
|
||||||
|
'strGender' => !empty($strGender) ? $strGender : '',
|
||||||
|
'strCategory' => !empty($strCategory) ? $strCategory : 'all',
|
||||||
|
'strStatus' => !empty($strStatus) ? $strStatus : 'all',
|
||||||
|
'strOrder' => !empty($strOrder) ? $strOrder : 'all',
|
||||||
|
'intPage' => $intPage ?? 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$strUrl = preg_replace('#/{2,}#', '/', $strUrl);
|
||||||
|
return (string)$strUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
* 小说目录
|
||||||
|
* @param int $intVId
|
||||||
|
* @param string $intPinYin
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getVideoCatalogUrl($intVId, $intPinYin, $strOrder, $intPage = 1): string
|
||||||
|
{
|
||||||
|
$strKey = 'VIDEO_CATALOG_URL';
|
||||||
|
$strUrl = $this->SiteContext->DomainModel->getFomartUrl($strKey, [
|
||||||
|
'intVId' => $intVId,
|
||||||
|
'strPinYin' => $intPinYin,
|
||||||
|
'strOrder' => $strOrder,
|
||||||
|
'intPage' => $intPage,
|
||||||
|
]);
|
||||||
|
return (string)$strUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @param int $intPage
|
||||||
|
* @param string $strKeyWords
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getVideoSearchUrl($strKeyWords, $intPage = 1): string
|
||||||
|
{
|
||||||
|
$strKey = 'SEARCH_INFO_URL';
|
||||||
|
$strUrl = $this->SiteContext->DomainModel->getFomartUrl($strKey, [
|
||||||
|
'intPage' => $intPage,
|
||||||
|
'strSearchKeywords' => $strKeyWords
|
||||||
|
]);
|
||||||
|
return (string)$strUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取排行榜小说
|
||||||
|
*
|
||||||
|
* @param array $arrParams
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getRankList(array $arrParams): array
|
||||||
|
{
|
||||||
|
$intCount = (int)$arrParams['count'] ?? 10;
|
||||||
|
$strSortType = (string)$arrParams['sort_type'] ?? '';
|
||||||
|
$strNStatus = (string) $arrParams['v_isend'] ?? '';
|
||||||
|
|
||||||
|
$strDiffKey = (string) $arrParams['diff_key'] ?? '';
|
||||||
|
$intCacheLifeTime = (int)$arrParams['cache_life'] ?? 0;
|
||||||
|
|
||||||
|
$arrFilter = [];
|
||||||
|
|
||||||
|
# v_isend filter
|
||||||
|
if (!empty($strNStatus)) {
|
||||||
|
switch ($strNStatus) {
|
||||||
|
case 'lianzai':
|
||||||
|
$arrFilter['v_isend'] = 0;
|
||||||
|
break;
|
||||||
|
case 'wanjie':
|
||||||
|
$arrFilter['v_isend'] = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$arrSort = [];
|
||||||
|
|
||||||
|
# sort filter
|
||||||
|
if (!empty($strSortType)) {
|
||||||
|
switch ($strSortType) {
|
||||||
|
case 'daily':
|
||||||
|
$arrSort['v_sort_type'] = 'daily';
|
||||||
|
break;
|
||||||
|
case 'weekly':
|
||||||
|
$arrSort['v_sort_type'] = 'weekly';
|
||||||
|
break;
|
||||||
|
case 'monthly':
|
||||||
|
$arrSort['v_sort_type'] = 'monthly';
|
||||||
|
break;
|
||||||
|
case 'total':
|
||||||
|
$arrSort['v_sort_type'] = 'total';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$strCacheKey = '';
|
||||||
|
$intLifeTime = 0;
|
||||||
|
|
||||||
|
# cache filter
|
||||||
|
if ($intCacheLifeTime > 0) {
|
||||||
|
$strCacheKey = sprintf(
|
||||||
|
'VideoService:getRankList:%s:%s:%s:%s:%s',
|
||||||
|
$this->SiteContext->DomainModel->d_domain,
|
||||||
|
md5(serialize($arrFilter)),
|
||||||
|
md5(serialize($arrSort)),
|
||||||
|
$intCount,
|
||||||
|
$strDiffKey,
|
||||||
|
);
|
||||||
|
|
||||||
|
$intLifeTime = $intLifeTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrVideo = $this->VideoModel->getRankVideoOnCache(
|
||||||
|
$strCacheKey,
|
||||||
|
$intCount,
|
||||||
|
$arrFilter['v_category_sex_zh'] ?? 0,
|
||||||
|
$arrSort['v_sort_type'] ?? 'daily',
|
||||||
|
$arrFilter['v_isend'] ?? NULL,
|
||||||
|
$intLifeTime,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $arrVideo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取小说数据
|
||||||
|
*
|
||||||
|
* @param array $arrParams
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getVideoList(array $arrParams): array
|
||||||
|
{
|
||||||
|
$intCount = (int)$arrParams['count'] ?? 10;
|
||||||
|
$strNCategory = $arrParams['v_category'] ?? '';
|
||||||
|
$strSortType = (string)$arrParams['sort_type'] ?? '';
|
||||||
|
$strNStatus = (string) $arrParams['v_isend'] ?? '';
|
||||||
|
|
||||||
|
$strDiffKey = (string) $arrParams['diff_key'] ?? '';
|
||||||
|
$intCacheLifeTime = (int)$arrParams['cache_life'] ?? 0;
|
||||||
|
|
||||||
|
$arrFilter = [];
|
||||||
|
|
||||||
|
# v_category filter
|
||||||
|
if (!empty($strNCategory)) {
|
||||||
|
$strNCategory = CategoryModel::getZhByPinYin($strNCategory);
|
||||||
|
if ($strNCategory) {
|
||||||
|
$arrFilter['v_category'] = $strNCategory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# v_isend filter
|
||||||
|
if (!empty($strNStatus)) {
|
||||||
|
switch ($strNStatus) {
|
||||||
|
case 'lianzai':
|
||||||
|
$arrFilter['v_isend'] = StaticConfig::$arrVideoStatus[$strNStatus];
|
||||||
|
break;
|
||||||
|
case 'wanjie':
|
||||||
|
$arrFilter['v_isend'] = StaticConfig::$arrVideoStatus[$strNStatus];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$arrSort = [];
|
||||||
|
|
||||||
|
# sort filter
|
||||||
|
if (!empty($strSortType)) {
|
||||||
|
switch ($strSortType) {
|
||||||
|
case 'news':
|
||||||
|
$arrSort['created_at'] = -1;
|
||||||
|
break;
|
||||||
|
case 'tuijian':
|
||||||
|
$arrSort['v_level'] = -1;
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
$arrSort['v_update_time'] = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$strCacheKey = '';
|
||||||
|
$intLifeTime = 0;
|
||||||
|
|
||||||
|
# cache filter
|
||||||
|
if ($intCacheLifeTime > 0) {
|
||||||
|
$strCacheKey = sprintf(
|
||||||
|
'VideoService:getVideoList:%s:%s:%s:%s:%s',
|
||||||
|
$this->SiteContext->DomainModel->d_domain,
|
||||||
|
md5(serialize($arrFilter)),
|
||||||
|
md5(serialize($arrSort)),
|
||||||
|
$intCount,
|
||||||
|
$strDiffKey,
|
||||||
|
);
|
||||||
|
|
||||||
|
$intLifeTime = $intLifeTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrVideo = $this->VideoModel->findManyShuffledWithCache(
|
||||||
|
$arrFilter,
|
||||||
|
$intCount,
|
||||||
|
$arrSort,
|
||||||
|
$strCacheKey,
|
||||||
|
$intLifeTime,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $arrVideo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取小说分页数据
|
||||||
|
*
|
||||||
|
* @param array $arrParams
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getVideoPager(array $arrParams): array
|
||||||
|
{
|
||||||
|
$arrParams = [
|
||||||
|
'page' => max((int)($arrParams['page'] ?? 1), 1),
|
||||||
|
'limit' => (int)($arrParams['limit'] ?? 10),
|
||||||
|
'buttov_num' => (int)($arrParams['buttov_num'] ?? 0),
|
||||||
|
'v_category' => (string)($arrParams['v_category'] ?? ''),
|
||||||
|
'sort_type' => (string)($arrParams['sort_type'] ?? ''),
|
||||||
|
'v_isend' => (string)($arrParams['v_isend'] ?? ''),
|
||||||
|
'v_sex' => (string)($arrParams['v_sex'] ?? ''),
|
||||||
|
'diff_key' => (string)($arrParams['diff_key'] ?? ''),
|
||||||
|
'key' => (string)($arrParams['key'] ?? ''),
|
||||||
|
'cache_life' => (int)($arrParams['cache_life'] ?? 0),
|
||||||
|
'func' => (string)($arrParams['func']),
|
||||||
|
];
|
||||||
|
|
||||||
|
$intPage = $arrParams['page'];
|
||||||
|
$intLimit = $arrParams['limit'];
|
||||||
|
$strNCategory = $arrParams['v_category'];
|
||||||
|
$strSortType = $arrParams['sort_type'];
|
||||||
|
$strNStatus = $arrParams['v_isend'];
|
||||||
|
|
||||||
|
$strDiffKey = $arrParams['diff_key'];
|
||||||
|
$strKey = $arrParams['key'];
|
||||||
|
$intCacheLifeTime = $arrParams['cache_life'];
|
||||||
|
$Func = $arrParams['func'];
|
||||||
|
|
||||||
|
if ($intPage <= 0) {
|
||||||
|
$intPage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrFilter = [
|
||||||
|
'$and' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
# v_category filter
|
||||||
|
if (!empty($strNCategory)) {
|
||||||
|
$strNCategory = CategoryModel::getZhByPinYin($strNCategory);
|
||||||
|
if ($strNCategory) {
|
||||||
|
$arrFilter['$and'][] = ['v_category' => $strNCategory];
|
||||||
|
} else {
|
||||||
|
$arrParams['v_category'] = 'all';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# v_isend filter
|
||||||
|
if (!empty($strNStatus)) {
|
||||||
|
switch ($strNStatus) {
|
||||||
|
case 'lianzai':
|
||||||
|
$arrFilter['$and'][] = ['v_isend' => StaticConfig::$arrVideoStatus[$strNStatus]];
|
||||||
|
break;
|
||||||
|
case 'wanjie':
|
||||||
|
$arrFilter['$and'][] = ['v_isend' => StaticConfig::$arrVideoStatus[$strNStatus]];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$arrParams['v_isend'] = 'all';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# key filter
|
||||||
|
if (!empty($strKey)) {
|
||||||
|
|
||||||
|
$strKey = mb_substr($strKey, 0, 30);
|
||||||
|
$arrFilter['$and'][] = [
|
||||||
|
'$or' => [
|
||||||
|
['v_name' => ['$regex' => $strKey, '$options' => 'i']],
|
||||||
|
['v_author' => ['$regex' => $strKey, '$options' => 'i']],
|
||||||
|
['v_category' => ['$regex' => $strKey, '$options' => 'i']],
|
||||||
|
['v_description' => ['$regex' => $strKey, '$options' => 'i']],
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$arrParams['key'] = $strKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrSort = [];
|
||||||
|
|
||||||
|
# sort filter
|
||||||
|
if (!empty($strSortType)) {
|
||||||
|
switch ($strSortType) {
|
||||||
|
case 'news':
|
||||||
|
$arrSort['created_at'] = -1;
|
||||||
|
break;
|
||||||
|
case 'tuijian':
|
||||||
|
$arrSort['v_level'] = -1;
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
$arrSort['v_update_time'] = -1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$arrParams['sort_type'] = 'all';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$strCacheKey = '';
|
||||||
|
$intLifeTime = 0;
|
||||||
|
|
||||||
|
# cache filter
|
||||||
|
if ($intCacheLifeTime > 0) {
|
||||||
|
$strCacheKey = sprintf(
|
||||||
|
'VideoService:getVideoList:%s:%s:%s:%s:%s:%s',
|
||||||
|
$this->SiteContext->DomainModel->d_domain,
|
||||||
|
md5(serialize($arrFilter)),
|
||||||
|
md5(serialize($arrSort)),
|
||||||
|
$intPage,
|
||||||
|
$intLimit,
|
||||||
|
$strDiffKey,
|
||||||
|
);
|
||||||
|
|
||||||
|
$intLifeTime = $intLifeTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新值
|
||||||
|
$strGender = $this->SiteContext->Request->param('strGender');
|
||||||
|
$strNanUrlTemp = $this->SiteContext->DomainModel->getFomartSubject('NAN_SHENG_URL', '', false);
|
||||||
|
$strNanUrl = str_replace("/", "", $strNanUrlTemp);
|
||||||
|
$strCNSex = '全部';
|
||||||
|
if ($strGender) {
|
||||||
|
$strCNSex = $strGender == $strNanUrl ? '男生' : '女生';
|
||||||
|
}
|
||||||
|
ConverterMovel::setVal([
|
||||||
|
'intPage' => $intPage,
|
||||||
|
'strVideoSex' => $strCNSex,
|
||||||
|
'strVideoCategoryName' => empty($strNCategory) ? '' : str_replace("小说", "", $strNCategory),
|
||||||
|
'strVideoStatus' => empty($strNStatus) ? '' : StaticConfig::$arrVideoStatus[$strNStatus],
|
||||||
|
'strVideoOrder' => empty($strSortType) ? '' : StaticConfig::$arrVideoSortType[$strSortType],
|
||||||
|
'strSearchKeywords' => $strKey,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (empty($arrFilter['$and'])) {
|
||||||
|
$arrFilter = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrVideo = $this->VideoModel->findPaginatedWithCache(
|
||||||
|
$arrFilter,
|
||||||
|
$intPage,
|
||||||
|
$intLimit,
|
||||||
|
$arrSort,
|
||||||
|
$strCacheKey,
|
||||||
|
$intLifeTime,
|
||||||
|
);
|
||||||
|
|
||||||
|
$arrPager = $arrVideo;
|
||||||
|
unset($arrPager['data']);
|
||||||
|
$arrPager['pager'] = call_user_func([$this, $Func], $arrParams, $arrSort, $arrVideo);
|
||||||
|
|
||||||
|
$arrResult = [
|
||||||
|
'data' => $arrVideo['data'],
|
||||||
|
'p_data' => $arrPager,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $arrResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索定制分页
|
||||||
|
*
|
||||||
|
* @param array $arrFilter 查询条件字段
|
||||||
|
* @param array $arrSort 查询排序字段
|
||||||
|
* @param array $arrVideo 查询出来的数据
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function generateSearchPager(array $arrParams, array $arrSort, array $arrVideo): array
|
||||||
|
{
|
||||||
|
$strKey = $arrParams['key'];
|
||||||
|
$intPage = $arrVideo['page'];
|
||||||
|
$intLimit = $arrVideo['limit'];
|
||||||
|
$intButtomNum = $arrParams['buttov_num'];
|
||||||
|
$strBaseUrl = app(VideoService::class)->getVideoSearchUrl($strKey, '{page}');
|
||||||
|
$arrPaginator = CusteomPage02::generate($intPage, $arrVideo['total'], $intLimit, $strBaseUrl, $intButtomNum);
|
||||||
|
|
||||||
|
return $arrPaginator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 书库/分类定制分页
|
||||||
|
*
|
||||||
|
* @param array $arrFilter 查询条件字段
|
||||||
|
* @param array $arrSort 查询排序字段
|
||||||
|
* @param array $arrVideo 查询出来的数据
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function generateCategoryPager(array $arrParams, array $arrSort, array $arrVideo): array
|
||||||
|
{
|
||||||
|
$strGender = $arrParams['v_sex'];
|
||||||
|
$strCategory = $arrParams['v_category'];
|
||||||
|
$strStatus = $arrParams['v_isend'];
|
||||||
|
$strOrder = $arrParams['sort_type'];
|
||||||
|
$intPage = $arrVideo['page'] ?? 1;
|
||||||
|
$intLimit = $arrVideo['limit'] ?? 10;
|
||||||
|
$intTotal = $arrVideo['total'] ?? 0;
|
||||||
|
$intButtomNum = $arrParams['buttov_num'];
|
||||||
|
$strBaseUrl = $this->getVideoCategoryUrl($strGender, $strCategory, $strStatus, $strOrder, '{page}');
|
||||||
|
|
||||||
|
$arrPaginator = CusteomPage02::generate($intPage, $intTotal, $intLimit, $strBaseUrl, $intButtomNum);
|
||||||
|
|
||||||
|
return $arrPaginator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据VId获取小说详情
|
||||||
|
*
|
||||||
|
* @param integer $intVId
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getVideoByVId(int $intVId, int|null $intNForgeId = 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
// 小说详情
|
||||||
|
$arrVideo = $this->VideoModel->getVideoByVId($intVId);
|
||||||
|
|
||||||
|
if ($intNForgeId > 0) {
|
||||||
|
foreach ($arrVideo['v_forge_novel'] as $arrForgeVideo) {
|
||||||
|
if ($arrForgeVideo['v_forge_id'] == $intNForgeId) {
|
||||||
|
$arrVideo['v_name'] = $arrForgeVideo['v_forge_title'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分类拼音
|
||||||
|
$arrVideo['v_category_pinyin'] = CategoryModel::getPinYin($arrVideo['v_category']);
|
||||||
|
$arrVideo['v_category_sex_en'] = $arrVideo['v_category_sex_en'] ?? 'man';
|
||||||
|
|
||||||
|
// 点击数
|
||||||
|
$arrVideoClicks = $this->VideoClicksModel->getStats($intVId);
|
||||||
|
|
||||||
|
// 推荐小说
|
||||||
|
$arrRelateveVId = array_column($arrVideo['v_related_novel'], 'v_id');
|
||||||
|
|
||||||
|
$arrRelateveVideo = $this->VideoModel->findMany(['v_id' => [
|
||||||
|
'$in' => $arrRelateveVId,
|
||||||
|
]], 10);
|
||||||
|
|
||||||
|
|
||||||
|
// 更新值
|
||||||
|
ConverterMovel::setVal([
|
||||||
|
'intPage' => 1,
|
||||||
|
'strVideoName' => $arrVideo['v_name'],
|
||||||
|
'strVideoAuthor' => $arrVideo['v_author'],
|
||||||
|
'strVideoCategoryName' => $arrVideo['v_category'],
|
||||||
|
'strVideoSex' => $arrVideo['v_category_sex_en'] == 'man' ? '男生' : '女生',
|
||||||
|
'strVideoStatus' => $arrVideo['v_isend'],
|
||||||
|
'strVideoDescription' => $arrVideo['v_description'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$arrVideo['arrVideoClicks'] = $arrVideoClicks;
|
||||||
|
$arrVideo['arrRelateveVideo'] = $arrRelateveVideo;
|
||||||
|
|
||||||
|
|
||||||
|
return $arrVideo;
|
||||||
|
}
|
||||||
|
}
|
||||||
433
code/extend/template/taglib/Video.php
Normal file
433
code/extend/template/taglib/Video.php
Normal file
@@ -0,0 +1,433 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace template\taglib;
|
||||||
|
|
||||||
|
use think\template\TagLib;
|
||||||
|
|
||||||
|
class Video 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_forge_id,n_key', 'close' => 0],
|
||||||
|
'sort' => ['attr' => 'd_key,d_val'],
|
||||||
|
'ranksort' => ['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\\VideoService::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\\VideoService::class)->getVideoPager([
|
||||||
|
'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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
$arrDataName = randomString(5);
|
||||||
|
|
||||||
|
$strParse = <<<EOT
|
||||||
|
<?php
|
||||||
|
\${$arrDataName} = app(\\app\\services\\VideoService::class)->getVideoList([
|
||||||
|
'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 = isset($tag['n_forge_id']) ? $tag['n_forge_id'] : 0;
|
||||||
|
|
||||||
|
$n_key = $tag['n_key'] ?? 'arrVideo';
|
||||||
|
|
||||||
|
$n_id = $this->customBuildVar($n_id);
|
||||||
|
$n_forge_id = $this->customBuildVar($n_forge_id);
|
||||||
|
|
||||||
|
$strParse = <<<EOT
|
||||||
|
<?php
|
||||||
|
\$novelData = app(\\app\\services\\VideoService::class)->getVideoByNId(
|
||||||
|
{$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\\StaticConfig::class)::\$arrVideoSortType;
|
||||||
|
|
||||||
|
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 tagRankSort($tag, $content)
|
||||||
|
{
|
||||||
|
|
||||||
|
$d_key = $tag['d_key'] ?? 'd_key';
|
||||||
|
$d_val = $tag['d_val'] ?? 'd_val';
|
||||||
|
|
||||||
|
$strParse = <<<EOT
|
||||||
|
<?php
|
||||||
|
\$arrSort = app(\\app\\services\\StaticConfig::class)::\$arrVideoRankSortType;
|
||||||
|
|
||||||
|
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\\StaticConfig::class)::\$arrVideoStatus;
|
||||||
|
|
||||||
|
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\\StaticConfig::class)::\$arrVideoSex;
|
||||||
|
|
||||||
|
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\\services\\StaticConfig::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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user