reset
This commit is contained in:
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace db;
|
||||
|
||||
use database\seeders\SeedManager;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\Output;
|
||||
use think\console\input\Option;
|
||||
use think\facade\Db;
|
||||
|
||||
class DatabaseManage extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('db:manage')
|
||||
->addArgument('action', \think\console\input\Argument::OPTIONAL, 'The action to perform: backup or init or seed')
|
||||
->setDescription('Manage the database: backup or initialize');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $Output)
|
||||
{
|
||||
$strAction = $input->getArgument('action');
|
||||
|
||||
if ($strAction === 'backup') {
|
||||
$this->backupDatabase($Output);
|
||||
} elseif ($strAction === 'init') {
|
||||
$this->initializeDatabase($Output);
|
||||
} elseif ($strAction === 'seed') {
|
||||
$this->seed($Output);
|
||||
} else {
|
||||
$Output->writeln("Invalid action. Use 'backup' or 'init'. or 'seed'");
|
||||
}
|
||||
}
|
||||
|
||||
private function seed(Output $Output)
|
||||
{
|
||||
$SeedManager = new SeedManager;
|
||||
$Output->writeln("开始数据播种" . PHP_EOL);
|
||||
$SeedManager->handle();
|
||||
$Output->writeln("数据播种结束");
|
||||
}
|
||||
|
||||
private function backupDatabase(Output $Output)
|
||||
{
|
||||
$arrConfig = config('database.connections.mysql');
|
||||
$strDb = $arrConfig['database'];
|
||||
$strUserName = $arrConfig['username'];
|
||||
$strPwd = $arrConfig['password'];
|
||||
$strHost = $arrConfig['hostname'];
|
||||
$strBackupFile = app()->getRootPath() . 'database/schema/mysql-schema.dump';
|
||||
|
||||
$strTempFile = tempnam(sys_get_temp_dir(), 'mysql-schema-') . '.dump';
|
||||
|
||||
$strCmd = "mysqldump -h{$strHost} -u{$strUserName} -p{$strPwd} --no-data {$strDb} > {$strTempFile}";
|
||||
|
||||
system($strCmd, $intResultCode);
|
||||
|
||||
if ($intResultCode === 0) {
|
||||
if (file_exists($strBackupFile)) {
|
||||
unlink($strBackupFile);
|
||||
}
|
||||
|
||||
if (rename($strTempFile, $strBackupFile)) {
|
||||
$Output->writeln("Database backup successful: {$strBackupFile}");
|
||||
} else {
|
||||
$Output->writeln("Failed to move backup file to destination.");
|
||||
}
|
||||
} else {
|
||||
$Output->writeln("Database backup failed.");
|
||||
unlink($strTempFile);
|
||||
}
|
||||
}
|
||||
|
||||
private function initializeDatabase(Output $Output)
|
||||
{
|
||||
$arrConfig = config('database.connections.mysql');
|
||||
$strDb = $arrConfig['database'];
|
||||
$strUserName = $arrConfig['username'];
|
||||
$strPwd = $arrConfig['password'];
|
||||
$strHost = $arrConfig['hostname'];
|
||||
$strPort = $arrConfig['hostport'];
|
||||
$strBackupFile = app()->getRootPath() . 'database/schema/mysql-schema.dump';
|
||||
|
||||
$checkTableQuery = "SHOW TABLES LIKE 'migrations'";
|
||||
$boolMigrateExists = Db::query($checkTableQuery);
|
||||
|
||||
if (!empty($boolMigrateExists)) {
|
||||
$Output->writeln("数据库已存在,跳过初始化导入");
|
||||
return;
|
||||
}
|
||||
|
||||
$strTempFile = tempnam(sys_get_temp_dir(), 'mysql-schema-') . '.dump';
|
||||
|
||||
if (!copy($strBackupFile, $strTempFile)) {
|
||||
$Output->writeln("创建临时导入文件失败.");
|
||||
return;
|
||||
}
|
||||
|
||||
$strCmd = "mysql -h{$strHost} -P{$strPort} -u{$strUserName} -p{$strPwd} {$strDb} < {$strTempFile}";
|
||||
|
||||
system($strCmd, $intResultCode);
|
||||
|
||||
if ($intResultCode === 0) {
|
||||
$Output->writeln("成功导入初始化文件");
|
||||
} else {
|
||||
$Output->writeln("初始化文件导入失败");
|
||||
}
|
||||
|
||||
unlink($strTempFile);
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace db;
|
||||
|
||||
use db\mongo\MongoBase;
|
||||
use ddl\DDLManage;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
|
||||
class MongoMigrate extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('mongo:manage')
|
||||
->addArgument('action', \think\console\input\Argument::OPTIONAL, 'The action to perform: migrate')
|
||||
->setDescription('Manage the mongo, migarte index or drop all index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param Input $input
|
||||
* @param Output $Output
|
||||
* @return void
|
||||
*/
|
||||
protected function execute(Input $input, Output $Output)
|
||||
{
|
||||
$strAction = $input->getArgument('action');
|
||||
|
||||
if ($strAction === 'migrate') {
|
||||
$this->migrate($Output);
|
||||
} else if ($strAction === 'drop') {
|
||||
$this->dropAllIndexes($Output);
|
||||
} else {
|
||||
$Output->writeln("Invalid action. Use 'migrate' or 'drop'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param Output $Output
|
||||
* @return void
|
||||
*/
|
||||
protected function dropAllIndexes(Output $Output)
|
||||
{
|
||||
try {
|
||||
DDLManage::load('MongoBase');
|
||||
$Db = MongoBase::getInstance()->getDb();
|
||||
|
||||
$ColsInfo = $Db->listCollections();
|
||||
|
||||
foreach ($ColsInfo as $ColInfo) {
|
||||
$strColName = $ColInfo->getName();
|
||||
$Col = $Db->selectCollection($strColName);
|
||||
|
||||
|
||||
$arrIndexes = iterator_to_array($Col->listIndexes());
|
||||
$arrIndexesToDrop = [];
|
||||
|
||||
|
||||
foreach ($arrIndexes as $Index) {
|
||||
$strIndexName = $Index->getName();
|
||||
if ($strIndexName !== '_id_') {
|
||||
$arrIndexesToDrop[] = $strIndexName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($arrIndexesToDrop)) {
|
||||
foreach ($arrIndexesToDrop as $strIndexName) {
|
||||
$Col->dropIndex($strIndexName);
|
||||
$Output->writeln(" Dropped index: {$strIndexName} from collection: {$strColName}");
|
||||
}
|
||||
} else {
|
||||
$Output->writeln(" No non-_id indexes found in collection: {$strColName}");
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$Output->writeln("<error>Failed to drop indexes: {$e->getMessage()}</error>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param Output $Output
|
||||
* @return void
|
||||
*/
|
||||
protected function migrate(Output $Output)
|
||||
{
|
||||
try {
|
||||
DDLManage::load('MongoBase');
|
||||
$strMigrationDir = root_path() . 'database/mongo/migrations';
|
||||
|
||||
|
||||
if (!is_dir($strMigrationDir)) {
|
||||
mkdir($strMigrationDir, 0755, true);
|
||||
$Output->writeln("<info>Created migration directory: {$strMigrationDir}</info>");
|
||||
}
|
||||
|
||||
|
||||
$arrFiles = glob($strMigrationDir . '/*.php');
|
||||
if (empty($arrFiles)) {
|
||||
$Output->writeln('<comment>No migration files found.</comment>');
|
||||
return 0;
|
||||
}
|
||||
|
||||
sort($arrFiles);
|
||||
|
||||
$Db = MongoBase::getInstance()->getDb();
|
||||
|
||||
foreach ($arrFiles as $strFile) {
|
||||
$Output->writeln("Processing migration: " . basename($strFile));
|
||||
|
||||
|
||||
$arrMigration = require $strFile;
|
||||
if (!is_array($arrMigration) || !isset($arrMigration['collection']) || !isset($arrMigration['indexes'])) {
|
||||
$Output->writeln("<error>Invalid migration format in {$strFile}</error>");
|
||||
continue;
|
||||
}
|
||||
|
||||
$strCollectionName = $arrMigration['collection'];
|
||||
$arrIndexes = $arrMigration['indexes'];
|
||||
|
||||
|
||||
$Col = $Db->selectCollection($strCollectionName);
|
||||
|
||||
|
||||
$arrExistingIndexes = iterator_to_array($Col->listIndexes());
|
||||
|
||||
$arrExistingIndexKeys = [];
|
||||
foreach ($arrExistingIndexes as $Index) {
|
||||
$strKey = json_encode($Index->getKey());
|
||||
$arrExistingIndexKeys[$strKey] = $Index->getName();
|
||||
}
|
||||
|
||||
|
||||
foreach ($arrIndexes as $arrIndex) {
|
||||
$arrKey = $arrIndex['key'];
|
||||
$arrOptions = $arrIndex['options'] ?? [];
|
||||
|
||||
|
||||
$strKey = json_encode($arrKey);
|
||||
|
||||
|
||||
if (array_key_exists($strKey, $arrExistingIndexKeys)) {
|
||||
$Output->writeln(" Index for " . json_encode($arrKey) . " already exists as {$arrExistingIndexKeys[$strKey]}, skipping...");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$arrIndexNameParts = [];
|
||||
foreach ($arrKey as $field => $direction) {
|
||||
$arrIndexNameParts[] = "{$field}_{$direction}";
|
||||
}
|
||||
$strIndexName = implode('_', $arrIndexNameParts);
|
||||
|
||||
|
||||
$arrOptions['name'] = $strIndexName;
|
||||
$Col->createIndex($arrKey, $arrOptions);
|
||||
|
||||
$Output->writeln(" Created index: {$strIndexName} for " . json_encode($arrKey));
|
||||
}
|
||||
}
|
||||
|
||||
$Output->writeln('<info>Migration completed successfully!</info>');
|
||||
return 0;
|
||||
} catch (\Exception $e) {
|
||||
$Output->writeln("<error>Error: {$e->getMessage()}</error>");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace db;
|
||||
|
||||
use app\model\CategoryModel;
|
||||
use app\model\ChapterModel;
|
||||
use database\seeders\SeedManager;
|
||||
use db\mongo\MongoBase;
|
||||
use ddl\DDLManage;
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\Output;
|
||||
use think\console\input\Option;
|
||||
use think\facade\Db;
|
||||
|
||||
class NovelManage extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('novel:manage')
|
||||
->addArgument('action', \think\console\input\Argument::OPTIONAL, 'The action to perform: reset')
|
||||
->setDescription('Manage the novel data: reset or ...');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $Output)
|
||||
{
|
||||
$strAction = $input->getArgument('action');
|
||||
|
||||
if ($strAction === 'reset') {
|
||||
$this->resetData($Output);
|
||||
} else {
|
||||
$Output->writeln("Invalid action. Use 'reset' ");
|
||||
}
|
||||
}
|
||||
|
||||
private function resetData(Output $Output)
|
||||
{
|
||||
DDLManage::load('MongoBase');
|
||||
|
||||
$Db = MongoBase::getInstance()->getDb();
|
||||
|
||||
$NovelCol = $Db->selectCollection('novel');
|
||||
|
||||
$ChapterCol = $Db->selectCollection('chapter');
|
||||
|
||||
$ChapterModel = ChapterModel::getInstance();
|
||||
|
||||
$intBatchSize = 1000;
|
||||
|
||||
$LastId = null;
|
||||
|
||||
while (true) {
|
||||
|
||||
$arrFilter = [];
|
||||
if (!is_null($LastId)) {
|
||||
$arrFilter['_id'] = ['$gt' => $LastId];
|
||||
}
|
||||
$arrOptions = [
|
||||
'sort' => ['_id' => 1],
|
||||
'limit' => $intBatchSize,
|
||||
'noCursorTimeout' => true,
|
||||
];
|
||||
|
||||
$Cursor = $NovelCol->find($arrFilter, $arrOptions);
|
||||
$arrDocs = iterator_to_array($Cursor);
|
||||
|
||||
if (empty($arrDocs)) {
|
||||
echo "全部处理完毕。\n";
|
||||
break;
|
||||
}
|
||||
|
||||
$arrBulkOps = [];
|
||||
|
||||
foreach ($arrDocs as $arrDoc) {
|
||||
$arrUpdateData = [];
|
||||
|
||||
if (!empty($arrDoc['n_category'])) {
|
||||
$arrUpdateData['n_category_pinyin'] = CategoryModel::getPinYin($arrDoc['n_category']);
|
||||
$arrUpdateData['n_category_sex_en'] = CategoryModel::getSexEn($arrDoc['n_category']);
|
||||
$arrUpdateData['n_category_sex_zh'] = CategoryModel::getSexZh($arrDoc['n_category']);
|
||||
}
|
||||
|
||||
$arrLasteChapter = $ChapterModel->getLatestChapterByNId($arrDoc['n_id'], false);
|
||||
|
||||
if (!empty($arrLasteChapter)) {
|
||||
$arrUpdateData['n_have_chapter'] = 1;
|
||||
$arrUpdateData['n_latest_chapter_name'] = $arrLasteChapter['name'];
|
||||
}
|
||||
|
||||
if (!empty($arrUpdateData)) {
|
||||
$arrBulkOps[] = [
|
||||
'updateOne' => [
|
||||
['_id' => $arrDoc['_id']],
|
||||
['$set' => $arrUpdateData],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$LastId = $arrDoc['_id'];
|
||||
}
|
||||
|
||||
if (!empty($arrBulkOps)) {
|
||||
$Result = $NovelCol->bulkWrite($arrBulkOps);
|
||||
printf("本批匹配 %d 条记录, 修改 %d 条记录\n", $Result->getMatchedCount(), $Result->getModifiedCount());
|
||||
} else {
|
||||
echo "本批无需要更新的记录。\n";
|
||||
}
|
||||
|
||||
echo "已处理一批,最后 _id: " . (string)$LastId . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ddl;
|
||||
|
||||
class DDLManage
|
||||
{
|
||||
private static $arrLoadedModules = [];
|
||||
|
||||
private static $arrModuleFiles = [
|
||||
'MicroServer' => 'extend/ddl/MicroCore.ddl',
|
||||
'MongoBase' => 'extend/ddl/MongoBase.ddl',
|
||||
];
|
||||
|
||||
/**
|
||||
* 加载指定模块
|
||||
* @param string $strModuleCode 模块编码
|
||||
* @return bool 加载是否成功
|
||||
*/
|
||||
public static function load($strModuleCode)
|
||||
{
|
||||
if (isset(self::$arrLoadedModules[$strModuleCode])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isset(self::$arrModuleFiles[$strModuleCode])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = self::$arrModuleFiles[$strModuleCode];
|
||||
|
||||
$strFileName = root_path() . $filename;
|
||||
|
||||
if (!file_exists($strFileName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (load_module_file($strFileName)) {
|
||||
self::$arrLoadedModules[$strModuleCode] = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查模块是否已加载
|
||||
* @param string $strModuleCode 类名
|
||||
* @return bool
|
||||
*/
|
||||
public static function isLoaded($strModuleCode)
|
||||
{
|
||||
return isset(self::$arrLoadedModules[$strModuleCode]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有已加载的模块
|
||||
* @return array
|
||||
*/
|
||||
public static function getarrLoadedModules()
|
||||
{
|
||||
return array_keys(self::$arrLoadedModules);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace processor;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use think\Exception;
|
||||
|
||||
class ImageProcessor
|
||||
{
|
||||
private static $instance = null;
|
||||
private $client;
|
||||
private $key;
|
||||
|
||||
private function __construct($key)
|
||||
{
|
||||
$this->client = new Client([
|
||||
'verify' => false // 忽略证书检测
|
||||
]);
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
public static function getInstance($key = 0x88)
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new ImageProcessor($key = 0x88);
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function downloadAndEncryptImage($imageUrl, $directory)
|
||||
{
|
||||
try {
|
||||
// 下载图片
|
||||
$response = $this->client->get($imageUrl);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
throw new Exception("Failed to download image: $imageUrl");
|
||||
}
|
||||
$imageData = $response->getBody()->getContents();
|
||||
|
||||
// 加密图片
|
||||
$encryptedData = $this->encrypt($imageData);
|
||||
|
||||
// 生成目录路径
|
||||
$relativePath = $this->generatePath($directory);
|
||||
|
||||
// 保存加密后的图片
|
||||
file_put_contents(public_path() . $relativePath, $encryptedData);
|
||||
|
||||
return '/' . $relativePath;
|
||||
} catch (RequestException $e) {
|
||||
throw new Exception("Request Error: " . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Error: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function downloadImage( $intXiaoShuoSourceId,$imageUrl, $directory)
|
||||
{
|
||||
try {
|
||||
// 下载图片
|
||||
$response = $this->client->get($imageUrl);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
throw new Exception("Failed to download image: $imageUrl");
|
||||
}
|
||||
$imageData = $response->getBody()->getContents();
|
||||
|
||||
// 加密图片
|
||||
//$encryptedData = $this->encrypt($imageData);
|
||||
|
||||
// 生成目录路径
|
||||
$relativePath = $this->generateImgPath($directory,$intXiaoShuoSourceId);
|
||||
|
||||
// 保存图片
|
||||
file_put_contents(public_path() . $relativePath, $imageData);
|
||||
|
||||
return '/' . $relativePath;
|
||||
} catch (RequestException $e) {
|
||||
throw new Exception("Request Error: " . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Error: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function encrypt($data)
|
||||
{
|
||||
$bytes = array_values(unpack('C*', $data));
|
||||
$len = count($bytes);
|
||||
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$bytes[$i] ^= $this->key;
|
||||
}
|
||||
|
||||
return pack('C*', ...$bytes);
|
||||
}
|
||||
|
||||
private function generateImgPath($directory,$intXiaoShuoSourceId)
|
||||
{
|
||||
$relativePath = $directory . '/pic/'.$intXiaoShuoSourceId;
|
||||
$basePath = public_path() . $relativePath;
|
||||
if (!is_dir($basePath)) {
|
||||
mkdir($basePath, 0777, true);
|
||||
}
|
||||
|
||||
$filePath = $relativePath . '.jpg'; ;
|
||||
return $filePath;
|
||||
}
|
||||
|
||||
private function generatePath($directory)
|
||||
{
|
||||
$datePath = date('Y/m/d');
|
||||
$hash = md5(uniqid(rand(), true));
|
||||
$hashPath = substr($hash, 0, 2) . '/' . substr($hash, 2, 2);
|
||||
|
||||
$relativePath = $directory . '/' . $datePath . '/' . $hashPath;
|
||||
$basePath = public_path() . $relativePath;
|
||||
if (!is_dir($basePath)) {
|
||||
mkdir($basePath, 0777, true);
|
||||
}
|
||||
|
||||
$filePath = $relativePath . '/' . uniqid() . '.jpg';
|
||||
return $filePath;
|
||||
}
|
||||
}
|
||||
|
||||
// // 示例用法
|
||||
// try {
|
||||
// $imageProcessor = ImageProcessor::getInstance();
|
||||
// $savedPath = $imageProcessor->downloadAndEncryptImage('https://example.com/path/to/image.jpg', 'abc');
|
||||
// echo "图片加密并保存到: " . $savedPath;
|
||||
// } catch (Exception $e) {
|
||||
// echo "错误: " . $e->getMessage();
|
||||
// }
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace storage;
|
||||
|
||||
use League\Flysystem\Filesystem;
|
||||
use League\Flysystem\AwsS3v3\AwsS3Adapter;
|
||||
use Aws\S3\S3Client;
|
||||
use League\Flysystem\Adapter\Local;
|
||||
|
||||
class StorageCore
|
||||
{
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var Filesystem
|
||||
*/
|
||||
private $Filesystem;
|
||||
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var Local
|
||||
*/
|
||||
private $Adapter;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$arrConfig = config('storage');
|
||||
|
||||
$this->Adapter = new Local(
|
||||
$arrConfig['local']['dir']
|
||||
);
|
||||
|
||||
$this->Filesystem = new Filesystem($this->Adapter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function getInstance(): self
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function set($strKey, $strContent)
|
||||
{
|
||||
$strContent = zstd_compress($strContent);
|
||||
return $this->Filesystem->write($strKey, $strContent);
|
||||
}
|
||||
|
||||
public function writeStream(string $strPath, $Resource)
|
||||
{
|
||||
$this->Filesystem->writeStream($strPath, $Resource);
|
||||
}
|
||||
|
||||
public function put($strKey, $strContent, array $arrConfig = [])
|
||||
{
|
||||
$strContent = zstd_compress($strContent);
|
||||
return $this->Filesystem->put($strKey, $strContent, $arrConfig);
|
||||
}
|
||||
|
||||
public function write($strKey, $strContent, array $arrConfig = [])
|
||||
{
|
||||
$strContent = zstd_compress($strContent);
|
||||
return $this->Filesystem->write($strKey, $strContent, $arrConfig);
|
||||
}
|
||||
|
||||
public function update($strKey, $strContent, array $arrConfig = [])
|
||||
{
|
||||
$strContent = zstd_compress($strContent);
|
||||
return $this->Filesystem->update($strKey, $strContent, $arrConfig);
|
||||
}
|
||||
|
||||
public function read($strKey)
|
||||
{
|
||||
try {
|
||||
$Stream = $this->Filesystem->readStream($strKey);
|
||||
$strContent = stream_get_contents($Stream);
|
||||
$strContent = zstd_uncompress($strContent);
|
||||
return $strContent;
|
||||
} catch (\Exception $e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public function has($strKey)
|
||||
{
|
||||
return $this->Filesystem->has($strKey);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
//
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user