|
|
|
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
|
+} |