debug
This commit is contained in:
@@ -1017,9 +1017,11 @@ class DomainModel extends BaseModel
|
||||
}
|
||||
|
||||
if (!is_array($this->t_cfg) || !array_key_exists($strKey, $this->t_cfg)) {
|
||||
$strFallbackValue = $this->resolveLegacyTemplateFallback((string)$strKey);
|
||||
if ($strFallbackValue !== null) {
|
||||
return $strFallbackValue;
|
||||
}
|
||||
return '';
|
||||
$strError = sprintf("t_cfg [%s] not found! %s ", $strKey , $strDomain . '-' . $strController . '-' . $strAction. '-' . $strDiff. '-' . $boolJoin.'-'.request()->url);
|
||||
throw new \Exception($strError);
|
||||
}
|
||||
|
||||
$intSfgId = $this->t_cfg[$strKey]['sfg_id'];
|
||||
@@ -1070,13 +1072,83 @@ class DomainModel extends BaseModel
|
||||
$strError = sprintf("subject fomart [%s] not found !", $strKey);
|
||||
throw new \Exception($strError);
|
||||
}
|
||||
|
||||
return $SubjectFomartModel->sf_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
||||
return $SubjectFomartModel->sf_val;
|
||||
}
|
||||
|
||||
protected function resolveLegacyTemplateFallback(string $strKey): ?string
|
||||
{
|
||||
if (!is_array($this->t_cfg) || !isset($this->t_cfg['pages'], $this->t_cfg['url_family'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$arrSeoKeyMap = [
|
||||
'VIDEO@INDEX@INDEX@TITLE' => ['title', 'home'],
|
||||
'VIDEO@INDEX@INDEX@KEYWORDS' => ['keywords', 'home'],
|
||||
'VIDEO@INDEX@INDEX@DESCRIPTION' => ['description', 'home'],
|
||||
'VIDEO@GETCATEGORYINDEX@TITLE' => ['title', 'category_index'],
|
||||
'VIDEO@GETCATEGORYINDEX@KEYWORDS' => ['keywords', 'category_index'],
|
||||
'VIDEO@GETCATEGORYINDEX@DESCRIPTION' => ['description', 'category_index'],
|
||||
'VIDEO@GETCATEGORY@TITLE' => ['title', 'category_list'],
|
||||
'VIDEO@GETCATEGORY@KEYWORDS' => ['keywords', 'category_list'],
|
||||
'VIDEO@GETCATEGORY@DESCRIPTION' => ['description', 'category_list'],
|
||||
'VIDEO@GETSEARCHVIDEO@TITLE' => ['title', 'search'],
|
||||
'VIDEO@GETSEARCHVIDEO@KEYWORDS' => ['keywords', 'search'],
|
||||
'VIDEO@GETSEARCHVIDEO@DESCRIPTION' => ['description', 'search'],
|
||||
'VIDEO@GETVIDEORANKINDEX@TITLE' => ['title', 'rank_index'],
|
||||
'VIDEO@GETVIDEORANKINDEX@KEYWORDS' => ['keywords', 'rank_index'],
|
||||
'VIDEO@GETVIDEORANKINDEX@DESCRIPTION' => ['description', 'rank_index'],
|
||||
'VIDEO@GETVIDEORANKLIST@TITLE' => ['title', 'rank_list'],
|
||||
'VIDEO@GETVIDEORANKLIST@KEYWORDS' => ['keywords', 'rank_list'],
|
||||
'VIDEO@GETVIDEORANKLIST@DESCRIPTION' => ['description', 'rank_list'],
|
||||
'VIDEO@GETVIDEOINFO@TITLE' => ['title', 'detail'],
|
||||
'VIDEO@GETVIDEOINFO@KEYWORDS' => ['keywords', 'detail'],
|
||||
'VIDEO@GETVIDEOINFO@DESCRIPTION' => ['description', 'detail'],
|
||||
'VIDEO@GETVIDEOPLAY@TITLE' => ['title', 'play'],
|
||||
'VIDEO@GETVIDEOPLAY@KEYWORDS' => ['keywords', 'play'],
|
||||
'VIDEO@GETVIDEOPLAY@DESCRIPTION' => ['description', 'play'],
|
||||
];
|
||||
|
||||
if (isset($arrSeoKeyMap[$strKey])) {
|
||||
[$strSeoCode, $strSeoPage] = $arrSeoKeyMap[$strKey];
|
||||
|
||||
try {
|
||||
$SiteContext = \think\Container::getInstance()->make(\app\services\SiteContext::class);
|
||||
return (string)$SiteContext->getSeoTkd($strSeoCode, $strSeoPage);
|
||||
} catch (\Throwable $Throwable) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$arrRuntimeStyle = \app\common\helper\SiteStyle::getConfig($this, (string)($this->d_domain ?? ''));
|
||||
$UrlBuilder = new \app\common\helper\UrlBuilder($arrRuntimeStyle);
|
||||
} catch (\Throwable $Throwable) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$strTemplateCode = (string)(request()->TemplatesModel->t_code ?? '');
|
||||
if ($strTemplateCode !== '' && $strTemplateCode !== 'videoGpt1') {
|
||||
return match ($strKey) {
|
||||
'VIDEO_RANK_INDEX_URL' => '/phb-index',
|
||||
'VIDEO_SEARCH_LIST_URL' => '/query.html',
|
||||
'VIDEO_HISTORY_LIST_URL' => '/history.html',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
return match ($strKey) {
|
||||
'VIDEO_CATEGORY_INDEX_URL' => $UrlBuilder->categoryHome(),
|
||||
'VIDEO_RANK_INDEX_URL' => $UrlBuilder->rankIndex(),
|
||||
'VIDEO_SEARCH_LIST_URL' => $UrlBuilder->searchEntry(),
|
||||
'VIDEO_HISTORY_LIST_URL' => $UrlBuilder->history(),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param string $strKey
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -172,6 +172,53 @@ class VideoModel extends MongoModel
|
||||
return $this->findManyWithCache($arrFilter, $intCount, $arrSort, $arrOptions, $strKey, $intLifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 轻量级 sitemap / rss 列表,只取生成 URL 需要的字段,避免大对象缓存撑爆内存。
|
||||
*/
|
||||
public function findSitemapItemsWithCache(
|
||||
array $arrFilter,
|
||||
int $intCount = 1000,
|
||||
array $arrSort = [],
|
||||
string $strKey = '',
|
||||
int $intLifeTime = 24 * 3600
|
||||
): array {
|
||||
try {
|
||||
$arrResult = $this->checkCacheByKey($strKey);
|
||||
if ($arrResult !== NULL) {
|
||||
return is_array($arrResult) ? $arrResult : [];
|
||||
}
|
||||
|
||||
$arrOptions = self::$arrOptions;
|
||||
$arrOptions['projection'] = [
|
||||
'_id' => 0,
|
||||
'v_id' => 1,
|
||||
'v_name_en' => 1,
|
||||
'v_publish_date' => 1,
|
||||
'created_at' => 1,
|
||||
'updated_at' => 1,
|
||||
];
|
||||
$arrOptions['limit'] = max(1, $intCount);
|
||||
|
||||
if (!empty($arrSort)) {
|
||||
$arrOptions['sort'] = $arrSort;
|
||||
}
|
||||
|
||||
$Cursor = $this->getCol()->find($arrFilter, $arrOptions);
|
||||
$arrResult = iterator_to_array($Cursor);
|
||||
|
||||
foreach ($arrResult as &$arrItem) {
|
||||
applyToKeys($arrItem, ['created_at', 'updated_at'], 'formatMongoDate');
|
||||
}
|
||||
unset($arrItem);
|
||||
|
||||
$this->setCacheByKey($strKey, $arrResult, $intLifeTime);
|
||||
|
||||
return $arrResult;
|
||||
} catch (\Throwable $Throwable) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* find one Video
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user