|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use App\Models\Blog\Blog;
|
|
|
|
use App\Models\Blog\BlogCategory;
|
|
|
|
use App\Models\CustomModule\CustomModule;
|
|
|
|
use App\Models\CustomModule\CustomModuleCategory;
|
|
|
|
use App\Models\Module\Module;
|
|
|
|
use App\Models\Module\ModuleCategory;
|
|
|
|
use App\Models\News\News;
|
|
|
|
use App\Models\News\NewsCategory;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Template\BCustomTemplate;
|
|
|
|
use App\Models\WebSetting\WebSetting;
|
|
|
|
use App\Models\WebSetting\WebSettingSeo;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use phpQuery;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* C端处理TDK服务
|
|
|
|
*/
|
|
|
|
class TdkService{
|
|
|
|
/**
|
|
|
|
* 页面TDK处理
|
|
|
|
*/
|
|
|
|
public function pageTdkHandle($projectInfo,$html,$type,$routerMapInfo=null): string
|
|
|
|
{
|
|
|
|
$titleContent = "";
|
|
|
|
$descriptionContent = "";
|
|
|
|
$keywordsContent = "";
|
|
|
|
$phpQueryDom=phpQuery::newDocument($html);
|
|
|
|
//首页TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_INDEX){
|
|
|
|
$tdkInfo = $this->indexTDK($projectInfo);
|
|
|
|
}
|
|
|
|
//单页面TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_PAGE){
|
|
|
|
$tdkInfo = $this->pageTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
//自定义模块列表页TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_MODULE_CATE){
|
|
|
|
$tdkInfo = $this->moduleCategoryTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
//自定义模块详情页TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_MODULE){
|
|
|
|
$tdkInfo = $this->moduleDetailsTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
//新闻详情TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_NEWS){
|
|
|
|
$tdkInfo = $this->newsDetailsTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
//博客详情TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_BLOG){
|
|
|
|
$tdkInfo = $this->blogDetailsTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
//聚合页TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_PRODUCT_KEYWORD){
|
|
|
|
$tdkInfo = $this->productKeywordsTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
//新闻列表页TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_NEWS_CATE){
|
|
|
|
$tdkInfo = $this->newsCategoryTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
//博客列表页TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_BLOG_CATE){
|
|
|
|
$tdkInfo = $this->blogCategoryTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
//产品列表页TDK设置
|
|
|
|
if ($type == RouteMap::SOURCE_PRODUCT_CATE){
|
|
|
|
$tdkInfo = $this->productCategoryTDK($projectInfo,$routerMapInfo);
|
|
|
|
}
|
|
|
|
if (!empty($tdkInfo)){
|
|
|
|
$titleContent = strip_tags($tdkInfo["titleContent"]);
|
|
|
|
$descriptionContent = strip_tags($tdkInfo["descriptionContent"]);
|
|
|
|
$keywordsContent = strip_tags($tdkInfo["keywordsContent"]);
|
|
|
|
}
|
|
|
|
$phpQueryDom->find('title')->text($titleContent);
|
|
|
|
$phpQueryDom->find('meta[name="description"]')->attr('content', $descriptionContent);
|
|
|
|
$phpQueryDom->find('meta[name="keywords"]')->attr('content', $keywordsContent);
|
|
|
|
$phpQueryDom->find('head')->append("<meta property='og:title' content='".$titleContent."'/>");
|
|
|
|
$phpQueryDom->find('head')->append("<meta property='og:type' content='site'/>");
|
|
|
|
$phpQueryDom->find('head')->append("<meta property='og:site_name' content='".$titleContent."'/>");
|
|
|
|
$content = $phpQueryDom->htmlOuter();
|
|
|
|
unset($html,$tdkInfo,$phpQueryDom);
|
|
|
|
phpQuery::unloadDocuments();
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 首页TDK
|
|
|
|
*/
|
|
|
|
public function indexTDK($projectInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$webSettingInfo = $this->getWebSetting($projectInfo);
|
|
|
|
if (!empty($webSettingInfo)){
|
|
|
|
$titleContent = strip_tags($webSettingInfo['title']);
|
|
|
|
$descriptionContent = strip_tags($webSettingInfo['remark']);
|
|
|
|
$keywordsContent = strip_tags($webSettingInfo['keyword']);
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
}
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 网站设置
|
|
|
|
*/
|
|
|
|
public function getWebSetting($projectInfo)
|
|
|
|
{
|
|
|
|
if (Cache::get("project_".$projectInfo['id']."_web_setting") == null) {
|
|
|
|
$webSettingModel = new WebSetting();
|
|
|
|
$webSettingInfo = $webSettingModel->read(['project_id'=>$projectInfo['id']]);
|
|
|
|
if ($webSettingInfo !== false) {
|
|
|
|
Cache::add("project_".$projectInfo['id']."_web_setting", json_encode($webSettingInfo));
|
|
|
|
return $webSettingInfo;
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return (array)json_decode(Cache::get("project_".$projectInfo['id']."_web_setting"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新闻列表页TDK
|
|
|
|
*/
|
|
|
|
public function newsCategoryTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$pageSuffix = "";
|
|
|
|
$webSetting = $this->getWebSetting($projectInfo);
|
|
|
|
$newsCategoryModel = new NewsCategory();
|
|
|
|
$newsCategoryInfo = $newsCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
|
|
|
|
//seo拼接
|
|
|
|
$webSeoModel = new WebSettingSeo();
|
|
|
|
$webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
|
|
|
|
if ($webSeoInfo !== false){
|
|
|
|
$pageSuffix = !empty($webSeoInfo['single_page_suffix']) ? " ".$webSeoInfo['single_page_suffix'] : "";
|
|
|
|
}
|
|
|
|
if ($newsCategoryInfo !== false){
|
|
|
|
//title
|
|
|
|
if (!empty($newsCategoryInfo['seo_title'])){
|
|
|
|
$titleContent = $newsCategoryInfo['seo_title'].$pageSuffix;
|
|
|
|
}else{
|
|
|
|
$titleContent = $newsCategoryInfo['name'].$pageSuffix;
|
|
|
|
}
|
|
|
|
//description
|
|
|
|
if (!empty($newsCategoryInfo['seo_des'])){
|
|
|
|
$descriptionContent = $newsCategoryInfo['seo_des'];
|
|
|
|
}else{
|
|
|
|
$descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
|
|
|
|
}
|
|
|
|
//keyword
|
|
|
|
if (!empty($newsCategoryInfo['seo_keywords'])){
|
|
|
|
$keywordsContent = $newsCategoryInfo['seo_keywords'];
|
|
|
|
}else{
|
|
|
|
$keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
|
|
|
|
}
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
}
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 博客列表页TDK
|
|
|
|
*/
|
|
|
|
public function blogCategoryTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$pageSuffix = "";
|
|
|
|
$webSetting = $this->getWebSetting($projectInfo);
|
|
|
|
$blogCategoryModel = new BlogCategory();
|
|
|
|
$blogCategoryInfo = $blogCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
|
|
|
|
//seo拼接
|
|
|
|
$webSeoModel = new WebSettingSeo();
|
|
|
|
$webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
|
|
|
|
if ($webSeoInfo !== false){
|
|
|
|
$pageSuffix = !empty($webSeoInfo['single_page_suffix']) ? " ".$webSeoInfo['single_page_suffix'] : "";
|
|
|
|
}
|
|
|
|
if ($blogCategoryInfo !== false){
|
|
|
|
//title
|
|
|
|
if (!empty($blogCategoryInfo['seo_title'])){
|
|
|
|
$titleContent = $blogCategoryInfo['seo_title'].$pageSuffix;
|
|
|
|
}else{
|
|
|
|
$titleContent = $blogCategoryInfo['name'].$pageSuffix;
|
|
|
|
}
|
|
|
|
//description
|
|
|
|
if (!empty($blogCategoryInfo['seo_des'])){
|
|
|
|
$descriptionContent = $blogCategoryInfo['seo_des'];
|
|
|
|
}else{
|
|
|
|
$descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
|
|
|
|
}
|
|
|
|
//keyword
|
|
|
|
if (!empty($blogCategoryInfo['seo_keywords'])){
|
|
|
|
$keywordsContent = $blogCategoryInfo['seo_keywords'];
|
|
|
|
}else{
|
|
|
|
$keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
|
|
|
|
}
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
}
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 产品列表页TDK
|
|
|
|
*/
|
|
|
|
public function productCategoryTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$prefix = "";
|
|
|
|
$suffix = "";
|
|
|
|
$webSettingTitle = "";
|
|
|
|
$webSettingDescription = "";
|
|
|
|
$webSettingKeyword = "";
|
|
|
|
$projectCategoryModel = new Category();
|
|
|
|
$projectCategoryInfo = $projectCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
|
|
|
|
$webSetting = $this->getWebSetting($projectInfo);
|
|
|
|
//seo拼接
|
|
|
|
$webSeoModel = new WebSettingSeo();
|
|
|
|
$webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
|
|
|
|
if ($webSeoInfo !== false){
|
|
|
|
$prefix = !empty($webSeoInfo['product_cate_prefix']) ? $webSeoInfo['product_cate_prefix']." " : "";
|
|
|
|
$suffix = !empty($webSeoInfo['product_cate_suffix']) ? " ".$webSeoInfo['product_cate_suffix'] : "";
|
|
|
|
}
|
|
|
|
if ($webSetting !== false){
|
|
|
|
$webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
|
|
|
|
$webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
|
|
|
|
$webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
|
|
|
|
}
|
|
|
|
if ($projectCategoryInfo !== false){
|
|
|
|
//title
|
|
|
|
if (!empty($projectCategoryInfo['seo_title'])){
|
|
|
|
$titleContent = $prefix.$projectCategoryInfo['seo_title'].$suffix;
|
|
|
|
}else{
|
|
|
|
$titleContent = $prefix.$webSettingTitle.$suffix;
|
|
|
|
}
|
|
|
|
//description
|
|
|
|
if (!empty($projectCategoryInfo['seo_des'])){
|
|
|
|
$descriptionContent = $projectCategoryInfo['seo_des'];
|
|
|
|
}else{
|
|
|
|
$descriptionContent = $webSettingDescription;
|
|
|
|
}
|
|
|
|
//keywords
|
|
|
|
if (!empty($projectCategoryInfo['seo_keywords'])){
|
|
|
|
$keywordsContent = $projectCategoryInfo['seo_keywords'];
|
|
|
|
}else{
|
|
|
|
$keywordsContent = $webSettingKeyword;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$titleContent = $prefix.$webSettingTitle.$suffix;
|
|
|
|
$descriptionContent = $webSettingDescription;
|
|
|
|
$keywordsContent = $webSettingKeyword;
|
|
|
|
}
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 产品聚合页TDK
|
|
|
|
*/
|
|
|
|
public function productKeywordsTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$keywordInfo = $keywordModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
|
|
|
|
if ($keywordInfo !== false){
|
|
|
|
//处理title
|
|
|
|
$title = $keywordInfo['seo_title'] ?: $keywordInfo['title'];
|
|
|
|
//seo拼接
|
|
|
|
$webSeoModel = new WebSettingSeo();
|
|
|
|
$webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
|
|
|
|
$titleContent = $webSeoInfo ? $webSeoInfo['tab_prefix'] . " " . $title . " " . $webSeoInfo['tab_suffix'] : $title;
|
|
|
|
//处理description
|
|
|
|
$descriptionContent = $keywordInfo['seo_description'] ?: $keywordInfo['title'];
|
|
|
|
//处理keywords
|
|
|
|
$keywordsContent = $keywordInfo['seo_keywords'] ?: $keywordInfo['title'];
|
|
|
|
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
}
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新闻详情页TDK
|
|
|
|
*/
|
|
|
|
public function newsDetailsTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$titleContent = "";
|
|
|
|
$keywordsContent = "";
|
|
|
|
$descriptionContent = "";
|
|
|
|
$newsModel = new News();
|
|
|
|
$newsInfo = $newsModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>1]);
|
|
|
|
return $this->newsBlogTdk($newsInfo, $projectInfo, $titleContent, $descriptionContent, $keywordsContent, $tdkInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新闻详情页TDK
|
|
|
|
*/
|
|
|
|
public function blogDetailsTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$titleContent = "";
|
|
|
|
$keywordsContent = "";
|
|
|
|
$descriptionContent = "";
|
|
|
|
$blogMode = new Blog();
|
|
|
|
$blogInfo = $blogMode->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>1]);
|
|
|
|
return $this->newsBlogTdk($blogInfo, $projectInfo, $titleContent, $descriptionContent, $keywordsContent, $tdkInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 自定义模块列表页TDK
|
|
|
|
*/
|
|
|
|
public function moduleDetailsTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$moduleModel = new CustomModule();
|
|
|
|
$moduleInfo = $moduleModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>0]);
|
|
|
|
$webSetting = $this->getWebSetting($projectInfo);
|
|
|
|
if ($moduleInfo !== false){
|
|
|
|
//title
|
|
|
|
$webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
|
|
|
|
$titleContent = !empty($moduleInfo['seo_title']) ? $moduleInfo['seo_title'] : $webSettingTitle;
|
|
|
|
//description
|
|
|
|
$webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
|
|
|
|
$descriptionContent = !empty($moduleInfo['seo_description']) ? $moduleInfo['seo_description'] : $webSettingDescription;
|
|
|
|
|
|
|
|
//keywords
|
|
|
|
$webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
|
|
|
|
$keywordsContent = !empty($moduleInfo['seo_keywords']) ? $moduleInfo['seo_keywords'] : $webSettingKeyword;
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
}
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 自定义模块列表页TDK
|
|
|
|
*/
|
|
|
|
public function moduleCategoryTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
$moduleCategoryModel = new CustomModuleCategory();
|
|
|
|
$moduleCategoryInfo = $moduleCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
|
|
|
|
$webSetting = $this->getWebSetting($projectInfo);
|
|
|
|
if ($moduleCategoryInfo !== false){
|
|
|
|
//title
|
|
|
|
$webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
|
|
|
|
$titleContent = !empty($moduleCategoryInfo['seo_title']) ? $moduleCategoryInfo['seo_title'] : $webSettingTitle;
|
|
|
|
|
|
|
|
//description
|
|
|
|
$webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
|
|
|
|
$descriptionContent = !empty($moduleCategoryInfo['seo_description']) ? $moduleCategoryInfo['seo_description'] : $webSettingDescription;
|
|
|
|
|
|
|
|
//keywords
|
|
|
|
$webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
|
|
|
|
$keywordsContent = !empty($moduleCategoryInfo['seo_keywords']) ? $moduleCategoryInfo['seo_keywords'] : $webSettingKeyword;
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
}
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 单页面TDK
|
|
|
|
*/
|
|
|
|
public function pageTDK($projectInfo,$routerMapInfo): array
|
|
|
|
{
|
|
|
|
$tdkInfo = [];
|
|
|
|
if (!empty($routerMap)){
|
|
|
|
$customModel = new BCustomTemplate();
|
|
|
|
$webCustomInfo = $customModel->read(['id'=>$routerMapInfo['source_id'],'status'=>1]);
|
|
|
|
//seo拼接
|
|
|
|
$webSeoModel = new WebSettingSeo();
|
|
|
|
$webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
|
|
|
|
//网站设置
|
|
|
|
$webSetting = $this->getWebSetting($projectInfo);
|
|
|
|
$titleContent = "";
|
|
|
|
$descriptionContent = "";
|
|
|
|
$keywordsContent = "";
|
|
|
|
if ($webCustomInfo !== false){
|
|
|
|
//title
|
|
|
|
if ($webCustomInfo['title'] == null){
|
|
|
|
if (!empty($webSeo)){
|
|
|
|
$titleContent = $webCustomInfo['name']." ".$webSeoInfo['single_page_suffix'];
|
|
|
|
}else{
|
|
|
|
$titleContent = $webCustomInfo['name'];
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if (!empty($webSeo)){
|
|
|
|
$titleContent = $webCustomInfo['title']." ".$webSeoInfo['single_page_suffix'];
|
|
|
|
}else{
|
|
|
|
$titleContent = $webCustomInfo['title'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//keywords
|
|
|
|
if ($webCustomInfo['keywords'] == null){
|
|
|
|
if (!empty($webSetting)){
|
|
|
|
$keywordsContent = $webSetting['keyword'];
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$keywordsContent = $webSetting['keywords'];
|
|
|
|
}
|
|
|
|
//description
|
|
|
|
if ($webCustomInfo['description'] == null){
|
|
|
|
if (!empty($webSetting)) {
|
|
|
|
$descriptionContent = $webSetting['remark'];
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$descriptionContent = $webCustomInfo['description'];
|
|
|
|
}
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新闻博客详情通用版块
|
|
|
|
*/
|
|
|
|
public function newsBlogTdk($info, $projectInfo, string $titleContent, $descriptionContent, $keywordsContent, array $tdkInfo): array
|
|
|
|
{
|
|
|
|
if (!empty($info)) {
|
|
|
|
//seo拼接
|
|
|
|
$pageSuffix = "";
|
|
|
|
$webSeoModel = new WebSettingSeo();
|
|
|
|
$webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
|
|
|
|
$webSetting = $this->getWebSetting($projectInfo);
|
|
|
|
if (!empty($webSeoInfo)) {
|
|
|
|
$pageSuffix = !empty($webSeo['single_page_suffix']) ? " " . $webSeo['single_page_suffix'] : "";
|
|
|
|
}
|
|
|
|
if ($info['seo_title'] == null) {
|
|
|
|
$titleContent = !empty($info['name']) ? $info['name'] . $pageSuffix : "";
|
|
|
|
} else {
|
|
|
|
$titleContent = $info['seo_title'] . $pageSuffix;
|
|
|
|
}
|
|
|
|
//处理description
|
|
|
|
if ($info['seo_description'] == null) {
|
|
|
|
$descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
|
|
|
|
} else {
|
|
|
|
$descriptionContent = $info['seo_description'];
|
|
|
|
}
|
|
|
|
//处理keywords
|
|
|
|
if ($info['seo_keywords'] == null) {
|
|
|
|
$keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
|
|
|
|
} else {
|
|
|
|
$keywordsContent = $info['seo_keywords'];
|
|
|
|
}
|
|
|
|
$tdkInfo["titleContent"] = $titleContent;
|
|
|
|
$tdkInfo["descriptionContent"] = $descriptionContent;
|
|
|
|
$tdkInfo["keywordsContent"] = $keywordsContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $tdkInfo;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|