init
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
use app\admin\model\SiteModel;
|
||||
use app\admin\model\SeoTdkConfigModel;
|
||||
|
||||
class SeoTdkHelper
|
||||
{
|
||||
public static function getProcessedTdk($pageCode, $extraReplacements = [])
|
||||
{
|
||||
// 基础变量
|
||||
$strSiteName = SiteModel::getValBySiteIdByValCode('site_name');
|
||||
$strDomain = SiteModel::getValBySiteIdByValCode('site_domain');
|
||||
|
||||
// 页面 SEO 配置
|
||||
$SeoTdkConfigModel = SeoTdkConfigModel::getValByCode($pageCode);
|
||||
$strTdkTitle = $SeoTdkConfigModel['stc_title'] ?? '';
|
||||
$strTdkKeywords = $SeoTdkConfigModel['stc_keywords'] ?? '';
|
||||
$strTdkDescription = $SeoTdkConfigModel['stc_description'] ?? '';
|
||||
|
||||
// 默认变量
|
||||
$replacements = array_merge([
|
||||
'{{{site_name}}}' => $strSiteName,
|
||||
'{{{site_domain}}}' => $strDomain,
|
||||
], $extraReplacements);
|
||||
|
||||
// 替换
|
||||
$strTdkTitle = strtr($strTdkTitle, $replacements);
|
||||
$strTdkKeywords = strtr($strTdkKeywords, $replacements);
|
||||
$strTdkDescription = strtr($strTdkDescription, $replacements);
|
||||
|
||||
return [
|
||||
'strTdkTitle' => $strTdkTitle,
|
||||
'strTdkKeywords' => $strTdkKeywords,
|
||||
'strTdkDescription' => $strTdkDescription,
|
||||
];
|
||||
}
|
||||
}
|
||||
84
code/extend/storage/StorageCore.php
Normal file
84
code/extend/storage/StorageCore.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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 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)
|
||||
{
|
||||
$Stream = $this->Filesystem->readStream($strKey);
|
||||
$strContent = stream_get_contents($Stream);
|
||||
$strContent = zstd_uncompress($strContent);
|
||||
return $strContent;
|
||||
}
|
||||
|
||||
public function has($strKey)
|
||||
{
|
||||
return $this->Filesystem->has($strKey);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user