Merge branch 'dev' of ssh://git.bgbg.live:18150/root/SEONexus into dev
This commit is contained in:
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