作者 lyh

gx

@@ -5,10 +5,12 @@ @@ -5,10 +5,12 @@
5 * Date: 2024/2/19 5 * Date: 2024/2/19
6 * Time: 15:46 6 * Time: 15:46
7 */ 7 */
8 -namespace App\Services; 8 +namespace App\Services\Html;
9 9
  10 +use App\Models\Product\Keyword;
10 use App\Models\Project\Project; 11 use App\Models\Project\Project;
11 use App\Models\RouteMap\RouteMap; 12 use App\Models\RouteMap\RouteMap;
  13 +use App\Models\WebSetting\WebSettingSeo;
12 14
13 class CreateHtmlService 15 class CreateHtmlService
14 { 16 {
@@ -25,12 +27,14 @@ class CreateHtmlService @@ -25,12 +27,14 @@ class CreateHtmlService
25 if($projectInfo === false){ 27 if($projectInfo === false){
26 return ['code'=>400,'message'=>'当前项目不存在或者已被删除']; 28 return ['code'=>400,'message'=>'当前项目不存在或者已被删除'];
27 } 29 }
28 - // 获取页面信息  
29 - $page_info = $this->getInfoByRoute($route);  
30 - // 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;  
31 - if ($projectInfo && $page_info) {  
32 - $html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);  
33 - } else { 30 + //获取页面信息
  31 + $pageInfo = $this->getInfoByRoute($route);
  32 + if(empty($pageInfo)){
  33 + return ['code'=>400,'message'=>'当前路由不存在或者已被删除'];
  34 + }
  35 + if($projectInfo['is_upgrade'] == 0){
  36 + $html = $this->getHtmlV6($project_id, $route);
  37 + }else{
34 $html = $this->getHtmlV5(); 38 $html = $this->getHtmlV5();
35 } 39 }
36 return $html; 40 return $html;
@@ -63,12 +67,11 @@ class CreateHtmlService @@ -63,12 +67,11 @@ class CreateHtmlService
63 * 返回6.0页面最终HTML 67 * 返回6.0页面最终HTML
64 * @return mixed 68 * @return mixed
65 */ 69 */
66 - public function getHtmlV6($master_lang, $lang = [], $page = 0) 70 + public function getHtmlV6($project_id,$route)
67 { 71 {
68 // 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息 72 // 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息
69 -  
70 - $origin_html = $this->originHtml();  
71 - $html = $this->renderData($origin_html, $page); 73 + $origin_html = $this->originHtml($project_id,$route);
  74 + $html = $this->renderData($origin_html);
72 $html = $this->plugHead($html); 75 $html = $this->plugHead($html);
73 $html = $this->processFinal($html); 76 $html = $this->processFinal($html);
74 /** ... 调用其他方法, 直至返回完整的正确的HTML */ 77 /** ... 调用其他方法, 直至返回完整的正确的HTML */
@@ -99,9 +102,11 @@ class CreateHtmlService @@ -99,9 +102,11 @@ class CreateHtmlService
99 * 获取可视化HTML 102 * 获取可视化HTML
100 * @return string 103 * @return string
101 */ 104 */
102 - public function originHtml() 105 + public function originHtml($project_id,$route)
103 { 106 {
104 - $html = '根据路由查询数据库,并拼装HTML'; 107 + $generatePageService = new GeneratePageService();
  108 + $data = $generatePageService->generateHtml($project_id,$route);
  109 + $html = $data['html'] ?? '';
105 return $html; 110 return $html;
106 } 111 }
107 112
@@ -7,19 +7,18 @@ @@ -7,19 +7,18 @@
7 * @time :2024/2/19 15:54 7 * @time :2024/2/19 15:54
8 */ 8 */
9 9
10 -namespace App\Services; 10 +namespace App\Services\Html;
11 11
12 use App\Models\CustomModule\CustomModule; 12 use App\Models\CustomModule\CustomModule;
13 use App\Models\CustomModule\CustomModuleCategory; 13 use App\Models\CustomModule\CustomModuleCategory;
14 use App\Models\CustomModule\CustomModuleContent; 14 use App\Models\CustomModule\CustomModuleContent;
15 -use App\Models\Project\Project;  
16 use App\Models\RouteMap\RouteMap; 15 use App\Models\RouteMap\RouteMap;
17 use App\Models\Template\BTemplate; 16 use App\Models\Template\BTemplate;
18 use App\Models\Template\BTemplateCommon; 17 use App\Models\Template\BTemplateCommon;
19 use App\Models\Template\BTemplateMain; 18 use App\Models\Template\BTemplateMain;
20 use App\Models\Template\Setting; 19 use App\Models\Template\Setting;
21 -use App\Models\Template\Template;  
22 use App\Models\Template\TemplateTypeMain; 20 use App\Models\Template\TemplateTypeMain;
  21 +use App\Services\ProjectServer;
23 use Illuminate\Support\Facades\DB; 22 use Illuminate\Support\Facades\DB;
24 23
25 class GeneratePageService 24 class GeneratePageService
@@ -27,13 +26,8 @@ class GeneratePageService @@ -27,13 +26,8 @@ class GeneratePageService
27 protected $route; 26 protected $route;
28 27
29 protected $param; 28 protected $param;
30 -  
31 protected $project_id = 0; 29 protected $project_id = 0;
32 - public function __construct(){  
33 - $this->param = request()->all();  
34 - $this->route = $this->param['route'];  
35 - $this->project_id = $this->param['project_id'];  
36 - } 30 +
37 31
38 /** 32 /**
39 * @remark :生成单页数据 33 * @remark :生成单页数据
@@ -42,7 +36,9 @@ class GeneratePageService @@ -42,7 +36,9 @@ class GeneratePageService
42 * @method :post 36 * @method :post
43 * @time :2024/2/19 16:57 37 * @time :2024/2/19 16:57
44 */ 38 */
45 - public function generateHtml(){ 39 + public function generateHtml($project_id,$route){
  40 + $this->project_id = $project_id;
  41 + $this->route = $route;
46 ProjectServer::useProject($this->project_id); 42 ProjectServer::useProject($this->project_id);
47 $routeMapModel = new RouteMap(); 43 $routeMapModel = new RouteMap();
48 $routeInfo = $routeMapModel->read(['route'=>$this->param['route']]); 44 $routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);
@@ -50,7 +46,7 @@ class GeneratePageService @@ -50,7 +46,7 @@ class GeneratePageService
50 //页面管理单独处理 46 //页面管理单独处理
51 }else{ 47 }else{
52 $this->handleParam($routeInfo); 48 $this->handleParam($routeInfo);
53 - $this->getTemplateHtml(); 49 + return $this->getTemplateHtml();
54 } 50 }
55 DB::disconnect('custom_mysql'); 51 DB::disconnect('custom_mysql');
56 return true; 52 return true;
  1 +<?php
  2 +
  3 +namespace App\Services;
  4 +
  5 +use App\Models\Blog\Blog;
  6 +use App\Models\Blog\BlogCategory;
  7 +use App\Models\CustomModule\CustomModule;
  8 +use App\Models\CustomModule\CustomModuleCategory;
  9 +use App\Models\Module\Module;
  10 +use App\Models\Module\ModuleCategory;
  11 +use App\Models\News\News;
  12 +use App\Models\News\NewsCategory;
  13 +use App\Models\Product\Category;
  14 +use App\Models\Product\Keyword;
  15 +use App\Models\RouteMap\RouteMap;
  16 +use App\Models\Template\BCustomTemplate;
  17 +use App\Models\WebSetting\WebSetting;
  18 +use App\Models\WebSetting\WebSettingSeo;
  19 +
  20 +use Illuminate\Support\Facades\Cache;
  21 +use phpQuery;
  22 +
  23 +/**
  24 + * C端处理TDK服务
  25 + */
  26 +class TdkService{
  27 + /**
  28 + * 页面TDK处理
  29 + */
  30 + public function pageTdkHandle($projectInfo,$html,$type,$routerMapInfo=null): string
  31 + {
  32 + $titleContent = "";
  33 + $descriptionContent = "";
  34 + $keywordsContent = "";
  35 + $phpQueryDom=phpQuery::newDocument($html);
  36 + //首页TDK设置
  37 + if ($type == RouteMap::SOURCE_INDEX){
  38 + $tdkInfo = $this->indexTDK($projectInfo);
  39 + }
  40 + //单页面TDK设置
  41 + if ($type == RouteMap::SOURCE_PAGE){
  42 + $tdkInfo = $this->pageTDK($projectInfo,$routerMapInfo);
  43 + }
  44 + //自定义模块列表页TDK设置
  45 + if ($type == RouteMap::SOURCE_MODULE_CATE){
  46 + $tdkInfo = $this->moduleCategoryTDK($projectInfo,$routerMapInfo);
  47 + }
  48 + //自定义模块详情页TDK设置
  49 + if ($type == RouteMap::SOURCE_MODULE){
  50 + $tdkInfo = $this->moduleDetailsTDK($projectInfo,$routerMapInfo);
  51 + }
  52 + //新闻详情TDK设置
  53 + if ($type == RouteMap::SOURCE_NEWS){
  54 + $tdkInfo = $this->newsDetailsTDK($projectInfo,$routerMapInfo);
  55 + }
  56 + //博客详情TDK设置
  57 + if ($type == RouteMap::SOURCE_BLOG){
  58 + $tdkInfo = $this->blogDetailsTDK($projectInfo,$routerMapInfo);
  59 + }
  60 + //聚合页TDK设置
  61 + if ($type == RouteMap::SOURCE_PRODUCT_KEYWORD){
  62 + $tdkInfo = $this->productKeywordsTDK($projectInfo,$routerMapInfo);
  63 + }
  64 + //新闻列表页TDK设置
  65 + if ($type == RouteMap::SOURCE_NEWS_CATE){
  66 + $tdkInfo = $this->newsCategoryTDK($projectInfo,$routerMapInfo);
  67 + }
  68 + //博客列表页TDK设置
  69 + if ($type == RouteMap::SOURCE_BLOG_CATE){
  70 + $tdkInfo = $this->blogCategoryTDK($projectInfo,$routerMapInfo);
  71 + }
  72 + //产品列表页TDK设置
  73 + if ($type == RouteMap::SOURCE_PRODUCT_CATE){
  74 + $tdkInfo = $this->productCategoryTDK($projectInfo,$routerMapInfo);
  75 + }
  76 + if (!empty($tdkInfo)){
  77 + $titleContent = strip_tags($tdkInfo["titleContent"]);
  78 + $descriptionContent = strip_tags($tdkInfo["descriptionContent"]);
  79 + $keywordsContent = strip_tags($tdkInfo["keywordsContent"]);
  80 + }
  81 + $phpQueryDom->find('title')->text($titleContent);
  82 + $phpQueryDom->find('meta[name="description"]')->attr('content', $descriptionContent);
  83 + $phpQueryDom->find('meta[name="keywords"]')->attr('content', $keywordsContent);
  84 + $phpQueryDom->find('head')->append("<meta property='og:title' content='".$titleContent."'/>");
  85 + $phpQueryDom->find('head')->append("<meta property='og:type' content='site'/>");
  86 + $phpQueryDom->find('head')->append("<meta property='og:site_name' content='".$titleContent."'/>");
  87 + $content = $phpQueryDom->htmlOuter();
  88 + unset($html,$tdkInfo,$phpQueryDom);
  89 + phpQuery::unloadDocuments();
  90 + return $content;
  91 + }
  92 +
  93 + /**
  94 + * 首页TDK
  95 + */
  96 + public function indexTDK($projectInfo): array
  97 + {
  98 + $tdkInfo = [];
  99 + $webSettingInfo = $this->getWebSetting($projectInfo);
  100 + if (!empty($webSettingInfo)){
  101 + $titleContent = strip_tags($webSettingInfo['title']);
  102 + $descriptionContent = strip_tags($webSettingInfo['remark']);
  103 + $keywordsContent = strip_tags($webSettingInfo['keyword']);
  104 + $tdkInfo["titleContent"] = $titleContent;
  105 + $tdkInfo["descriptionContent"] = $descriptionContent;
  106 + $tdkInfo["keywordsContent"] = $keywordsContent;
  107 + }
  108 + return $tdkInfo;
  109 + }
  110 +
  111 + /**
  112 + * 网站设置
  113 + */
  114 + public function getWebSetting($projectInfo)
  115 + {
  116 + if (Cache::get("project_".$projectInfo['id']."_web_setting") == null) {
  117 + $webSettingModel = new WebSetting();
  118 + $webSettingInfo = $webSettingModel->read(['project_id'=>$projectInfo['id']]);
  119 + if ($webSettingInfo !== false) {
  120 + Cache::add("project_".$projectInfo['id']."_web_setting", json_encode($webSettingInfo));
  121 + return $webSettingInfo;
  122 + }
  123 + return [];
  124 + }
  125 + return (array)json_decode(Cache::get("project_".$projectInfo['id']."_web_setting"));
  126 + }
  127 +
  128 + /**
  129 + * 新闻列表页TDK
  130 + */
  131 + public function newsCategoryTDK($projectInfo,$routerMapInfo): array
  132 + {
  133 + $tdkInfo = [];
  134 + $pageSuffix = "";
  135 + $webSetting = $this->getWebSetting($projectInfo);
  136 + $newsCategoryModel = new NewsCategory();
  137 + $newsCategoryInfo = $newsCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  138 + //seo拼接
  139 + $webSeoModel = new WebSettingSeo();
  140 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  141 + if ($webSeoInfo !== false){
  142 + $pageSuffix = !empty($webSeoInfo['single_page_suffix']) ? " ".$webSeoInfo['single_page_suffix'] : "";
  143 + }
  144 + if ($newsCategoryInfo !== false){
  145 + //title
  146 + if (!empty($newsCategoryInfo['seo_title'])){
  147 + $titleContent = $newsCategoryInfo['seo_title'].$pageSuffix;
  148 + }else{
  149 + $titleContent = $newsCategoryInfo['name'].$pageSuffix;
  150 + }
  151 + //description
  152 + if (!empty($newsCategoryInfo['seo_des'])){
  153 + $descriptionContent = $newsCategoryInfo['seo_des'];
  154 + }else{
  155 + $descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  156 + }
  157 + //keyword
  158 + if (!empty($newsCategoryInfo['seo_keywords'])){
  159 + $keywordsContent = $newsCategoryInfo['seo_keywords'];
  160 + }else{
  161 + $keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  162 + }
  163 + $tdkInfo["titleContent"] = $titleContent;
  164 + $tdkInfo["descriptionContent"] = $descriptionContent;
  165 + $tdkInfo["keywordsContent"] = $keywordsContent;
  166 + }
  167 + return $tdkInfo;
  168 + }
  169 +
  170 + /**
  171 + * 博客列表页TDK
  172 + */
  173 + public function blogCategoryTDK($projectInfo,$routerMapInfo): array
  174 + {
  175 + $tdkInfo = [];
  176 + $pageSuffix = "";
  177 + $webSetting = $this->getWebSetting($projectInfo);
  178 + $blogCategoryModel = new BlogCategory();
  179 + $blogCategoryInfo = $blogCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  180 + //seo拼接
  181 + $webSeoModel = new WebSettingSeo();
  182 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  183 + if ($webSeoInfo !== false){
  184 + $pageSuffix = !empty($webSeoInfo['single_page_suffix']) ? " ".$webSeoInfo['single_page_suffix'] : "";
  185 + }
  186 + if ($blogCategoryInfo !== false){
  187 + //title
  188 + if (!empty($blogCategoryInfo['seo_title'])){
  189 + $titleContent = $blogCategoryInfo['seo_title'].$pageSuffix;
  190 + }else{
  191 + $titleContent = $blogCategoryInfo['name'].$pageSuffix;
  192 + }
  193 + //description
  194 + if (!empty($blogCategoryInfo['seo_des'])){
  195 + $descriptionContent = $blogCategoryInfo['seo_des'];
  196 + }else{
  197 + $descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  198 + }
  199 + //keyword
  200 + if (!empty($blogCategoryInfo['seo_keywords'])){
  201 + $keywordsContent = $blogCategoryInfo['seo_keywords'];
  202 + }else{
  203 + $keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  204 + }
  205 + $tdkInfo["titleContent"] = $titleContent;
  206 + $tdkInfo["descriptionContent"] = $descriptionContent;
  207 + $tdkInfo["keywordsContent"] = $keywordsContent;
  208 + }
  209 + return $tdkInfo;
  210 + }
  211 +
  212 + /**
  213 + * 产品列表页TDK
  214 + */
  215 + public function productCategoryTDK($projectInfo,$routerMapInfo): array
  216 + {
  217 + $tdkInfo = [];
  218 + $prefix = "";
  219 + $suffix = "";
  220 + $webSettingTitle = "";
  221 + $webSettingDescription = "";
  222 + $webSettingKeyword = "";
  223 + $projectCategoryModel = new Category();
  224 + $projectCategoryInfo = $projectCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  225 + $webSetting = $this->getWebSetting($projectInfo);
  226 + //seo拼接
  227 + $webSeoModel = new WebSettingSeo();
  228 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  229 + if ($webSeoInfo !== false){
  230 + $prefix = !empty($webSeoInfo['product_cate_prefix']) ? $webSeoInfo['product_cate_prefix']." " : "";
  231 + $suffix = !empty($webSeoInfo['product_cate_suffix']) ? " ".$webSeoInfo['product_cate_suffix'] : "";
  232 + }
  233 + if ($webSetting !== false){
  234 + $webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
  235 + $webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  236 + $webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  237 + }
  238 + if ($projectCategoryInfo !== false){
  239 + //title
  240 + if (!empty($projectCategoryInfo['seo_title'])){
  241 + $titleContent = $prefix.$projectCategoryInfo['seo_title'].$suffix;
  242 + }else{
  243 + $titleContent = $prefix.$webSettingTitle.$suffix;
  244 + }
  245 + //description
  246 + if (!empty($projectCategoryInfo['seo_des'])){
  247 + $descriptionContent = $projectCategoryInfo['seo_des'];
  248 + }else{
  249 + $descriptionContent = $webSettingDescription;
  250 + }
  251 + //keywords
  252 + if (!empty($projectCategoryInfo['seo_keywords'])){
  253 + $keywordsContent = $projectCategoryInfo['seo_keywords'];
  254 + }else{
  255 + $keywordsContent = $webSettingKeyword;
  256 + }
  257 + }else{
  258 + $titleContent = $prefix.$webSettingTitle.$suffix;
  259 + $descriptionContent = $webSettingDescription;
  260 + $keywordsContent = $webSettingKeyword;
  261 + }
  262 + $tdkInfo["titleContent"] = $titleContent;
  263 + $tdkInfo["descriptionContent"] = $descriptionContent;
  264 + $tdkInfo["keywordsContent"] = $keywordsContent;
  265 + return $tdkInfo;
  266 + }
  267 +
  268 + /**
  269 + * 产品聚合页TDK
  270 + */
  271 + public function productKeywordsTDK($projectInfo,$routerMapInfo): array
  272 + {
  273 + $tdkInfo = [];
  274 + $keywordModel = new Keyword();
  275 + $keywordInfo = $keywordModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  276 + if ($keywordInfo !== false){
  277 + //处理title
  278 + $title = $keywordInfo['seo_title'] ?: $keywordInfo['title'];
  279 + //seo拼接
  280 + $webSeoModel = new WebSettingSeo();
  281 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  282 + $titleContent = $webSeoInfo ? $webSeoInfo['tab_prefix'] . " " . $title . " " . $webSeoInfo['tab_suffix'] : $title;
  283 + //处理description
  284 + $descriptionContent = $keywordInfo['seo_description'] ?: $keywordInfo['title'];
  285 + //处理keywords
  286 + $keywordsContent = $keywordInfo['seo_keywords'] ?: $keywordInfo['title'];
  287 +
  288 + $tdkInfo["titleContent"] = $titleContent;
  289 + $tdkInfo["descriptionContent"] = $descriptionContent;
  290 + $tdkInfo["keywordsContent"] = $keywordsContent;
  291 + }
  292 + return $tdkInfo;
  293 + }
  294 +
  295 + /**
  296 + * 新闻详情页TDK
  297 + */
  298 + public function newsDetailsTDK($projectInfo,$routerMapInfo): array
  299 + {
  300 + $tdkInfo = [];
  301 + $titleContent = "";
  302 + $keywordsContent = "";
  303 + $descriptionContent = "";
  304 + $newsModel = new News();
  305 + $newsInfo = $newsModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>1]);
  306 + return $this->newsBlogTdk($newsInfo, $projectInfo, $titleContent, $descriptionContent, $keywordsContent, $tdkInfo);
  307 + }
  308 +
  309 + /**
  310 + * 新闻详情页TDK
  311 + */
  312 + public function blogDetailsTDK($projectInfo,$routerMapInfo): array
  313 + {
  314 + $tdkInfo = [];
  315 + $titleContent = "";
  316 + $keywordsContent = "";
  317 + $descriptionContent = "";
  318 + $blogMode = new Blog();
  319 + $blogInfo = $blogMode->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>1]);
  320 + return $this->newsBlogTdk($blogInfo, $projectInfo, $titleContent, $descriptionContent, $keywordsContent, $tdkInfo);
  321 + }
  322 +
  323 + /**
  324 + * 自定义模块列表页TDK
  325 + */
  326 + public function moduleDetailsTDK($projectInfo,$routerMapInfo): array
  327 + {
  328 + $tdkInfo = [];
  329 + $moduleModel = new CustomModule();
  330 + $moduleInfo = $moduleModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id'],'status'=>0]);
  331 + $webSetting = $this->getWebSetting($projectInfo);
  332 + if ($moduleInfo !== false){
  333 + //title
  334 + $webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
  335 + $titleContent = !empty($moduleInfo['seo_title']) ? $moduleInfo['seo_title'] : $webSettingTitle;
  336 + //description
  337 + $webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  338 + $descriptionContent = !empty($moduleInfo['seo_description']) ? $moduleInfo['seo_description'] : $webSettingDescription;
  339 +
  340 + //keywords
  341 + $webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  342 + $keywordsContent = !empty($moduleInfo['seo_keywords']) ? $moduleInfo['seo_keywords'] : $webSettingKeyword;
  343 + $tdkInfo["titleContent"] = $titleContent;
  344 + $tdkInfo["descriptionContent"] = $descriptionContent;
  345 + $tdkInfo["keywordsContent"] = $keywordsContent;
  346 + }
  347 + return $tdkInfo;
  348 + }
  349 +
  350 + /**
  351 + * 自定义模块列表页TDK
  352 + */
  353 + public function moduleCategoryTDK($projectInfo,$routerMapInfo): array
  354 + {
  355 + $tdkInfo = [];
  356 + $moduleCategoryModel = new CustomModuleCategory();
  357 + $moduleCategoryInfo = $moduleCategoryModel->read(['project_id'=>$projectInfo['id'],'id'=>$routerMapInfo['source_id']]);
  358 + $webSetting = $this->getWebSetting($projectInfo);
  359 + if ($moduleCategoryInfo !== false){
  360 + //title
  361 + $webSettingTitle = !empty($webSetting['title']) ? $webSetting['title'] : "";
  362 + $titleContent = !empty($moduleCategoryInfo['seo_title']) ? $moduleCategoryInfo['seo_title'] : $webSettingTitle;
  363 +
  364 + //description
  365 + $webSettingDescription = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  366 + $descriptionContent = !empty($moduleCategoryInfo['seo_description']) ? $moduleCategoryInfo['seo_description'] : $webSettingDescription;
  367 +
  368 + //keywords
  369 + $webSettingKeyword = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  370 + $keywordsContent = !empty($moduleCategoryInfo['seo_keywords']) ? $moduleCategoryInfo['seo_keywords'] : $webSettingKeyword;
  371 + $tdkInfo["titleContent"] = $titleContent;
  372 + $tdkInfo["descriptionContent"] = $descriptionContent;
  373 + $tdkInfo["keywordsContent"] = $keywordsContent;
  374 + }
  375 + return $tdkInfo;
  376 + }
  377 +
  378 + /**
  379 + * 单页面TDK
  380 + */
  381 + public function pageTDK($projectInfo,$routerMapInfo): array
  382 + {
  383 + $tdkInfo = [];
  384 + if (!empty($routerMap)){
  385 + $customModel = new BCustomTemplate();
  386 + $webCustomInfo = $customModel->read(['id'=>$routerMapInfo['source_id'],'status'=>1]);
  387 + //seo拼接
  388 + $webSeoModel = new WebSettingSeo();
  389 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  390 + //网站设置
  391 + $webSetting = $this->getWebSetting($projectInfo);
  392 + $titleContent = "";
  393 + $descriptionContent = "";
  394 + $keywordsContent = "";
  395 + if ($webCustomInfo !== false){
  396 + //title
  397 + if ($webCustomInfo['title'] == null){
  398 + if (!empty($webSeo)){
  399 + $titleContent = $webCustomInfo['name']." ".$webSeoInfo['single_page_suffix'];
  400 + }else{
  401 + $titleContent = $webCustomInfo['name'];
  402 + }
  403 + }else{
  404 + if (!empty($webSeo)){
  405 + $titleContent = $webCustomInfo['title']." ".$webSeoInfo['single_page_suffix'];
  406 + }else{
  407 + $titleContent = $webCustomInfo['title'];
  408 + }
  409 + }
  410 + //keywords
  411 + if ($webCustomInfo['keywords'] == null){
  412 + if (!empty($webSetting)){
  413 + $keywordsContent = $webSetting['keyword'];
  414 + }
  415 + }else{
  416 + $keywordsContent = $webSetting['keywords'];
  417 + }
  418 + //description
  419 + if ($webCustomInfo['description'] == null){
  420 + if (!empty($webSetting)) {
  421 + $descriptionContent = $webSetting['remark'];
  422 + }
  423 + }else{
  424 + $descriptionContent = $webCustomInfo['description'];
  425 + }
  426 + $tdkInfo["titleContent"] = $titleContent;
  427 + $tdkInfo["descriptionContent"] = $descriptionContent;
  428 + $tdkInfo["keywordsContent"] = $keywordsContent;
  429 + }
  430 + }
  431 + return $tdkInfo;
  432 + }
  433 +
  434 + /**
  435 + * 新闻博客详情通用版块
  436 + */
  437 + public function newsBlogTdk($info, $projectInfo, string $titleContent, $descriptionContent, $keywordsContent, array $tdkInfo): array
  438 + {
  439 + if (!empty($info)) {
  440 + //seo拼接
  441 + $pageSuffix = "";
  442 + $webSeoModel = new WebSettingSeo();
  443 + $webSeoInfo = $webSeoModel->read(['project_id'=>$projectInfo['id']]);
  444 + $webSetting = $this->getWebSetting($projectInfo);
  445 + if (!empty($webSeoInfo)) {
  446 + $pageSuffix = !empty($webSeo['single_page_suffix']) ? " " . $webSeo['single_page_suffix'] : "";
  447 + }
  448 + if ($info['seo_title'] == null) {
  449 + $titleContent = !empty($info['name']) ? $info['name'] . $pageSuffix : "";
  450 + } else {
  451 + $titleContent = $info['seo_title'] . $pageSuffix;
  452 + }
  453 + //处理description
  454 + if ($info['seo_description'] == null) {
  455 + $descriptionContent = !empty($webSetting['remark']) ? $webSetting['remark'] : "";
  456 + } else {
  457 + $descriptionContent = $info['seo_description'];
  458 + }
  459 + //处理keywords
  460 + if ($info['seo_keywords'] == null) {
  461 + $keywordsContent = !empty($webSetting['keyword']) ? $webSetting['keyword'] : "";
  462 + } else {
  463 + $keywordsContent = $info['seo_keywords'];
  464 + }
  465 + $tdkInfo["titleContent"] = $titleContent;
  466 + $tdkInfo["descriptionContent"] = $descriptionContent;
  467 + $tdkInfo["keywordsContent"] = $keywordsContent;
  468 + }
  469 +
  470 + return $tdkInfo;
  471 + }
  472 +}