gpt
This commit is contained in:
@@ -10,6 +10,8 @@ use app\model\VideoCategoryModel;
|
||||
use app\services\StaticConfig;
|
||||
use microserver\ProcessSanitizer;
|
||||
use microserver\QueueManage;
|
||||
use app\model\TemplatesModel;
|
||||
use app\common\helper\SiteStyle;
|
||||
|
||||
class VideoSiteMapLogic
|
||||
{
|
||||
@@ -159,6 +161,19 @@ class VideoSiteMapLogic
|
||||
mkdir($strDomainDir);
|
||||
}
|
||||
|
||||
// 通过域名获取对应的模板
|
||||
// $TemplatesModel = TemplatesModel::getTemplateOnCacheByTId($DomainModel->t_id);
|
||||
// if (empty($TemplatesModel)) {
|
||||
// $TemplatesModel = 'videoGpt1';
|
||||
// }
|
||||
|
||||
// // 判断如果是gpt 模板 则 先获取当前域名的 siteStyle,方便下面拿 url模板
|
||||
// if ($TemplatesModel == 'videoGpt1') {
|
||||
// $arrTpStyle = SiteStyle::getConfig($DomainModel->d_domain);
|
||||
// $arrUrlFamily = $arrTpStyle['template_cfg']['url_family'];
|
||||
// }
|
||||
$arrUrlFamily = $this->getGptArrUrlTmp($DomainModel);
|
||||
|
||||
$strHead = <<<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
@@ -195,7 +210,13 @@ EOF;
|
||||
'strPinYin' => $Video->v_name_en,
|
||||
];
|
||||
|
||||
$strUri = $DomainModel->getFomartUrlEx($strKey, $strDomain, $strController, $strAction, $arrArgs);
|
||||
if ($arrUrlFamily && !empty($arrUrlFamily)) {
|
||||
|
||||
$strPattern = $arrUrlFamily['detail']['pattern'];
|
||||
$strUri = buildUrlFromPattern($strPattern, $arrArgs);
|
||||
} else {
|
||||
$strUri = $DomainModel->getFomartUrlEx($strKey, $strDomain, $strController, $strAction, $arrArgs);
|
||||
}
|
||||
$strUrl = sprintf("https://www.%s%s", $DomainModel->d_domain, $strUri);
|
||||
$strPriority = '0.8';
|
||||
$strContent = sprintf($strTemplate, $strUrl, $strPriority);
|
||||
@@ -266,10 +287,17 @@ EOF;
|
||||
if (is_dir($strDomainDir) == false) {
|
||||
mkdir($strDomainDir);
|
||||
}
|
||||
|
||||
$strMapIndexFile = $strDomainDir . '/sitemap-main.xml';
|
||||
|
||||
$strRankIndexUri = $DomainModel->getFomartUrlEx("VIDEO_RANK_INDEX_URL", $DomainModel->d_domain, "", "", []);
|
||||
$arrUrlFamily = $this->getGptArrUrlTmp($DomainModel);
|
||||
|
||||
if ($arrUrlFamily && !empty($arrUrlFamily)) {
|
||||
|
||||
$strPattern = $arrUrlFamily['rank_index']['pattern'];
|
||||
$strRankIndexUri = buildUrlFromPattern($strPattern, []);
|
||||
} else {
|
||||
$strRankIndexUri = $DomainModel->getFomartUrlEx("VIDEO_RANK_INDEX_URL", $DomainModel->d_domain, "", "", []);
|
||||
}
|
||||
$strRankIndexUrl = sprintf("https://www.%s%s", $DomainModel->d_domain, $strRankIndexUri);
|
||||
|
||||
$strContent = <<<EOF
|
||||
@@ -299,9 +327,16 @@ EOF;
|
||||
$strAction = "";
|
||||
$arrArgs = [
|
||||
'strParentCategory' => $arrParentCategory['v_category_en'],
|
||||
'intParentId' => $arrParentCategory['v_category_en'],
|
||||
];
|
||||
|
||||
$strUri = $DomainModel->getFomartUrlEx($strKey, $strDomain, $strController, $strAction, $arrArgs);
|
||||
if ($arrUrlFamily && !empty($arrUrlFamily)) {
|
||||
|
||||
$strPattern = $arrUrlFamily['category_parent']['pattern'];
|
||||
$strUri = buildUrlFromPattern($strPattern, $arrArgs);
|
||||
} else {
|
||||
$strUri = $DomainModel->getFomartUrlEx($strKey, $strDomain, $strController, $strAction, $arrArgs);
|
||||
}
|
||||
|
||||
$strUrl = sprintf("https://www.%s%s", $DomainModel->d_domain, $strUri);
|
||||
|
||||
@@ -331,15 +366,22 @@ EOF;
|
||||
$strAction = "";
|
||||
$arrArgs = [
|
||||
'strParentCategory' => $arrParentCategory['v_category_en'],
|
||||
'intParentId' => $arrParentCategory['v_category_en'],
|
||||
'strCategory' => $arrChildrenCategory['v_category_en'],
|
||||
'intCategoryId' => $arrChildrenCategory['v_category_en'],
|
||||
'strYear' => 'all',
|
||||
'strArea' => 'all',
|
||||
'strOrder' => $strSortKey,
|
||||
'strLang' => 'all',
|
||||
'intPage' => 1,
|
||||
];
|
||||
if ($arrUrlFamily && !empty($arrUrlFamily)) {
|
||||
|
||||
$strUri = $DomainModel->getFomartUrlEx($strKey, $strDomain, $strController, $strAction, $arrArgs);
|
||||
$strPattern = $arrUrlFamily['category_child']['pattern'];
|
||||
$strUri = buildUrlFromPattern($strPattern, $arrArgs);
|
||||
} else {
|
||||
$strUri = $DomainModel->getFomartUrlEx($strKey, $strDomain, $strController, $strAction, $arrArgs);
|
||||
}
|
||||
$strUrl = sprintf("https://www.%s%s", $DomainModel->d_domain, $strUri);
|
||||
$strContent = <<<EOF
|
||||
<url>
|
||||
@@ -372,7 +414,13 @@ EOF;
|
||||
'strSortType' => $strSortKey,
|
||||
];
|
||||
|
||||
$strUri = $DomainModel->getFomartUrlEx($strKey, $strDomain, $strController, $strAction, $arrArgs);
|
||||
if ($arrUrlFamily && !empty($arrUrlFamily)) {
|
||||
|
||||
$strPattern = $arrUrlFamily['rank_list']['pattern'];
|
||||
$strUri = buildUrlFromPattern($strPattern, $arrArgs);
|
||||
} else {
|
||||
$strUri = $DomainModel->getFomartUrlEx($strKey, $strDomain, $strController, $strAction, $arrArgs);
|
||||
}
|
||||
|
||||
$strUrl = sprintf("https://www.%s%s", $DomainModel->d_domain, $strUri);
|
||||
|
||||
@@ -489,6 +537,8 @@ EOF;
|
||||
|
||||
foreach ($this->getDomain() as $DomainModel) {
|
||||
|
||||
$arrUrlFamily = $this->getGptArrUrlTmp($DomainModel);
|
||||
|
||||
$strDomainDir = rtrim($this->strSiteMapPath, '/') . '/' . $DomainModel->d_domain;
|
||||
|
||||
if (!is_dir($strDomainDir)) {
|
||||
@@ -510,17 +560,23 @@ EOF;
|
||||
$isFirst = true;
|
||||
|
||||
foreach ($this->fetchVideosByBatch($intStart, $this->intPageSize) as $Video) {
|
||||
$arrArgs = [
|
||||
'intVId' => $Video->v_id,
|
||||
'strPinYin' => $Video->v_name_en,
|
||||
];
|
||||
if ($arrUrlFamily && !empty($arrUrlFamily)) {
|
||||
|
||||
$strUri = $DomainModel->getFomartUrlEx(
|
||||
"VIDEO_INFO_URL",
|
||||
$DomainModel->d_domain,
|
||||
'',
|
||||
'',
|
||||
[
|
||||
'intVId' => $Video->v_id,
|
||||
'strPinYin' => $Video->v_name_en,
|
||||
]
|
||||
);
|
||||
$strPattern = $arrUrlFamily['detail']['pattern'];
|
||||
$strUri = buildUrlFromPattern($strPattern, $arrArgs);
|
||||
} else {
|
||||
$strUri = $DomainModel->getFomartUrlEx(
|
||||
"VIDEO_INFO_URL",
|
||||
$DomainModel->d_domain,
|
||||
'',
|
||||
'',
|
||||
$arrArgs
|
||||
);
|
||||
}
|
||||
|
||||
$fullUrl = 'https://www.' . $DomainModel->d_domain . $strUri;
|
||||
|
||||
@@ -572,4 +628,29 @@ EOF;
|
||||
echo "[JSON] done {$finalFile}\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param [type] $DomainModel
|
||||
* @return void
|
||||
*/
|
||||
public function getGptArrUrlTmp($DomainModel)
|
||||
{
|
||||
// 通过域名获取对应的模板
|
||||
$arrUrlFamily = [];
|
||||
$TemplatesModel = TemplatesModel::getTemplateOnCacheByTId($DomainModel->t_id);
|
||||
|
||||
if (empty($TemplatesModel)) {
|
||||
$TemplatesModel = 'videoGpt1';
|
||||
}
|
||||
|
||||
// 判断如果是gpt 模板 则 先获取当前域名的 siteStyle,方便下面拿 url模板
|
||||
if ($TemplatesModel->t_code == 'videoGpt1') {
|
||||
$arrTpStyle = SiteStyle::getConfig(null, $DomainModel->d_domain);
|
||||
$arrUrlFamily = $arrTpStyle['template_cfg']['url_family'];
|
||||
}
|
||||
|
||||
return $arrUrlFamily;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user