|
1
|
-<?php
|
|
|
|
2
|
-
|
|
|
|
3
|
-
|
|
|
|
4
|
-namespace App\Services\Html;
|
|
|
|
5
|
-
|
|
|
|
6
|
-use App\Models\Blog\Blog;
|
|
|
|
7
|
-use App\Models\Collect\CollectTask;
|
|
|
|
8
|
-use App\Models\Com\Notify;
|
|
|
|
9
|
-use App\Models\Com\UpdateNotify;
|
|
|
|
10
|
-use App\Models\Com\UpdateProgress;
|
|
|
|
11
|
-use App\Models\CustomModule\CustomModuleContent;
|
|
|
|
12
|
-use App\Models\CustomModule\CustomModuleCategory;
|
|
|
|
13
|
-use App\Models\News\News;
|
|
|
|
14
|
-use App\Models\News\NewsCategory;
|
|
|
|
15
|
-use App\Models\Product\Category;
|
|
|
|
16
|
-use App\Models\Product\CategoryRelated;
|
|
|
|
17
|
-use App\Models\Product\Keyword;
|
|
|
|
18
|
-use App\Models\Product\Product;
|
|
|
|
19
|
-use App\Models\Project\CountryCustom;
|
|
|
|
20
|
-use App\Models\Project\DeployBuild;
|
|
|
|
21
|
-use App\Models\Project\Project;
|
|
|
|
22
|
-use App\Models\Project\UpdateMasterWebsiteModel;
|
|
|
|
23
|
-use App\Models\Project\UpdateMinorLanguagesModel;
|
|
|
|
24
|
-use App\Models\RouteMap\RouteMap;
|
|
|
|
25
|
-use App\Models\Template\BCustomTemplate;
|
|
|
|
26
|
-use App\Models\Template\BTemplate;
|
|
|
|
27
|
-use App\Models\Template\Setting;
|
|
|
|
28
|
-use App\Models\WebSetting\SettingNum;
|
|
|
|
29
|
-use App\Models\WebSetting\WebLanguage;
|
|
|
|
30
|
-use App\Repositories\StaticHtmlRepository;
|
|
|
|
31
|
-use Illuminate\Support\Facades\File;
|
|
|
|
32
|
-use phpQuery;
|
|
|
|
33
|
-use stdClass;
|
|
|
|
34
|
-
|
|
|
|
35
|
-/**
|
|
|
|
36
|
- * C端生成页面服务
|
|
|
|
37
|
- */
|
|
|
|
38
|
-class CreatePageService{
|
|
|
|
39
|
-
|
|
|
|
40
|
- /**
|
|
|
|
41
|
- * 获取升级项目小语种采集的页面
|
|
|
|
42
|
- * @param $project
|
|
|
|
43
|
- * @param $route
|
|
|
|
44
|
- * @param $source
|
|
|
|
45
|
- * @param $lang
|
|
|
|
46
|
- * @return string
|
|
|
|
47
|
- * @author Akun
|
|
|
|
48
|
- * @date 2024/01/08 11:40
|
|
|
|
49
|
- */
|
|
|
|
50
|
- public function getMinorLanguagePage($project,$route,$source,$lang){
|
|
|
|
51
|
- if($project['update_info']['is_language_update'] == 0){
|
|
|
|
52
|
- return '';
|
|
|
|
53
|
- }
|
|
|
|
54
|
- if ($source == 'news' || $source == 'blog' || $source == 'product' || $source == 'page' || $source == 'module'){
|
|
|
|
55
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("source",$source)->first();
|
|
|
|
56
|
- }elseif($source == ''){
|
|
|
|
57
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn("source",["product","page","module"])->orderBy('source','desc')->first();
|
|
|
|
58
|
- }else{
|
|
|
|
59
|
- return '';
|
|
|
|
60
|
- }
|
|
|
|
61
|
- if($routerMap) {
|
|
|
|
62
|
- switch ($routerMap->source) {
|
|
|
|
63
|
- //产品详情
|
|
|
|
64
|
- case RouteMap::SOURCE_PRODUCT:
|
|
|
|
65
|
- $detail = Product::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
|
|
|
|
66
|
- break;
|
|
|
|
67
|
- //博客详情
|
|
|
|
68
|
- case RouteMap::SOURCE_BLOG:
|
|
|
|
69
|
- $detail = Blog::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
|
|
|
|
70
|
- break;
|
|
|
|
71
|
- //新闻详情
|
|
|
|
72
|
- case RouteMap::SOURCE_NEWS:
|
|
|
|
73
|
- $detail = News::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
|
|
|
|
74
|
- break;
|
|
|
|
75
|
- //自定义模块详情
|
|
|
|
76
|
- case RouteMap::SOURCE_MODULE:
|
|
|
|
77
|
- $detail = Module::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
|
|
|
|
78
|
- break;
|
|
|
|
79
|
- default:
|
|
|
|
80
|
- //单页详情
|
|
|
|
81
|
- $detail = BCustomTemplate::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
|
|
|
|
82
|
- }
|
|
|
|
83
|
- if($detail && $detail->six_read){
|
|
|
|
84
|
- return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
|
|
|
|
85
|
- }else{
|
|
|
|
86
|
- return '';
|
|
|
|
87
|
- }
|
|
|
|
88
|
- }else{
|
|
|
|
89
|
- return '';
|
|
|
|
90
|
- }
|
|
|
|
91
|
- }
|
|
|
|
92
|
-
|
|
|
|
93
|
- /**
|
|
|
|
94
|
- * 根据语言,路由,分页数,获取页面内容
|
|
|
|
95
|
- */
|
|
|
|
96
|
- public function getPageByLangRoutePage($project,$route,$page=null,$source=""): string
|
|
|
|
97
|
- {
|
|
|
|
98
|
- $html = "";
|
|
|
|
99
|
- $page = $page == null ? null : (int)$page;
|
|
|
|
100
|
- $router = $route == "" ? "404" : $route;
|
|
|
|
101
|
- $productKeywordRouter = new Keyword();
|
|
|
|
102
|
- $productKeywordRouters = $productKeywordRouter->product_keyword_route;
|
|
|
|
103
|
- if (in_array($router, $productKeywordRouters)) {
|
|
|
|
104
|
- $html = $this->getProductKeywordListPage($project,$router,$page);
|
|
|
|
105
|
- unset($productKeywordRouter);
|
|
|
|
106
|
- } else {
|
|
|
|
107
|
- //新增:products,news,blog 三个路由为C端固定路由,数据库路由表没有路由也可以访问或调数据
|
|
|
|
108
|
- if ($router == "products" || $router == "news" || $router == "blog"){
|
|
|
|
109
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->first();
|
|
|
|
110
|
- $routerMapRegular = new stdClass();
|
|
|
|
111
|
- if (empty($routerMap)){
|
|
|
|
112
|
- if ($router == "products"){
|
|
|
|
113
|
- $routerMapRegular->source = RouteMap::SOURCE_PRODUCT_CATE;
|
|
|
|
114
|
- $routerMapRegular->route = "products";
|
|
|
|
115
|
- }
|
|
|
|
116
|
- if ($router == "news"){
|
|
|
|
117
|
- $routerMapRegular->source = RouteMap::SOURCE_NEWS_CATE;
|
|
|
|
118
|
- $routerMapRegular->route = "news";
|
|
|
|
119
|
- }
|
|
|
|
120
|
- if ($router == "blog"){
|
|
|
|
121
|
- $routerMapRegular->source = RouteMap::SOURCE_BLOG_CATE;
|
|
|
|
122
|
- $routerMapRegular->route = "blog";
|
|
|
|
123
|
- }
|
|
|
|
124
|
- $routerMapRegular->source_id = 0;
|
|
|
|
125
|
- $routerMapRegular->project_id = $project->id;
|
|
|
|
126
|
- $routerMap = $routerMapRegular;
|
|
|
|
127
|
- unset($routerMapRegular);
|
|
|
|
128
|
- }
|
|
|
|
129
|
- }else{
|
|
|
|
130
|
- if ($project->update_info["is_update"] == 1){
|
|
|
|
131
|
- if ($source != ""){
|
|
|
|
132
|
- //$source可能值:news,blog,news_category,blog_category
|
|
|
|
133
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->where("source",$source)->first();
|
|
|
|
134
|
- }else{
|
|
|
|
135
|
- //product_category,product,page,product_keyword,module_category,module
|
|
|
|
136
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->whereIn("source",["product","product_category","page","module_category","module","product_keyword"])->orderByRaw("FIELD(source, 'product_category','product','module_category','module','page','product_keyword')")->first();
|
|
|
|
137
|
- }
|
|
|
|
138
|
- if (empty($routerMap)){
|
|
|
|
139
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->first();
|
|
|
|
140
|
- }
|
|
|
|
141
|
- }else{
|
|
|
|
142
|
- //6.0
|
|
|
|
143
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$router)->first();
|
|
|
|
144
|
- }
|
|
|
|
145
|
- }
|
|
|
|
146
|
-
|
|
|
|
147
|
- if (!empty($routerMap)){
|
|
|
|
148
|
- $type = $routerMap->source;
|
|
|
|
149
|
- switch ($type) {
|
|
|
|
150
|
- //产品详情
|
|
|
|
151
|
- case RouteMap::SOURCE_PRODUCT:
|
|
|
|
152
|
- $html = $this->getProductPage($project,$routerMap);
|
|
|
|
153
|
- break;
|
|
|
|
154
|
- //产品列表
|
|
|
|
155
|
- case RouteMap::SOURCE_PRODUCT_CATE:
|
|
|
|
156
|
- $html = $this->getProductListPage($project,$routerMap,$page);
|
|
|
|
157
|
- break;
|
|
|
|
158
|
- //博客详情
|
|
|
|
159
|
- case RouteMap::SOURCE_BLOG:
|
|
|
|
160
|
- $html = $this->getBlogPage($project,$routerMap);
|
|
|
|
161
|
- break;
|
|
|
|
162
|
- //博客列表
|
|
|
|
163
|
- case RouteMap::SOURCE_BLOG_CATE:
|
|
|
|
164
|
- $html = $this->getBlogListPage($project,$routerMap,$page);
|
|
|
|
165
|
- break;
|
|
|
|
166
|
- //新闻详情
|
|
|
|
167
|
- case RouteMap::SOURCE_NEWS:
|
|
|
|
168
|
- $html = $this->getNewsPage($project,$routerMap);
|
|
|
|
169
|
- break;
|
|
|
|
170
|
- //新闻列表
|
|
|
|
171
|
- case RouteMap::SOURCE_NEWS_CATE:
|
|
|
|
172
|
- $html = $this->getNewsListPage($project,$routerMap,$page);
|
|
|
|
173
|
- break;
|
|
|
|
174
|
- //自定义模块列表
|
|
|
|
175
|
- case RouteMap::SOURCE_MODULE_CATE:
|
|
|
|
176
|
- $html = $this->getModuleListPage($project,$routerMap,$page);
|
|
|
|
177
|
- break;
|
|
|
|
178
|
- //自定义模块详情
|
|
|
|
179
|
- case RouteMap::SOURCE_MODULE:
|
|
|
|
180
|
- $html = $this->getModulePage($project,$routerMap);
|
|
|
|
181
|
- break;
|
|
|
|
182
|
- //聚合页
|
|
|
|
183
|
- case RouteMap::SOURCE_PRODUCT_KEYWORD:
|
|
|
|
184
|
- $html = $this->getProductKeywordPage($project,$routerMap);
|
|
|
|
185
|
- break;
|
|
|
|
186
|
- case RouteMap::SOURCE_PAGE:
|
|
|
|
187
|
- if ($router == RouteMap::SOURCE_INDEX){
|
|
|
|
188
|
- //首页
|
|
|
|
189
|
- $html = $this->getIndexPage($project,$routerMap);
|
|
|
|
190
|
- }else{
|
|
|
|
191
|
- //单页面
|
|
|
|
192
|
- $html = $this->getSinglePage($project,$routerMap);
|
|
|
|
193
|
- }
|
|
|
|
194
|
- break;
|
|
|
|
195
|
- default:
|
|
|
|
196
|
- $html = $this->getSinglePage($project,$routerMap);
|
|
|
|
197
|
- }
|
|
|
|
198
|
- }
|
|
|
|
199
|
- }
|
|
|
|
200
|
- return $html;
|
|
|
|
201
|
- }
|
|
|
|
202
|
-
|
|
|
|
203
|
- /**
|
|
|
|
204
|
- * 获取首页html
|
|
|
|
205
|
- */
|
|
|
|
206
|
- public function getIndexPage($project,$routerMap): string
|
|
|
|
207
|
- {
|
|
|
|
208
|
- $pageService = new PageService();
|
|
|
|
209
|
- $commonService = new CommonService();
|
|
|
|
210
|
- $tdkService = new TdkService();
|
|
|
|
211
|
- //首页模板
|
|
|
|
212
|
- $info = Setting::where("project_id",$project->id)->first();
|
|
|
|
213
|
- if (empty($info)){
|
|
|
|
214
|
- return "";
|
|
|
|
215
|
- }
|
|
|
|
216
|
- $webIndexTemplate = BTemplate::where("project_id",$project->id)->where("template_id",$info->template_id)->where("source",1)->first();
|
|
|
|
217
|
- if (!empty($webIndexTemplate)){
|
|
|
|
218
|
- $html = $pageService->isAndGetVisualizationHtml($project,RouteMap::SOURCE_INDEX,$routerMap);
|
|
|
|
219
|
- if ($html == ""){
|
|
|
|
220
|
- //组装首页页面
|
|
|
|
221
|
- $html = $pageService->assembleIndexPage($project,$webIndexTemplate);
|
|
|
|
222
|
- }
|
|
|
|
223
|
- //公共处理
|
|
|
|
224
|
- $html = $pageService->publicHtmlHandle($html,$project->id);
|
|
|
|
225
|
- $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_INDEX);
|
|
|
|
226
|
- if ((int)$isVisual == 1 || $isVisual == null){
|
|
|
|
227
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
228
|
- $html = $pageService->generalTemplateProcessingForDataModules($html,$project->id);
|
|
|
|
229
|
- }
|
|
|
|
230
|
- //第三方
|
|
|
|
231
|
- $html = $commonService->thirdPartyCodeHandle($project,$html,RouteMap::SOURCE_INDEX);
|
|
|
|
232
|
- //TDK处理
|
|
|
|
233
|
- $html = $tdkService->pageTdkHandle($project,$html,RouteMap::SOURCE_INDEX,$routerMap);
|
|
|
|
234
|
- if (!empty($html)){
|
|
|
|
235
|
- return $this->pageUrlHandle($project,$routerMap,$html);
|
|
|
|
236
|
- }else{
|
|
|
|
237
|
- return "";
|
|
|
|
238
|
- }
|
|
|
|
239
|
- }else{
|
|
|
|
240
|
- return "";
|
|
|
|
241
|
- }
|
|
|
|
242
|
- }
|
|
|
|
243
|
-
|
|
|
|
244
|
- /**
|
|
|
|
245
|
- * 获取产品列表页html
|
|
|
|
246
|
- */
|
|
|
|
247
|
- public function getProductListPage($project,$routerMap,$page): string
|
|
|
|
248
|
- {
|
|
|
|
249
|
- $pageService = new PageService();
|
|
|
|
250
|
- $commonService = new CommonService();
|
|
|
|
251
|
- $tdkService = new TdkService();
|
|
|
|
252
|
- //公共拼接页面方法
|
|
|
|
253
|
- $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_PRODUCT_CATE,$routerMap);
|
|
|
|
254
|
- //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
|
|
|
|
255
|
- $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_PRODUCT_CATE,$routerMap,$page);
|
|
|
|
256
|
- //是否开启可视化
|
|
|
|
257
|
- $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_PRODUCT_CATE);
|
|
|
|
258
|
- if ((int)$isVisual == 1 || $isVisual == null){
|
|
|
|
259
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
260
|
- $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
|
|
|
|
261
|
- }
|
|
|
|
262
|
- $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_PRODUCT_CATE,$routerMap);
|
|
|
|
263
|
- $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
|
|
|
|
264
|
- unset($pageService);
|
|
|
|
265
|
- $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);
|
|
|
|
266
|
- //处理URL等,处理html链接a标签href
|
|
|
|
267
|
- if (!empty($html)){
|
|
|
|
268
|
- return $this->pageUrlHandle($project,$routerMap,$html,"",$page);
|
|
|
|
269
|
- }else{
|
|
|
|
270
|
- return "";
|
|
|
|
271
|
- }
|
|
|
|
272
|
- }
|
|
|
|
273
|
-
|
|
|
|
274
|
- /**
|
|
|
|
275
|
- * 获取产品页html
|
|
|
|
276
|
- */
|
|
|
|
277
|
- public function getProductPage($project,$routerMap,$lang=''): string
|
|
|
|
278
|
- {
|
|
|
|
279
|
- $pageService = new PageService();
|
|
|
|
280
|
- $commonService = new CommonService();
|
|
|
|
281
|
- $products_detail = Product::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->whereNotNull('route')->first();
|
|
|
|
282
|
- if($project['update_info']['is_update'] && $products_detail && $products_detail->six_read){
|
|
|
|
283
|
- return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
|
|
|
|
284
|
- }else{
|
|
|
|
285
|
- $products_detail = $pageService->productDataHandle($project,$products_detail);
|
|
|
|
286
|
- if (!empty($products_detail)){
|
|
|
|
287
|
- //公共拼接页面方法
|
|
|
|
288
|
- $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_PRODUCT,$routerMap);
|
|
|
|
289
|
- //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
|
|
|
|
290
|
- $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,"product",$routerMap,null);
|
|
|
|
291
|
- $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_PRODUCT);
|
|
|
|
292
|
- if ((int)$isVisual == 1 || $isVisual == null){
|
|
|
|
293
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
294
|
- $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
|
|
|
|
295
|
- }
|
|
|
|
296
|
- $webCustomHtml = $pageService->productsDetailTdkHandle($project,$webCustomHtml,$products_detail);
|
|
|
|
297
|
- $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
|
|
|
|
298
|
- unset($pageService);
|
|
|
|
299
|
- $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);
|
|
|
|
300
|
- //处理URL等,处理html链接a标签href
|
|
|
|
301
|
- if (!empty($html)){
|
|
|
|
302
|
- return $this->pageUrlHandle($project,$routerMap,$html);
|
|
|
|
303
|
- }else{
|
|
|
|
304
|
- return "";
|
|
|
|
305
|
- }
|
|
|
|
306
|
- }else{
|
|
|
|
307
|
- return "";
|
|
|
|
308
|
- }
|
|
|
|
309
|
- }
|
|
|
|
310
|
- }
|
|
|
|
311
|
-
|
|
|
|
312
|
- /**
|
|
|
|
313
|
- * 获取产品关键词页html
|
|
|
|
314
|
- */
|
|
|
|
315
|
- public function getProductKeywordPage($project,$routerMap): string
|
|
|
|
316
|
- {
|
|
|
|
317
|
- $pageService = new PageService();
|
|
|
|
318
|
- $commonService = new CommonService();
|
|
|
|
319
|
- $keywordModel = new Keyword();
|
|
|
|
320
|
- $tdkService = new TdkService();
|
|
|
|
321
|
- $routePath = $routerMap->route;
|
|
|
|
322
|
-
|
|
|
|
323
|
- //公共头部底部
|
|
|
|
324
|
- $publicTemplate = $pageService->getPublicTemplate($project);
|
|
|
|
325
|
- $headerHtml = $publicTemplate->headerHtml;
|
|
|
|
326
|
- $footerHtml = $publicTemplate->footerHtml;
|
|
|
|
327
|
- //关键词详情
|
|
|
|
328
|
- $keywordsDetails = $pageService->getKeywordDetails($project, $routerMap->route);
|
|
|
|
329
|
- if (!empty($keywordsDetails)){
|
|
|
|
330
|
- if (!empty($keywordsDetails->embed_code)){
|
|
|
|
331
|
- $videoUrl = $keywordsDetails->embed_code;
|
|
|
|
332
|
- preg_match('/src="([^"]+)"/', $videoUrl, $matches);
|
|
|
|
333
|
- $src = $matches[1];
|
|
|
|
334
|
- $keywordsDetails->video = $src;
|
|
|
|
335
|
- }
|
|
|
|
336
|
- //随机获取关键词列表
|
|
|
|
337
|
- $productsKeywordsList = $keywordModel->getProductsKeywordsList($project);
|
|
|
|
338
|
- //调整为相关产品
|
|
|
|
339
|
- $productsRecommendAndHot = $pageService->getRecommendAndHotProducts($project,$routePath);
|
|
|
|
340
|
- //博客新闻数据
|
|
|
|
341
|
- $blogT = $pageService->getProductsBlogNews($project);
|
|
|
|
342
|
- $viewPath = isset($keywordsDetails->video) && !empty($keywordsDetails->video) ? "products/products_video_keywords" : "products/products_keywords";
|
|
|
|
343
|
- $html = view($viewPath, compact("headerHtml", "footerHtml", "routePath", "productsKeywordsList", "productsRecommendAndHot", "blogT","keywordsDetails"))->__toString();
|
|
|
|
344
|
- $html = $pageService->publicHtmlHandle($html, $project->id);
|
|
|
|
345
|
- //生成静态页
|
|
|
|
346
|
- $webCustomHtml = $commonService->thirdPartyCodeHandle($project, $html, $routerMap->route);
|
|
|
|
347
|
- //TDK
|
|
|
|
348
|
- unset($html,$productsKeywordsList,$productsRecommendAndHot,$blogT);
|
|
|
|
349
|
- $html = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_PRODUCT_KEYWORD,$routerMap);
|
|
|
|
350
|
- //处理URL等,处理html链接a标签href
|
|
|
|
351
|
- if (!empty($html)){
|
|
|
|
352
|
- return $this->pageUrlHandle($project,$routerMap,$html);
|
|
|
|
353
|
- }else{
|
|
|
|
354
|
- return "";
|
|
|
|
355
|
- }
|
|
|
|
356
|
- }else{
|
|
|
|
357
|
- return "";
|
|
|
|
358
|
- }
|
|
|
|
359
|
- }
|
|
|
|
360
|
-
|
|
|
|
361
|
- /**
|
|
|
|
362
|
- * 获取产品新闻列表页html
|
|
|
|
363
|
- */
|
|
|
|
364
|
- public function getNewsListPage($project,$routerMap,$page): string
|
|
|
|
365
|
- {
|
|
|
|
366
|
- $pageService = new PageService();
|
|
|
|
367
|
- $commonService = new CommonService();
|
|
|
|
368
|
- $tdkService = new TdkService();
|
|
|
|
369
|
- $routePath = $routerMap->route;
|
|
|
|
370
|
- //公共拼接页面方法
|
|
|
|
371
|
- $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_NEWS_CATE,$routerMap);
|
|
|
|
372
|
- //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
|
|
|
|
373
|
- $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_NEWS_CATE,$routerMap,$page);
|
|
|
|
374
|
- $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_NEWS_CATE);
|
|
|
|
375
|
- if ((int)$isVisual == 1 || $isVisual == null){
|
|
|
|
376
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
377
|
- $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
|
|
|
|
378
|
- }
|
|
|
|
379
|
- $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_NEWS_CATE,$routerMap);
|
|
|
|
380
|
- $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
|
|
|
|
381
|
- unset($pageService);
|
|
|
|
382
|
- $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);
|
|
|
|
383
|
- //处理URL等,处理html链接a标签href
|
|
|
|
384
|
- if (!empty($html)){
|
|
|
|
385
|
- return $this->pageUrlHandle($project,$routerMap,$html,"",$page);
|
|
|
|
386
|
- }else{
|
|
|
|
387
|
- return "";
|
|
|
|
388
|
- }
|
|
|
|
389
|
-
|
|
|
|
390
|
- }
|
|
|
|
391
|
-
|
|
|
|
392
|
- /**
|
|
|
|
393
|
- * 自定义模块列表
|
|
|
|
394
|
- */
|
|
|
|
395
|
- public function getModuleListPage($project,$routerMap,$page): string
|
|
|
|
396
|
- {
|
|
|
|
397
|
- $pageService = new PageService();
|
|
|
|
398
|
- $commonService = new CommonService();
|
|
|
|
399
|
- $tdkService = new TdkService();
|
|
|
|
400
|
- $routePath = $routerMap->route;
|
|
|
|
401
|
- //公共拼接页面方法
|
|
|
|
402
|
- $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_MODULE_CATE,$routerMap);
|
|
|
|
403
|
- //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
|
|
|
|
404
|
- $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_MODULE_CATE,$routerMap,$page);
|
|
|
|
405
|
- $moduleCategoryInfo = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);
|
|
|
|
406
|
- if (isset($moduleCategoryInfo->getExtend->list_visualization) && $moduleCategoryInfo->getExtend->list_visualization == 1){
|
|
|
|
407
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
408
|
- $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
|
|
|
|
409
|
- }
|
|
|
|
410
|
-
|
|
|
|
411
|
- $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_MODULE_CATE,$routerMap);
|
|
|
|
412
|
- $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
|
|
|
|
413
|
- unset($pageService);
|
|
|
|
414
|
- $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);
|
|
|
|
415
|
- //处理URL等,处理html链接a标签href
|
|
|
|
416
|
- if (!empty($html)){
|
|
|
|
417
|
- return $this->pageUrlHandle($project,$routerMap,$html,"",$page);
|
|
|
|
418
|
- }else{
|
|
|
|
419
|
- return "";
|
|
|
|
420
|
- }
|
|
|
|
421
|
- }
|
|
|
|
422
|
-
|
|
|
|
423
|
- /**
|
|
|
|
424
|
- * 获取新闻页html
|
|
|
|
425
|
- */
|
|
|
|
426
|
- public function getNewsPage($project,$routerMap,$lang=''): string
|
|
|
|
427
|
- {
|
|
|
|
428
|
- $pageService = new PageService();
|
|
|
|
429
|
- $commonService = new CommonService();
|
|
|
|
430
|
- $tdkService = new TdkService();
|
|
|
|
431
|
- //页面路由
|
|
|
|
432
|
- $routePath = $routerMap->route;
|
|
|
|
433
|
- $news_detail = News::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
|
|
|
|
434
|
- if (!empty($news_detail)){
|
|
|
|
435
|
- if($project['update_info']['is_update'] && $news_detail->six_read){
|
|
|
|
436
|
- return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
|
|
|
|
437
|
- }else{
|
|
|
|
438
|
- //公共拼接页面方法
|
|
|
|
439
|
- $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_NEWS,$routerMap);
|
|
|
|
440
|
- //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
|
|
|
|
441
|
- $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_NEWS,$routerMap,null);
|
|
|
|
442
|
- $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_NEWS);
|
|
|
|
443
|
- if ((int)$isVisual == 1 || $isVisual == null){
|
|
|
|
444
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
445
|
- $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
|
|
|
|
446
|
- }
|
|
|
|
447
|
- //TDK处理
|
|
|
|
448
|
- $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_NEWS,$routerMap);
|
|
|
|
449
|
- //网页公共部分
|
|
|
|
450
|
- $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
|
|
|
|
451
|
- unset($pageService);
|
|
|
|
452
|
- $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);
|
|
|
|
453
|
- //处理URL等,处理html链接a标签href
|
|
|
|
454
|
- if (!empty($html)){
|
|
|
|
455
|
- return $this->pageUrlHandle($project,$routerMap,$html);
|
|
|
|
456
|
- }else{
|
|
|
|
457
|
- return "";
|
|
|
|
458
|
- }
|
|
|
|
459
|
- }
|
|
|
|
460
|
- }else{
|
|
|
|
461
|
- return "";
|
|
|
|
462
|
- }
|
|
|
|
463
|
- }
|
|
|
|
464
|
-
|
|
|
|
465
|
- /**
|
|
|
|
466
|
- * 自定义模块详情
|
|
|
|
467
|
- */
|
|
|
|
468
|
- public function getModulePage($project,$routerMap,$lang=''): string
|
|
|
|
469
|
- {
|
|
|
|
470
|
- $pageService = new PageService();
|
|
|
|
471
|
- $commonService = new CommonService();
|
|
|
|
472
|
- $tdkService = new TdkService();
|
|
|
|
473
|
- //页面路由
|
|
|
|
474
|
- $routePath = $routerMap->route;
|
|
|
|
475
|
- $module_detail = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
|
|
|
|
476
|
- if (!empty($module_detail)){
|
|
|
|
477
|
- if($project['update_info']['is_update'] && $module_detail->six_read){
|
|
|
|
478
|
- return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
|
|
|
|
479
|
- }else{
|
|
|
|
480
|
- //公共拼接页面方法
|
|
|
|
481
|
- $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_MODULE,$routerMap);
|
|
|
|
482
|
- //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
|
|
|
|
483
|
- $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_MODULE,$routerMap,null);
|
|
|
|
484
|
- $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$module_detail);
|
|
|
|
485
|
- if (isset($moduleCategoryInfo->getExtend->detail_visualization) && $moduleCategoryInfo->getExtend->detail_visualization == 1){
|
|
|
|
486
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
487
|
- $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
|
|
|
|
488
|
- }
|
|
|
|
489
|
- //TDK处理
|
|
|
|
490
|
- $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_MODULE,$routerMap);
|
|
|
|
491
|
- //网页公共部分
|
|
|
|
492
|
- $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
|
|
|
|
493
|
- unset($pageService);
|
|
|
|
494
|
- $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routePath);
|
|
|
|
495
|
- //处理URL等,处理html链接a标签href
|
|
|
|
496
|
- if (!empty($html)){
|
|
|
|
497
|
- return $this->pageUrlHandle($project,$routerMap,$html);
|
|
|
|
498
|
- }else{
|
|
|
|
499
|
- return "";
|
|
|
|
500
|
- }
|
|
|
|
501
|
- }
|
|
|
|
502
|
- }else{
|
|
|
|
503
|
- return "";
|
|
|
|
504
|
- }
|
|
|
|
505
|
- }
|
|
|
|
506
|
-
|
|
|
|
507
|
- /**
|
|
|
|
508
|
- * 获取博客列表页html
|
|
|
|
509
|
- */
|
|
|
|
510
|
- public function getBlogListPage($project,$routerMap,$page): string
|
|
|
|
511
|
- {
|
|
|
|
512
|
- $pageService = new PageService();
|
|
|
|
513
|
- $commonService = new CommonService();
|
|
|
|
514
|
- $tdkService = new TdkService();
|
|
|
|
515
|
- //公共拼接页面方法
|
|
|
|
516
|
- $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_BLOG_CATE,$routerMap);
|
|
|
|
517
|
- //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
|
|
|
|
518
|
- $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_BLOG_CATE,$routerMap,$page);
|
|
|
|
519
|
- $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_BLOG_CATE);
|
|
|
|
520
|
- if ((int)$isVisual == 1 || $isVisual == null){
|
|
|
|
521
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
522
|
- $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
|
|
|
|
523
|
- }
|
|
|
|
524
|
- $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_BLOG_CATE,$routerMap);
|
|
|
|
525
|
- $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
|
|
|
|
526
|
- unset($pageService);
|
|
|
|
527
|
- $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);
|
|
|
|
528
|
- //处理URL等,处理html链接a标签href
|
|
|
|
529
|
- if (!empty($html)){
|
|
|
|
530
|
- return $this->pageUrlHandle($project,$routerMap,$html,"",$page);
|
|
|
|
531
|
- }else{
|
|
|
|
532
|
- return "";
|
|
|
|
533
|
- }
|
|
|
|
534
|
- }
|
|
|
|
535
|
-
|
|
|
|
536
|
- /**
|
|
|
|
537
|
- * 获取博客页html
|
|
|
|
538
|
- */
|
|
|
|
539
|
- public function getBlogPage($project,$routerMap,$lang=''): string
|
|
|
|
540
|
- {
|
|
|
|
541
|
- $pageService = new PageService();
|
|
|
|
542
|
- $commonService = new CommonService();
|
|
|
|
543
|
- $tdkService = new TdkService();
|
|
|
|
544
|
- $blog_detail = Blog::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",1)->first();
|
|
|
|
545
|
- if (!empty($blog_detail)){
|
|
|
|
546
|
- if($project['update_info']['is_update'] && $blog_detail->six_read){
|
|
|
|
547
|
- return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
|
|
|
|
548
|
- }else{
|
|
|
|
549
|
- //公共拼接页面方法
|
|
|
|
550
|
- $webCustomHtml = $pageService->publicMontagePage($project,RouteMap::SOURCE_BLOG,$routerMap);
|
|
|
|
551
|
- //公共面包屑导航,左侧导航处理,内页banner背景图,列表页分页
|
|
|
|
552
|
- $webCustomHtml = $pageService->publicMdAndLeftNavInnerImageListDetailsDataHandle($webCustomHtml,$project,RouteMap::SOURCE_BLOG,$routerMap,null);
|
|
|
|
553
|
- $isVisual = $pageService->isOpenVisualization($project,RouteMap::SOURCE_BLOG);
|
|
|
|
554
|
- if ((int)$isVisual == 1 || $isVisual == null){
|
|
|
|
555
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
556
|
- $webCustomHtml = $pageService->generalTemplateProcessingForDataModules($webCustomHtml,$project->id);
|
|
|
|
557
|
- }
|
|
|
|
558
|
- $webCustomHtml = $tdkService->pageTdkHandle($project,$webCustomHtml,RouteMap::SOURCE_BLOG,$routerMap);
|
|
|
|
559
|
- $webCustomHtml = $pageService->publicHtmlHandle($webCustomHtml,$project->id);
|
|
|
|
560
|
- unset($pageService);
|
|
|
|
561
|
- //生成静态页
|
|
|
|
562
|
- $html = $commonService->thirdPartyCodeHandle($project,$webCustomHtml,$routerMap->route);
|
|
|
|
563
|
- //处理URL等,处理html链接a标签href
|
|
|
|
564
|
- if (!empty($html)){
|
|
|
|
565
|
- return $this->pageUrlHandle($project,$routerMap,$html);
|
|
|
|
566
|
- }else{
|
|
|
|
567
|
- return "";
|
|
|
|
568
|
- }
|
|
|
|
569
|
- }
|
|
|
|
570
|
- }else{
|
|
|
|
571
|
- return "";
|
|
|
|
572
|
- }
|
|
|
|
573
|
- }
|
|
|
|
574
|
-
|
|
|
|
575
|
- /**
|
|
|
|
576
|
- * 获取单页面html
|
|
|
|
577
|
- */
|
|
|
|
578
|
- public function getSinglePage($project,$routerMap,$lang=''): string
|
|
|
|
579
|
- {
|
|
|
|
580
|
- $pageService = new PageService();
|
|
|
|
581
|
- $commonService = new CommonService();
|
|
|
|
582
|
- $tdkService = new TdkService();
|
|
|
|
583
|
- //页面路由
|
|
|
|
584
|
- $routePath = $routerMap->route;
|
|
|
|
585
|
- $webCustom = BCustomTemplate::where("id",$routerMap->source_id)->where("status",1)->first();
|
|
|
|
586
|
- if (!empty($webCustom)){
|
|
|
|
587
|
- if($project['update_info']['is_update'] && $webCustom->six_read){
|
|
|
|
588
|
- return $this->getOldHtml($project,$routerMap,$project['update_info']['old_domain_test'],$project['update_info']['old_domain_online'],$lang);
|
|
|
|
589
|
- }else{
|
|
|
|
590
|
- //公共拼接页面方法
|
|
|
|
591
|
- $content = $pageService->publicMontagePage($project,RouteMap::SOURCE_PAGE,$routerMap);
|
|
|
|
592
|
- //公共左侧导航处理
|
|
|
|
593
|
- $phpQueryDom=phpQuery::newDocument($content);
|
|
|
|
594
|
- $pageService->leftNavSideNavHandle($project,RouteMap::SOURCE_PAGE,$phpQueryDom,$routerMap);
|
|
|
|
595
|
- $content = $phpQueryDom->htmlOuter();
|
|
|
|
596
|
- unset($phpQueryDom);
|
|
|
|
597
|
- //产品,产品分类,新闻,博客(section模板通用数据模块处理)
|
|
|
|
598
|
- $content = $pageService->generalTemplateProcessingForDataModules($content,$project->id);
|
|
|
|
599
|
- //生成静态页
|
|
|
|
600
|
- $content = $tdkService->pageTdkHandle($project,$content,RouteMap::SOURCE_PAGE,$routerMap);
|
|
|
|
601
|
- $content = $pageService->publicHtmlHandle($content,$project->id);
|
|
|
|
602
|
- unset($pageService);
|
|
|
|
603
|
- $html = $commonService->thirdPartyCodeHandle($project,$content,$routePath,$routerMap);
|
|
|
|
604
|
- //处理URL等,处理html链接a标签href
|
|
|
|
605
|
- if (!empty($html)){
|
|
|
|
606
|
- return $this->pageUrlHandle($project,$routerMap,$html);
|
|
|
|
607
|
- }else{
|
|
|
|
608
|
- return "";
|
|
|
|
609
|
- }
|
|
|
|
610
|
- }
|
|
|
|
611
|
- }else{
|
|
|
|
612
|
- return "";
|
|
|
|
613
|
- }
|
|
|
|
614
|
- }
|
|
|
|
615
|
-
|
|
|
|
616
|
- /**
|
|
|
|
617
|
- * 获取关键词列表页面
|
|
|
|
618
|
- */
|
|
|
|
619
|
- public function getProductKeywordListPage($project,$router,$page): string
|
|
|
|
620
|
- {
|
|
|
|
621
|
- if (isset($router->route) && $router->route != null) {
|
|
|
|
622
|
- $routePath = $router->route;
|
|
|
|
623
|
- } else {
|
|
|
|
624
|
- $routePath = $router;
|
|
|
|
625
|
- }
|
|
|
|
626
|
- //公共头部底部
|
|
|
|
627
|
- $pageService = new PageService();
|
|
|
|
628
|
- $commonService = new CommonService();
|
|
|
|
629
|
- $publicTemplate = $pageService->getPublicTemplate($project);
|
|
|
|
630
|
- $headerHtml = $publicTemplate->headerHtml;
|
|
|
|
631
|
- $footerHtml = $publicTemplate->footerHtml;
|
|
|
|
632
|
-
|
|
|
|
633
|
- //获取字母开头关键词列表
|
|
|
|
634
|
- $keywords = $pageService->getProductKeywordsByLetter($project,$router,$page);
|
|
|
|
635
|
- $html = view("products/products_keywords_list",compact("headerHtml","footerHtml","keywords","routePath"))->__toString();
|
|
|
|
636
|
- $html = $pageService->publicHtmlHandle($html, $project->id);
|
|
|
|
637
|
- //生成静态页
|
|
|
|
638
|
- $webCustomHtml = $commonService->thirdPartyCodeHandle($project, $html, $routePath);
|
|
|
|
639
|
- //top-search TDK处理,分页link索引处理
|
|
|
|
640
|
- $webCustomHtml = $pageService->productKeywordListTdkHandle($webCustomHtml,$project,$routePath,$keywords,$page);
|
|
|
|
641
|
- //处理URL等,处理html链接a标签href
|
|
|
|
642
|
- if (!empty($html)){
|
|
|
|
643
|
- $webCustomHtml = $this->pageUrlHandle($project,$routePath,$webCustomHtml);
|
|
|
|
644
|
- }else{
|
|
|
|
645
|
- return "";
|
|
|
|
646
|
- }
|
|
|
|
647
|
- unset($keywords);
|
|
|
|
648
|
- unset($html);
|
|
|
|
649
|
- return $webCustomHtml;
|
|
|
|
650
|
- }
|
|
|
|
651
|
-
|
|
|
|
652
|
- /**
|
|
|
|
653
|
- * TODO:处理URL等,处理html链接a标签href,获取最终html
|
|
|
|
654
|
- */
|
|
|
|
655
|
- public function pageUrlHandle($project,$routerMap,$html,$lang="",$page=null): string
|
|
|
|
656
|
- {
|
|
|
|
657
|
- if (isset($routerMap->route) && $routerMap->route != null) {
|
|
|
|
658
|
- $route = $routerMap->route;
|
|
|
|
659
|
- } else {
|
|
|
|
660
|
- $route = $routerMap;
|
|
|
|
661
|
- }
|
|
|
|
662
|
- $pageService = new PageService();
|
|
|
|
663
|
- $phpQueryDom=phpQuery::newDocument($html);
|
|
|
|
664
|
- $domainEnd = $project->domain_end;
|
|
|
|
665
|
- //主站a链接处理
|
|
|
|
666
|
- $this->masterWebATagHandle($phpQueryDom,$project,$domainEnd);
|
|
|
|
667
|
- //html 标签处理
|
|
|
|
668
|
- $this->htmlTagHandle($phpQueryDom,$project);
|
|
|
|
669
|
- //国家
|
|
|
|
670
|
- $webCountry = $pageService->getCountryList($project->id);
|
|
|
|
671
|
- //语种 alternate
|
|
|
|
672
|
- $this->setHrefLang($phpQueryDom,$project,$route,$page,$lang,$webCountry);
|
|
|
|
673
|
- //以-tag的聚合页结尾的路由加上 <meta name="robots" content="noindex">
|
|
|
|
674
|
- $this->setTagRobotsNoindex($phpQueryDom,$routerMap);
|
|
|
|
675
|
- //<meta name="cookie_consent_banner" content="参数值"> 配置
|
|
|
|
676
|
- $this->setCookieConsentBanner($phpQueryDom,$project);
|
|
|
|
677
|
-
|
|
|
|
678
|
- $html = $phpQueryDom->htmlOuter();
|
|
|
|
679
|
- unset($phpQueryDom);
|
|
|
|
680
|
- phpQuery::unloadDocuments();
|
|
|
|
681
|
-
|
|
|
|
682
|
- //根据配置读取不同的资源路径功能
|
|
|
|
683
|
- $html = $this->setResourcePath($project,$html);
|
|
|
|
684
|
- //网站语种列表
|
|
|
|
685
|
- return $pageService->publicCountryLanguageHandle($html,$project,$route);
|
|
|
|
686
|
- }
|
|
|
|
687
|
-
|
|
|
|
688
|
- /**
|
|
|
|
689
|
- * html 标签处理
|
|
|
|
690
|
- */
|
|
|
|
691
|
- public function htmlTagHandle($phpQueryDom,$project)
|
|
|
|
692
|
- {
|
|
|
|
693
|
- $phpQueryDom->find("html")->attr("dir","ltr");
|
|
|
|
694
|
- $mainLang = WebLanguage::getProjectMainLang($project->main_lang_id);
|
|
|
|
695
|
- if ($mainLang->short == "ru"){
|
|
|
|
696
|
- $phpQueryDom->find('main .keyword_search')->remove();
|
|
|
|
697
|
- }
|
|
|
|
698
|
- $lang = $mainLang ? $mainLang->short : 'en';
|
|
|
|
699
|
- $phpQueryDom->find("html")->attr("lang",$lang);
|
|
|
|
700
|
- }
|
|
|
|
701
|
-
|
|
|
|
702
|
- /**
|
|
|
|
703
|
- * 888项目禁用鼠标右键点击,查看元素
|
|
|
|
704
|
- */
|
|
|
|
705
|
- public function prohibitRightMouseClick($phpQueryDom,$project)
|
|
|
|
706
|
- {
|
|
|
|
707
|
- if ($project->id == 888){
|
|
|
|
708
|
- $phpQueryDom->find("body")->attr("ondragstart","window.event.returnValue=false");
|
|
|
|
709
|
- $phpQueryDom->find("body")->attr("oncontextmenu","window.event.returnValue=false");
|
|
|
|
710
|
- $phpQueryDom->find("body")->attr("onselectstart","event.returnValue=false");
|
|
|
|
711
|
- }
|
|
|
|
712
|
- }
|
|
|
|
713
|
-
|
|
|
|
714
|
- /**
|
|
|
|
715
|
- *主站a链接处理
|
|
|
|
716
|
- */
|
|
|
|
717
|
- public function masterWebATagHandle($phpQueryDom,$project,$domainEnd)
|
|
|
|
718
|
- {
|
|
|
|
719
|
- foreach ($phpQueryDom->find('a') as $a) {
|
|
|
|
720
|
- $href = pq($a)->attr('href');
|
|
|
|
721
|
- //a标签href字符串是否有http://或者https://等协议头,有的话不做处理
|
|
|
|
722
|
- if (strpos($href, 'http://') !== false || strpos($href, 'https://') !== false || strpos($href, 'javascript') !== false || strpos($href, 'javasctipt') !== false || strpos($href, '#') !== false || empty($href) || strpos($href, '.zip') !== false || strpos($href, '.txt') !== false || strpos($href, 'tel:') !== false || strpos($href, 'mailto') !== false || strpos($href, '.pdf') !== false || strpos($href, '.tar') !== false || strpos($href, '.jpg') !== false || strpos($href, '.png') !== false || strpos($href, '.jpeg') !== false || strpos($href, '.xml') !== false || strpos($href, 'skype:') !== false || strpos($href, 'whatsapp:') !== false) {
|
|
|
|
723
|
- $domain = $project->domain;
|
|
|
|
724
|
- $domain = str_replace("http://","",$domain);
|
|
|
|
725
|
- $domain = str_replace("https://","",$domain);
|
|
|
|
726
|
- $domain = str_replace("/","",$domain);
|
|
|
|
727
|
- $domainArr = parse_url($domain);
|
|
|
|
728
|
- if (strpos($href, '#') !== false || strpos($href, '.xml') !== false){}else{
|
|
|
|
729
|
- if (isset($domainArr["path"]) && !empty($domainArr["path"])){
|
|
|
|
730
|
- if (strpos($href, 'http://') !== false || strpos($href, 'https://') !== false){
|
|
|
|
731
|
- $domain = $domainArr["path"];
|
|
|
|
732
|
- if (strpos($href, $domain) !== false){
|
|
|
|
733
|
- $href = str_replace("http://","",$href);
|
|
|
|
734
|
- $href = str_replace("https://","",$href);
|
|
|
|
735
|
- $href = str_replace($domain,"",$href);
|
|
|
|
736
|
- if ($domainEnd == Project::$domainEndSlash){
|
|
|
|
737
|
- //以斜杠结尾
|
|
|
|
738
|
- $href = substr($href, -1) === '/' ? $href : $href . "/";
|
|
|
|
739
|
- }else{
|
|
|
|
740
|
- //不以斜杠结尾
|
|
|
|
741
|
- if (substr($href, -1) === '/') {
|
|
|
|
742
|
- if ($href != "/"){
|
|
|
|
743
|
- $href = rtrim($href, '/');
|
|
|
|
744
|
- }
|
|
|
|
745
|
- }
|
|
|
|
746
|
- }
|
|
|
|
747
|
- }
|
|
|
|
748
|
- }
|
|
|
|
749
|
- }
|
|
|
|
750
|
- }
|
|
|
|
751
|
- pq($a)->attr('href', $href);
|
|
|
|
752
|
- }else{
|
|
|
|
753
|
- if ($domainEnd == Project::$domainEndSlash){
|
|
|
|
754
|
- //以斜杠结尾
|
|
|
|
755
|
- $href = substr($href, -1) === '/' ? $href : $href . "/";
|
|
|
|
756
|
- if (strpos($href, ".html") !== false || strpos($href, ".htm") !== false){
|
|
|
|
757
|
- $href = rtrim($href, '/');
|
|
|
|
758
|
- }
|
|
|
|
759
|
- }else{
|
|
|
|
760
|
- //不以斜杠结尾
|
|
|
|
761
|
- if (substr($href, -1) === '/') {
|
|
|
|
762
|
- if ($href != "/"){
|
|
|
|
763
|
- $href = rtrim($href, '/');
|
|
|
|
764
|
- }
|
|
|
|
765
|
- }
|
|
|
|
766
|
- }
|
|
|
|
767
|
- }
|
|
|
|
768
|
- pq($a)->attr('href', $href);
|
|
|
|
769
|
- }
|
|
|
|
770
|
- }
|
|
|
|
771
|
-
|
|
|
|
772
|
- /**
|
|
|
|
773
|
- * <meta name="cookie_consent_banner" content="参数值"> 配置
|
|
|
|
774
|
- */
|
|
|
|
775
|
- public function setCookieConsentBanner($phpQueryDom,$project)
|
|
|
|
776
|
- {
|
|
|
|
777
|
- $deployBuildInfo = DeployBuild::where("project_id",$project->id)->first();
|
|
|
|
778
|
- if (!empty($deployBuildInfo)){
|
|
|
|
779
|
- $phpQueryDom->find('head')->append('<meta name="cookie_consent_banner" content="'.$deployBuildInfo->cookie_consent_banner.'">');
|
|
|
|
780
|
- }
|
|
|
|
781
|
- }
|
|
|
|
782
|
-
|
|
|
|
783
|
- /**
|
|
|
|
784
|
- * 语种 alternate
|
|
|
|
785
|
- */
|
|
|
|
786
|
- public function setHrefLang($phpQueryDom,$project,$route,$page,$lang,$webCountry)
|
|
|
|
787
|
- {
|
|
|
|
788
|
- //处理源代码语言url
|
|
|
|
789
|
- $countryUrl = [];
|
|
|
|
790
|
- $createPageService = new CreatePageService();
|
|
|
|
791
|
- $domain = $createPageService->domainHandle($project->domain);
|
|
|
|
792
|
- $mainLang = WebLanguage::getProjectMainLang($project->main_lang_id);
|
|
|
|
793
|
- if (!empty($webCountry)) {
|
|
|
|
794
|
- foreach ($webCountry as $key => $item) {
|
|
|
|
795
|
- //语种列表调整,新增自定义跳转链接
|
|
|
|
796
|
- if (isset($item->country_custom) && !empty($item->country_custom)){
|
|
|
|
797
|
- if ($item->country_custom->is_create == 1){
|
|
|
|
798
|
- $page = (int)$page != null && (int)$page != 0 ? (int)$page . "/" : "";
|
|
|
|
799
|
- if (!empty($mainLang) && $item->short != $mainLang->short){
|
|
|
|
800
|
- $countryUrl[$key]["url"] = "https://" . $item->country_custom->custom_domain . "/" . $route . "/" . $page;
|
|
|
|
801
|
- }else{
|
|
|
|
802
|
- $countryUrl[$key]["url"] = "https://" . $domain . "/" . $route . "/" . $page;
|
|
|
|
803
|
- }
|
|
|
|
804
|
- }else{
|
|
|
|
805
|
- $countryUrl[$key]["url"] = "https://" . $item->country_custom->custom_domain . "/";
|
|
|
|
806
|
- }
|
|
|
|
807
|
- $countryUrl[$key]["alias"] = $item->short;
|
|
|
|
808
|
- }else{
|
|
|
|
809
|
- if (!empty($mainLang) && $item->short != $mainLang->short){
|
|
|
|
810
|
- $langShort = $item->short."/";
|
|
|
|
811
|
- }else{
|
|
|
|
812
|
- $langShort = "";
|
|
|
|
813
|
- }
|
|
|
|
814
|
- if ((int)$page != null) {
|
|
|
|
815
|
- $countryUrl[$key]["url"] = "https://" . $domain . "/" .$langShort . $route . "/" . (int)$page . "/";
|
|
|
|
816
|
- } else {
|
|
|
|
817
|
- $countryUrl[$key]["url"] = $route == "index" ? "https://" . $domain . "/" . $langShort : "https://" . $domain . "/" . $langShort. $route . "/";
|
|
|
|
818
|
- }
|
|
|
|
819
|
- $countryUrl[$key]["alias"] = $item->short;
|
|
|
|
820
|
- }
|
|
|
|
821
|
- }
|
|
|
|
822
|
- }
|
|
|
|
823
|
- //路径
|
|
|
|
824
|
- if ($route == "index") {
|
|
|
|
825
|
- $webUrl = "https://" . $domain . "/";
|
|
|
|
826
|
- } else {
|
|
|
|
827
|
- if ((int)$page != null || (int)$page != 0) {
|
|
|
|
828
|
- if ($lang != "") {
|
|
|
|
829
|
- $langShort = $lang == "en" ? "" : $lang."/";
|
|
|
|
830
|
- $webUrl = "https://" . $domain . "/" .$langShort. $route . "/" . (int)$page . "/";
|
|
|
|
831
|
- } else {
|
|
|
|
832
|
- $webUrl = "https://" . $domain . "/" . $route . "/" . (int)$page . "/";
|
|
|
|
833
|
- }
|
|
|
|
834
|
- } else {
|
|
|
|
835
|
- if ($lang != "") {
|
|
|
|
836
|
- $langShort = $lang == "en" ? "" : $lang."/";
|
|
|
|
837
|
- $webUrl = "https://" . $domain . "/" . $langShort . $route . "/";
|
|
|
|
838
|
- } else {
|
|
|
|
839
|
- $webUrl = "https://" . $domain . "/" . $route . "/";
|
|
|
|
840
|
- }
|
|
|
|
841
|
- }
|
|
|
|
842
|
- }
|
|
|
|
843
|
- $phpQueryDom->find('head')->append("<meta property='og:url' content='$route'/>");
|
|
|
|
844
|
- $phpQueryDom->find('head')->append("<link rel='canonical' href='$webUrl' />");
|
|
|
|
845
|
- if (!empty($countryUrl)){
|
|
|
|
846
|
- foreach ($countryUrl as $item){
|
|
|
|
847
|
- if (isset($item['alias']) && isset($item['url'])){
|
|
|
|
848
|
- $phpQueryDom->find('head')->append("<link rel='alternate' hreflang='".$item['alias']."' href='".$item['url']."'>");
|
|
|
|
849
|
- }
|
|
|
|
850
|
- }
|
|
|
|
851
|
- }
|
|
|
|
852
|
- }
|
|
|
|
853
|
-
|
|
|
|
854
|
- /**
|
|
|
|
855
|
- * 以-tag的聚合页结尾的路由加上 <meta name="robots" content="noindex">
|
|
|
|
856
|
- */
|
|
|
|
857
|
- public function setTagRobotsNoindex($phpQueryDom,$routerMap)
|
|
|
|
858
|
- {
|
|
|
|
859
|
- if (isset($routerMap->source) && $routerMap->source == RouteMap::SOURCE_PRODUCT_KEYWORD){
|
|
|
|
860
|
- $routerSuffix = substr($routerMap->route, -4);
|
|
|
|
861
|
- $routerLength = strlen($routerMap->route);
|
|
|
|
862
|
- if ($routerLength >= 4 && $routerSuffix == "-tag"){
|
|
|
|
863
|
- $phpQueryDom->find('head')->append('<meta name="robots" content="noindex,nofollow">');
|
|
|
|
864
|
- }
|
|
|
|
865
|
- }
|
|
|
|
866
|
- }
|
|
|
|
867
|
-
|
|
|
|
868
|
- /**
|
|
|
|
869
|
- * 配置资源路径
|
|
|
|
870
|
- */
|
|
|
|
871
|
- public function setResourcePath($project,$html)
|
|
|
|
872
|
- {
|
|
|
|
873
|
- $projectLocation = $project->project_location;
|
|
|
|
874
|
- $storageType = $project->storage_type;
|
|
|
|
875
|
- $cos = config('filesystems.disks.cos');
|
|
|
|
876
|
- if ($projectLocation == Project::$projectLocationZero){
|
|
|
|
877
|
- //普通项目
|
|
|
|
878
|
- if ($storageType == Project::$storageTypeZero){
|
|
|
|
879
|
- //压缩项目
|
|
|
|
880
|
- $html = str_replace($cos['cdn1'],$cos['cdn'],$html);
|
|
|
|
881
|
- }else{
|
|
|
|
882
|
- //非压缩项目
|
|
|
|
883
|
- $html = str_replace($cos['cdn'],$cos['cdn1'],$html);
|
|
|
|
884
|
- }
|
|
|
|
885
|
- }else{
|
|
|
|
886
|
- $s3 = config('filesystems.disks.s3');
|
|
|
|
887
|
- //危险项目
|
|
|
|
888
|
- $html = str_replace($cos['cdn1'],$s3['cdn'],$html);
|
|
|
|
889
|
- $html = str_replace($cos['cdn'],$s3['cdn'],$html);
|
|
|
|
890
|
- }
|
|
|
|
891
|
- return $html;
|
|
|
|
892
|
- }
|
|
|
|
893
|
-
|
|
|
|
894
|
- /**
|
|
|
|
895
|
- * 放入文件
|
|
|
|
896
|
- */
|
|
|
|
897
|
- public function putHtmlToPageFile($project,$lang,$route,$page,$html,$routeType=""): bool
|
|
|
|
898
|
- {
|
|
|
|
899
|
- if (empty($html) || $html == ""){
|
|
|
|
900
|
- return true;
|
|
|
|
901
|
- }
|
|
|
|
902
|
- if (strpos($route, '.php') !== false || strpos($route, '.env') !== false || strpos($route, '.jpg') !== false || strpos($route, '.asp') !== false || strpos($route, '.png') !== false || strpos($route, '.gif') !== false ){
|
|
|
|
903
|
- return true;
|
|
|
|
904
|
- }
|
|
|
|
905
|
- $domain = $project->domain;
|
|
|
|
906
|
- $domain = str_replace("https://","",$domain);
|
|
|
|
907
|
- $domain = str_replace("http://","",$domain);
|
|
|
|
908
|
- $domain = str_replace("/","",$domain);
|
|
|
|
909
|
- $originLang = $lang;
|
|
|
|
910
|
- $lang = $lang == "zh-TW" ? "zh-ct" : $lang;
|
|
|
|
911
|
- $lang = $lang=="" ? "" : "/".$lang;
|
|
|
|
912
|
- $page = $page == null || (int)$page == 1 ? null : "/".(int)$page;
|
|
|
|
913
|
-
|
|
|
|
914
|
- //是否是5.0升级项目
|
|
|
|
915
|
- if (isset($project->update_info["is_update"]) && $project->update_info["is_update"] == 1){
|
|
|
|
916
|
- //5.0生成路径
|
|
|
|
917
|
- $path = $this->getProjectRoutePath5($project,$domain,$route,$routeType,$lang,$page);
|
|
|
|
918
|
- }else{
|
|
|
|
919
|
- //6.0生成路径
|
|
|
|
920
|
- $path = $this->getProjectRoutePath6($project,$domain,$route,$routeType,$lang,$page);
|
|
|
|
921
|
- }
|
|
|
|
922
|
- try {
|
|
|
|
923
|
- //$filePath = iconv("UTF-8", "GBK", $path);
|
|
|
|
924
|
- $filePath = $path;
|
|
|
|
925
|
- if (!file_exists(public_path($filePath))) {
|
|
|
|
926
|
- mkdir(public_path($filePath), 0777, true);
|
|
|
|
927
|
- }
|
|
|
|
928
|
- if (strpos($route, ".html") !== false || strpos($route, ".htm") !== false) {
|
|
|
|
929
|
- file_put_contents(public_path($filePath . ".html"), $html);
|
|
|
|
930
|
- chmod(public_path($filePath . ".html"), 0777);
|
|
|
|
931
|
- }else{
|
|
|
|
932
|
- file_put_contents(public_path($filePath . "/index.html"), $html);
|
|
|
|
933
|
- chmod(public_path($filePath . "/index.html"), 0777);
|
|
|
|
934
|
- }
|
|
|
|
935
|
- } catch (\Exception $e) {
|
|
|
|
936
|
- return true;
|
|
|
|
937
|
- }
|
|
|
|
938
|
-
|
|
|
|
939
|
- return true;
|
|
|
|
940
|
- }
|
|
|
|
941
|
-
|
|
|
|
942
|
- /**
|
|
|
|
943
|
- * 6.0生成路径
|
|
|
|
944
|
- */
|
|
|
|
945
|
- public function getProjectRoutePath6($project,$domain,$route,$routeType,$lang,$page): string
|
|
|
|
946
|
- {
|
|
|
|
947
|
- if ($routeType == "news" || $routeType == "blogs"){
|
|
|
|
948
|
- if ($routeType == "blogs"){
|
|
|
|
949
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn('path', ['blog','blogs',''])->first();
|
|
|
|
950
|
- }else{
|
|
|
|
951
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path",$routeType)->first();
|
|
|
|
952
|
- }
|
|
|
|
953
|
- }else{
|
|
|
|
954
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();
|
|
|
|
955
|
- }
|
|
|
|
956
|
- if (!empty($routerMap)){
|
|
|
|
957
|
- if ($routerMap->source == "news"){
|
|
|
|
958
|
- $route = "/news/".$route;
|
|
|
|
959
|
- }elseif($routerMap->source == "blog"){
|
|
|
|
960
|
- $route = "/blogs/".$route;
|
|
|
|
961
|
- }elseif($routerMap->source == "module"){
|
|
|
|
962
|
- $modules = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
|
|
|
|
963
|
- $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$modules);
|
|
|
|
964
|
- if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){
|
|
|
|
965
|
- $route = "/".$moduleCategoryInfo->route."/".$route;
|
|
|
|
966
|
- }
|
|
|
|
967
|
- }else{
|
|
|
|
968
|
- $route = $route == "index" ? "" : "/".$route;
|
|
|
|
969
|
- }
|
|
|
|
970
|
- }else{
|
|
|
|
971
|
- $route = $route == "index" ? "" : "/".$route;
|
|
|
|
972
|
- }
|
|
|
|
973
|
- $route = str_replace(".html","",$route);
|
|
|
|
974
|
- $route = str_replace(".htm","",$route);
|
|
|
|
975
|
- return $domain.$lang.$route.$page;
|
|
|
|
976
|
- }
|
|
|
|
977
|
-
|
|
|
|
978
|
- /**
|
|
|
|
979
|
- * 5.0生成路径
|
|
|
|
980
|
- */
|
|
|
|
981
|
- public function getProjectRoutePath5($project,$domain,$route,$routeType,$lang,$page): string
|
|
|
|
982
|
- {
|
|
|
|
983
|
- if ($routeType == "news" || $routeType == "blogs"){
|
|
|
|
984
|
- if ($routeType == "blogs"){
|
|
|
|
985
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn('path', ['blog','blogs',''])->first();
|
|
|
|
986
|
- }else{
|
|
|
|
987
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path",$routeType)->first();
|
|
|
|
988
|
- }
|
|
|
|
989
|
- }else{
|
|
|
|
990
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path","")->first();
|
|
|
|
991
|
- if (empty($routerMap)){
|
|
|
|
992
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();
|
|
|
|
993
|
- }
|
|
|
|
994
|
- }
|
|
|
|
995
|
- if (!empty($routerMap)){
|
|
|
|
996
|
- if ($routerMap->source == "news"){
|
|
|
|
997
|
- $route = "/news/".$route;
|
|
|
|
998
|
- }elseif($routerMap->source == "blog" || $routerMap->source == "blogs"){
|
|
|
|
999
|
- $route = "/blogs/".$route;
|
|
|
|
1000
|
- }elseif ($routerMap->source == "news_category"){
|
|
|
|
1001
|
- if ($route == "news"){
|
|
|
|
1002
|
- $route = $page == null || $page == 1 ? "/".$route : "/".$route . "/page";
|
|
|
|
1003
|
- }else{
|
|
|
|
1004
|
- $route = $page == null || $page == 1 ? "/news_catalog/".$route : "/news_catalog/".$route."/page";
|
|
|
|
1005
|
- }
|
|
|
|
1006
|
- }elseif ($routerMap->source == "blog_category"){
|
|
|
|
1007
|
- if ($route == "blog"){
|
|
|
|
1008
|
- $route = $page == null || $page == 1 ? "/".$route : "/".$route."/page";
|
|
|
|
1009
|
- }else{
|
|
|
|
1010
|
- $route = $page == null || $page == 1 ? "/blog_catalog/".$route : "/blog_catalog/".$route."/page";
|
|
|
|
1011
|
- }
|
|
|
|
1012
|
- }elseif ($routerMap->source == "product_category"){
|
|
|
|
1013
|
- $route = $page == null || $page == 1 ? "/".$route : "/".$route."/page";
|
|
|
|
1014
|
- }elseif ($routerMap->source == "module_category"){
|
|
|
|
1015
|
- $moduleCategory = CustomModuleCategory::getModuleCategoryAndExtendById($project->id,$routerMap->source_id);
|
|
|
|
1016
|
- if (!empty($moduleCategory->getExtend->route)){
|
|
|
|
1017
|
- if ($moduleCategory->getExtend->route == $route){
|
|
|
|
1018
|
- $route = "/".$moduleCategory->route;
|
|
|
|
1019
|
- }else{
|
|
|
|
1020
|
- $route = "/".$moduleCategory->getExtend->route."_catalog/".$moduleCategory->route."/page";
|
|
|
|
1021
|
- }
|
|
|
|
1022
|
- }else{
|
|
|
|
1023
|
- $route = "/".$moduleCategory->route."/page";
|
|
|
|
1024
|
- }
|
|
|
|
1025
|
- }elseif ($routerMap->source == "module"){
|
|
|
|
1026
|
- $modules = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
|
|
|
|
1027
|
- $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$modules);
|
|
|
|
1028
|
- if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){
|
|
|
|
1029
|
- $route = "/".$moduleCategoryInfo->route."/".$modules->route;
|
|
|
|
1030
|
- }else{
|
|
|
|
1031
|
- $route = "/".$modules->route;
|
|
|
|
1032
|
- }
|
|
|
|
1033
|
- }else{
|
|
|
|
1034
|
- $route = $route == "index" ? "" : "/".$route;
|
|
|
|
1035
|
- }
|
|
|
|
1036
|
- }else{
|
|
|
|
1037
|
- if ($route == "products"){
|
|
|
|
1038
|
- if ($page == null || $page == 1){
|
|
|
|
1039
|
- $route = "/".$route;
|
|
|
|
1040
|
- }else{
|
|
|
|
1041
|
- $route = "/".$route."/page";
|
|
|
|
1042
|
- }
|
|
|
|
1043
|
- }elseif ($route == "news"){
|
|
|
|
1044
|
- $route = $page == null || $page == 1 ? "/".$route : "/".$route;
|
|
|
|
1045
|
- }elseif ($route == "blog"){
|
|
|
|
1046
|
- $route = $page == null || $page == 1 ? "/blog_catalog/".$route : "/blog_catalog/".$route."/page";
|
|
|
|
1047
|
- }else{
|
|
|
|
1048
|
- $route = $route == "index" ? "" : "/".$route;
|
|
|
|
1049
|
- }
|
|
|
|
1050
|
- }
|
|
|
|
1051
|
- $route = str_replace(".html","",$route);
|
|
|
|
1052
|
- $route = str_replace(".htm","",$route);
|
|
|
|
1053
|
- return $domain.$lang.$route.$page;
|
|
|
|
1054
|
- }
|
|
|
|
1055
|
-
|
|
|
|
1056
|
- /**
|
|
|
|
1057
|
- * 从主站拿页面
|
|
|
|
1058
|
- */
|
|
|
|
1059
|
- public function getHtmlToPageFile($project,$lang,$route,$page,$routeType = "")
|
|
|
|
1060
|
- {
|
|
|
|
1061
|
- $domain = $project->domain;
|
|
|
|
1062
|
- $domain = str_replace("https://","",$domain);
|
|
|
|
1063
|
- $domain = str_replace("http://","",$domain);
|
|
|
|
1064
|
- $domain = str_replace("/","",$domain);
|
|
|
|
1065
|
- $lang = $lang=="" ? "" : "/".$lang;
|
|
|
|
1066
|
- $page = $page == null || (int)$page == 1 ? null : "/".(int)$page;
|
|
|
|
1067
|
-
|
|
|
|
1068
|
- //是否是5.0升级项目
|
|
|
|
1069
|
- if (isset($project->update_info["is_update"]) && $project->update_info["is_update"] == 1){
|
|
|
|
1070
|
- //取5.0生成路径
|
|
|
|
1071
|
- $path = $this->getProjectRoutePagePath5($project,$domain,$route,$routeType,$lang,$page);
|
|
|
|
1072
|
- }else{
|
|
|
|
1073
|
- //取6.0生成路径
|
|
|
|
1074
|
- $path = $this->getProjectRoutePagePath6($project,$domain,$route,$routeType,$lang,$page);
|
|
|
|
1075
|
- }
|
|
|
|
1076
|
-
|
|
|
|
1077
|
- try {
|
|
|
|
1078
|
- $filePath = iconv("UTF-8", "GBK", $path);
|
|
|
|
1079
|
- if (file_exists(public_path($filePath . "/index.html"))) {
|
|
|
|
1080
|
- $html = file_get_contents(public_path($filePath . "/index.html"));
|
|
|
|
1081
|
- }else{
|
|
|
|
1082
|
- $html = "";
|
|
|
|
1083
|
- }
|
|
|
|
1084
|
- } catch (\Exception $e) {
|
|
|
|
1085
|
- $html = "";
|
|
|
|
1086
|
- }
|
|
|
|
1087
|
- return $html;
|
|
|
|
1088
|
- }
|
|
|
|
1089
|
-
|
|
|
|
1090
|
- /**
|
|
|
|
1091
|
- * 拿6.0页面
|
|
|
|
1092
|
- */
|
|
|
|
1093
|
- public function getProjectRoutePagePath6($project,$domain,$route,$routeType,$lang,$page): string
|
|
|
|
1094
|
- {
|
|
|
|
1095
|
- if ($routeType == "news" || $routeType == "blogs"){
|
|
|
|
1096
|
- if ($routeType == "blogs"){
|
|
|
|
1097
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn('path', ['blog','blogs',''])->first();
|
|
|
|
1098
|
- }else{
|
|
|
|
1099
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path",$routeType)->first();
|
|
|
|
1100
|
- }
|
|
|
|
1101
|
-
|
|
|
|
1102
|
- }else{
|
|
|
|
1103
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path","")->first();
|
|
|
|
1104
|
- if (empty($routerMap)){
|
|
|
|
1105
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();
|
|
|
|
1106
|
- }
|
|
|
|
1107
|
- }
|
|
|
|
1108
|
- if (!empty($routerMap)){
|
|
|
|
1109
|
- if ($routerMap->source == "news"){
|
|
|
|
1110
|
- $route = "/news/".$route;
|
|
|
|
1111
|
- }elseif($routerMap->source == "blog"){
|
|
|
|
1112
|
- $route = "/blogs/".$route;
|
|
|
|
1113
|
- }elseif($routerMap->source == "module"){
|
|
|
|
1114
|
- $modules = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
|
|
|
|
1115
|
- $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$modules);
|
|
|
|
1116
|
- if (isset($moduleCategoryInfo->route) && !empty($moduleCategoryInfo->route)){
|
|
|
|
1117
|
- $route = "/".$moduleCategoryInfo->route."/".$route;
|
|
|
|
1118
|
- }
|
|
|
|
1119
|
- }else{
|
|
|
|
1120
|
- $route = $route == "index" ? "" : "/".$route;
|
|
|
|
1121
|
- }
|
|
|
|
1122
|
- }else{
|
|
|
|
1123
|
- $route = $route == "index" ? "" : "/".$route;
|
|
|
|
1124
|
- }
|
|
|
|
1125
|
- return $domain.$lang.$route.$page;
|
|
|
|
1126
|
- }
|
|
|
|
1127
|
-
|
|
|
|
1128
|
- /**
|
|
|
|
1129
|
- * 拿5.0页面
|
|
|
|
1130
|
- */
|
|
|
|
1131
|
- public function getProjectRoutePagePath5($project,$domain,$route,$routeType,$lang,$page): string
|
|
|
|
1132
|
- {
|
|
|
|
1133
|
- if ($routeType == "news" || $routeType == "blogs"){
|
|
|
|
1134
|
- if ($routeType == "blogs"){
|
|
|
|
1135
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->whereIn('path', ['blog','blogs',''])->first();
|
|
|
|
1136
|
- }else{
|
|
|
|
1137
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path",$routeType)->first();
|
|
|
|
1138
|
- }
|
|
|
|
1139
|
-
|
|
|
|
1140
|
- }else{
|
|
|
|
1141
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->where("path","")->first();
|
|
|
|
1142
|
- if (empty($routerMap)){
|
|
|
|
1143
|
- $routerMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();
|
|
|
|
1144
|
- }
|
|
|
|
1145
|
- }
|
|
|
|
1146
|
- if (!empty($routerMap)){
|
|
|
|
1147
|
- if ($routerMap->source == "news"){
|
|
|
|
1148
|
- $route = "/news/".$route;
|
|
|
|
1149
|
- }elseif($routerMap->source == "blog" || $routerMap->source == "blogs"){
|
|
|
|
1150
|
- $route = "/blogs/".$route;
|
|
|
|
1151
|
- }elseif ($routerMap->source == "news_category"){
|
|
|
|
1152
|
- $route = "/news_catalog/".$route."/page";
|
|
|
|
1153
|
- }elseif ($routerMap->source == "blog_category"){
|
|
|
|
1154
|
- $route = "/blog_catalog/".$route."/page";
|
|
|
|
1155
|
- }elseif ($routerMap->source == "product_category"){
|
|
|
|
1156
|
- $route = "/".$route."/page";
|
|
|
|
1157
|
- }elseif ($routerMap->source == "module"){
|
|
|
|
1158
|
- $modules = CustomModuleContent::where("project_id",$project->id)->where("id",$routerMap->source_id)->where("status",0)->first();
|
|
|
|
1159
|
- $moduleCategoryInfo = CustomModuleContent::getModuleCategory($project->id,$modules);
|
|
|
|
1160
|
- if (isset($moduleCategoryInfo->getExtend->route) && !empty($moduleCategoryInfo->getExtend->route)){
|
|
|
|
1161
|
- $route = "/".$moduleCategoryInfo->getExtend->route."_catalog/".$moduleCategoryInfo->route."/page";
|
|
|
|
1162
|
- }else{
|
|
|
|
1163
|
- $route = "/extend_catalog/".$moduleCategoryInfo->route."/page";
|
|
|
|
1164
|
- }
|
|
|
|
1165
|
- }else{
|
|
|
|
1166
|
- $route = $route == "index" ? "" : "/".$route;
|
|
|
|
1167
|
- }
|
|
|
|
1168
|
- }else{
|
|
|
|
1169
|
- $route = $route == "index" ? "" : "/".$route;
|
|
|
|
1170
|
- }
|
|
|
|
1171
|
- return $domain.$lang.$route.$page;
|
|
|
|
1172
|
- }
|
|
|
|
1173
|
-
|
|
|
|
1174
|
- /**
|
|
|
|
1175
|
- * 翻译
|
|
|
|
1176
|
- */
|
|
|
|
1177
|
- public function translateWebPage($project,$html,$lang,$domain,$route="",$page=null,$countryLang=null): string
|
|
|
|
1178
|
- {
|
|
|
|
1179
|
- if (empty($html) || $html == ""){
|
|
|
|
1180
|
- return $html;
|
|
|
|
1181
|
- }
|
|
|
|
1182
|
- $staticHtmlRepository = new StaticHtmlRepository();
|
|
|
|
1183
|
- try {
|
|
|
|
1184
|
-//非主站处理html语言
|
|
|
|
1185
|
- $htmlOld = $this->langUrlHandle($project,$lang,$html,$route,$page,$countryLang);
|
|
|
|
1186
|
- $phpQueryDomOld = phpQuery::newDocument($htmlOld);
|
|
|
|
1187
|
- $langDomContent = $phpQueryDomOld->find("header .change-language")->eq(0)->html();
|
|
|
|
1188
|
- $footerFormDomContent = $phpQueryDomOld->find(".form-footer-inquiry-block")->eq(0)->html();
|
|
|
|
1189
|
- $mainFormDomContent = $phpQueryDomOld->find(".section-form-wrap-block")->eq(0)->html();
|
|
|
|
1190
|
- $popFormDomContent = $phpQueryDomOld->find(".pop-box.inquiry-box")->eq(0)->html();
|
|
|
|
1191
|
- $topSearchDomContent = $phpQueryDomOld->find("main .top-search-title-first-letter-list")->eq(0)->html();
|
|
|
|
1192
|
- $langDomContent5 = $phpQueryDomOld->find(".prisna-wp-translate-seo")->eq(0)->html();
|
|
|
|
1193
|
- unset($phpQueryDomOld);
|
|
|
|
1194
|
- phpQuery::unloadDocuments();
|
|
|
|
1195
|
-
|
|
|
|
1196
|
- $newHtml = "";
|
|
|
|
1197
|
- if ($lang != '') {
|
|
|
|
1198
|
- //翻译测试成功,用下面第二红最新翻译
|
|
|
|
1199
|
-// 第一种翻译
|
|
|
|
1200
|
-// $commonService = new CommonService();
|
|
|
|
1201
|
-// $htmlNew = $commonService->webHtmlTranslate($project,$htmlOld,$lang,$domain);
|
|
|
|
1202
|
-// 第二种翻译
|
|
|
|
1203
|
- $htmlNew = $staticHtmlRepository->getTranHtml($project,$htmlOld,$lang,$route,$page);
|
|
|
|
1204
|
- $phpQueryDomNew = phpQuery::newDocument($htmlNew);
|
|
|
|
1205
|
- unset($htmlOld);
|
|
|
|
1206
|
- $phpQueryDomNew->find("header .change-language")->eq(0)->html($langDomContent);
|
|
|
|
1207
|
- //取消根据翻译状态,翻译tag状态显示主站小语种列表功能(2024.02.27)
|
|
|
|
1208
|
-// $phpQueryDomNew->find("header div[data-module=2]")->find(".change-language-cont")->removeAttr("style");
|
|
|
|
1209
|
- $phpQueryDomNew->find(".form-footer-inquiry-block")->eq(0)->html($footerFormDomContent);
|
|
|
|
1210
|
- $phpQueryDomNew->find(".section-form-wrap-block")->eq(0)->html($mainFormDomContent);
|
|
|
|
1211
|
- $phpQueryDomNew->find(".pop-box.inquiry-box")->eq(0)->html($popFormDomContent);
|
|
|
|
1212
|
- $phpQueryDomNew->find("main .top-search-title-first-letter-list")->eq(0)->html($topSearchDomContent);
|
|
|
|
1213
|
- $phpQueryDomNew->find(".prisna-wp-translate-seo")->eq(0)->html($langDomContent5);
|
|
|
|
1214
|
- $newHtml = $phpQueryDomNew->htmlOuter();
|
|
|
|
1215
|
- unset($phpQueryDomNew,$htmlNew,$langDomContent,$footerFormDomContent,$mainFormDomContent,$popFormDomContent);
|
|
|
|
1216
|
- }
|
|
|
|
1217
|
- phpQuery::unloadDocuments();
|
|
|
|
1218
|
- } catch (\Exception $e) {
|
|
|
|
1219
|
- $newHtml = $staticHtmlRepository->getTranHtml($project,$html,$lang,$route,$page);
|
|
|
|
1220
|
- }
|
|
|
|
1221
|
-
|
|
|
|
1222
|
- return $newHtml;
|
|
|
|
1223
|
- }
|
|
|
|
1224
|
-
|
|
|
|
1225
|
- /**
|
|
|
|
1226
|
- * 小语种url处理
|
|
|
|
1227
|
- */
|
|
|
|
1228
|
- public function langUrlHandle($project,$lang,$html,$route="",$page=null,$countryLang=null)
|
|
|
|
1229
|
- {
|
|
|
|
1230
|
-// $html = str_replace("\n","",$html);
|
|
|
|
1231
|
- $content = $html;
|
|
|
|
1232
|
- //主站翻译,不进行小语种链接和页面处理
|
|
|
|
1233
|
- if ($project->is_lang_translate == 1){
|
|
|
|
1234
|
- $langInfo = WebLanguage::getProjectMainLang($project->main_lang_id);
|
|
|
|
1235
|
- if ($langInfo->short == $lang){
|
|
|
|
1236
|
- return $content;
|
|
|
|
1237
|
- }
|
|
|
|
1238
|
- }
|
|
|
|
1239
|
- //当前语言国徽背景图片处理
|
|
|
|
1240
|
- if ($lang != ""){
|
|
|
|
1241
|
- $oldLang = $lang;
|
|
|
|
1242
|
- $oldRoute = $route;
|
|
|
|
1243
|
- $phpQueryDom = phpQuery::newDocument($content);
|
|
|
|
1244
|
- //去掉小语种搜索框
|
|
|
|
1245
|
- $phpQueryDom->find("header .search")->remove();
|
|
|
|
1246
|
- $phpQueryDom->find("header .btn--search")->remove();
|
|
|
|
1247
|
- $phpQueryDom->find("header .btn-search")->remove();
|
|
|
|
1248
|
- $phpQueryDom->find("header .head-search")->remove();
|
|
|
|
1249
|
-
|
|
|
|
1250
|
- $page = $page == null ? "" : $page."/";
|
|
|
|
1251
|
- $route = $route == "index" || $route == "" ? "" : $route."/";
|
|
|
|
1252
|
- $lang = $lang."/";
|
|
|
|
1253
|
- $langUrl = "https://".$project->domain."/".$lang.$route.$page;
|
|
|
|
1254
|
- $phpQueryDom->find("link[rel=canonical]")->attr("href",$langUrl);
|
|
|
|
1255
|
-
|
|
|
|
1256
|
- //翻译版块当前小语种显示
|
|
|
|
1257
|
- $countryDom = $phpQueryDom->find("header div[data-module=2]");
|
|
|
|
1258
|
- $langInfo = WebLanguage::where("short",$oldLang)->first();
|
|
|
|
1259
|
- if (!empty($langInfo)){
|
|
|
|
1260
|
- $countryDom->find(".change-language-title span")->text($langInfo->english);
|
|
|
|
1261
|
- }
|
|
|
|
1262
|
- $oldTwLang = $oldLang == "zh-ct" ? "zh-TW" : $oldLang;
|
|
|
|
1263
|
- $countryDom->find(".change-language-title .country-flag")->attr("class","country-flag language-flag-".$oldTwLang);
|
|
|
|
1264
|
-
|
|
|
|
1265
|
- //html 标签处理
|
|
|
|
1266
|
- if ($oldLang == "ar" || $oldLang == "ug"){
|
|
|
|
1267
|
- $phpQueryDom->find("html")->attr("dir","rtl");
|
|
|
|
1268
|
- }else{
|
|
|
|
1269
|
- $phpQueryDom->find("html")->attr("dir","ltr");
|
|
|
|
1270
|
- }
|
|
|
|
1271
|
-
|
|
|
|
1272
|
- $phpQueryDom->find("html")->attr("lang",$oldLang);
|
|
|
|
1273
|
- //1:2级目录 2:2级域名
|
|
|
|
1274
|
- $linkingFormat = 1;
|
|
|
|
1275
|
- $mainLang = null;
|
|
|
|
1276
|
- $projectBuild = $project->deployBuild;
|
|
|
|
1277
|
- if (!empty($projectBuild)){
|
|
|
|
1278
|
- $linkingFormat = $projectBuild->linking_format;
|
|
|
|
1279
|
- }
|
|
|
|
1280
|
-
|
|
|
|
1281
|
- if (isset($project->main_lang_id) && !empty($project->main_lang_id)){
|
|
|
|
1282
|
- $mainLang = WebLanguage::getProjectMainLang($project->main_lang_id);
|
|
|
|
1283
|
- }
|
|
|
|
1284
|
- //小语种自定义跳转
|
|
|
|
1285
|
- $countryCustomInfo = CountryCustom::getCountryCustomByProjectId($project->id);
|
|
|
|
1286
|
- $countryCustomInfoNew = [];
|
|
|
|
1287
|
- if (!empty($countryCustomInfo)){
|
|
|
|
1288
|
- foreach ($countryCustomInfo as $countryCustomInfoItem){
|
|
|
|
1289
|
- if (isset($countryCustomInfoItem->country_custom_language->short)){
|
|
|
|
1290
|
- $countryCustomInfoNew[$countryCustomInfoItem->country_custom_language->short]["custom_domain"] = $countryCustomInfoItem->custom_domain;
|
|
|
|
1291
|
- }
|
|
|
|
1292
|
- }
|
|
|
|
1293
|
- }
|
|
|
|
1294
|
- // 1、处理A标签跳过图标 2、获取图标HTML a标签处理完成 还原图标HTML
|
|
|
|
1295
|
- //a标签路径问题
|
|
|
|
1296
|
- foreach ($phpQueryDom->find('a') as $a) {
|
|
|
|
1297
|
- $class =pq($a)->attr('class');
|
|
|
|
1298
|
- if (strpos($class, 'language-flag') !== false){
|
|
|
|
1299
|
- continue;
|
|
|
|
1300
|
- }
|
|
|
|
1301
|
- $href = pq($a)->attr('href');
|
|
|
|
1302
|
- //a标签href字符串是否有http://或者https://等协议头,有的话不做处理
|
|
|
|
1303
|
- if (strpos($href, 'http://') !== false || strpos($href, 'https://') !== false || strpos($href,'javascript') !== false || strpos($href, 'javasctipt') !== false || $href == "#" || empty($href) || strpos($href, '.zip') !== false || strpos($href, '.txt') !== false || strpos($href, 'tel:') !== false || strpos($href, 'mailto') !== false || strpos($href, '.pdf') !== false || strpos($href, '.tar') !== false || strpos($href, '.jpg') !== false || strpos($href, '.png') !== false || strpos($href, '.jpeg') !== false || strpos($href, '.xml') !== false || strpos($href, 'skype:') !== false || strpos($href, 'whatsapp:') !== false) {
|
|
|
|
1304
|
- }else{
|
|
|
|
1305
|
- if ($lang != ''){
|
|
|
|
1306
|
- if (!empty($mainLang)){
|
|
|
|
1307
|
- if ($lang != $mainLang->short){
|
|
|
|
1308
|
- //小语种自定义链接
|
|
|
|
1309
|
- if (isset($countryCustomInfoNew[$oldLang])){
|
|
|
|
1310
|
- continue;
|
|
|
|
1311
|
- }
|
|
|
|
1312
|
- if ($linkingFormat == 1){
|
|
|
|
1313
|
- $hrefNew = '/'.$lang . ltrim($href, '/');
|
|
|
|
1314
|
- }else{
|
|
|
|
1315
|
- $hrefNew = '/' . ltrim($href, '/');
|
|
|
|
1316
|
- }
|
|
|
|
1317
|
- }else{
|
|
|
|
1318
|
- $hrefNew = '/' . ltrim($href, '/');
|
|
|
|
1319
|
- }
|
|
|
|
1320
|
- pq($a)->attr('href', $hrefNew);
|
|
|
|
1321
|
- }
|
|
|
|
1322
|
- }
|
|
|
|
1323
|
- }
|
|
|
|
1324
|
- }
|
|
|
|
1325
|
-
|
|
|
|
1326
|
- $data = date("Y-m-d H:i:s");
|
|
|
|
1327
|
- $phpQueryDom->find('html')->append("<!-- Globalso translate Cache file was created on ".$data." -->");
|
|
|
|
1328
|
- $content = $phpQueryDom->htmlOuter();
|
|
|
|
1329
|
- unset($html,$phpQueryDom);
|
|
|
|
1330
|
- phpQuery::unloadDocuments();
|
|
|
|
1331
|
- return $content;
|
|
|
|
1332
|
- }
|
|
|
|
1333
|
- return $content;
|
|
|
|
1334
|
- }
|
|
|
|
1335
|
-
|
|
|
|
1336
|
- /**
|
|
|
|
1337
|
- * 生成robots
|
|
|
|
1338
|
- * @param Project $project
|
|
|
|
1339
|
- * @return bool
|
|
|
|
1340
|
- */
|
|
|
|
1341
|
- public function createRobots($project)
|
|
|
|
1342
|
- {
|
|
|
|
1343
|
- if (!empty($project)){
|
|
|
|
1344
|
- $robotTxtPath = public_path($project->domain."/robots.txt");
|
|
|
|
1345
|
- $createSitemapService = new CreateSitemapService();
|
|
|
|
1346
|
- //A端是否开启允许robots爬虫爬取
|
|
|
|
1347
|
- if ($project->robots == 0){
|
|
|
|
1348
|
- $sitemapContent = $this->getRefuseRobotsStr($project->domain);
|
|
|
|
1349
|
- }else{
|
|
|
|
1350
|
- $sitemapContent = $this->getAllowRobotsStr($project->domain);
|
|
|
|
1351
|
- }
|
|
|
|
1352
|
- $domainPath = public_path($project->domain);
|
|
|
|
1353
|
- if (!file_exists($domainPath)){
|
|
|
|
1354
|
- mkdir($domainPath, 0777, true);
|
|
|
|
1355
|
- }
|
|
|
|
1356
|
- $res = $createSitemapService->putSitemapFile($robotTxtPath,$sitemapContent);
|
|
|
|
1357
|
- if ($res){
|
|
|
|
1358
|
- return true;
|
|
|
|
1359
|
- }
|
|
|
|
1360
|
- }
|
|
|
|
1361
|
- return true;
|
|
|
|
1362
|
- }
|
|
|
|
1363
|
-
|
|
|
|
1364
|
- /**
|
|
|
|
1365
|
- * 生成允许爬虫爬取robots内容
|
|
|
|
1366
|
- * @param $domain
|
|
|
|
1367
|
- * @return string
|
|
|
|
1368
|
- */
|
|
|
|
1369
|
- public function getAllowRobotsStr($domain)
|
|
|
|
1370
|
- {
|
|
|
|
1371
|
- $domain_arr = config('custom.robots_disallow_domain');
|
|
|
|
1372
|
- $disallow = '';
|
|
|
|
1373
|
- if (in_array($domain, $domain_arr)) {
|
|
|
|
1374
|
- $langArr = WebLanguage::pluck('short');
|
|
|
|
1375
|
- foreach ($langArr as $val) {
|
|
|
|
1376
|
- if ($val == 'en')
|
|
|
|
1377
|
- continue;
|
|
|
|
1378
|
- $disallow .= 'Disallow: /' . $val . '/' . PHP_EOL;
|
|
|
|
1379
|
- }
|
|
|
|
1380
|
- }
|
|
|
|
1381
|
- $trans_string = is_file(public_path($domain . '/trans_sitemap.xml')) ? "Sitemap: https://".$domain."/trans_sitemap.xml" : '';
|
|
|
|
1382
|
- return "User-agent: *
|
|
|
|
1383
|
-Allow: /
|
|
|
|
1384
|
-Disallow: /404/
|
|
|
|
1385
|
-
|
|
|
|
1386
|
-".$disallow."
|
|
|
|
1387
|
-User-agent: MSNBot
|
|
|
|
1388
|
-Disallow: /
|
|
|
|
1389
|
-User-agent: YoudaoBot
|
|
|
|
1390
|
-Disallow: /
|
|
|
|
1391
|
-User-agent: JikeSpider
|
|
|
|
1392
|
-Disallow: /
|
|
|
|
1393
|
-User-agent: EasouSpider
|
|
|
|
1394
|
-Disallow: /
|
|
|
|
1395
|
-User-agent: AhrefsBot
|
|
|
|
1396
|
-Disallow: /
|
|
|
|
1397
|
-User-agent: MJ12bot
|
|
|
|
1398
|
-Disallow: /
|
|
|
|
1399
|
-User-agent: YYSpider
|
|
|
|
1400
|
-Disallow: /
|
|
|
|
1401
|
-User-agent: Teoma
|
|
|
|
1402
|
-Disallow: /
|
|
|
|
1403
|
-User-agent: rogerbot
|
|
|
|
1404
|
-Disallow: /
|
|
|
|
1405
|
-User-agent: exabot
|
|
|
|
1406
|
-Disallow: /
|
|
|
|
1407
|
-User-agent: DotBot
|
|
|
|
1408
|
-Disallow: /
|
|
|
|
1409
|
-User-agent: gigabot
|
|
|
|
1410
|
-Disallow: /
|
|
|
|
1411
|
-User-agent: BLEXBot
|
|
|
|
1412
|
-Disallow: /
|
|
|
|
1413
|
-User-agent: DOCOMO Sprider
|
|
|
|
1414
|
-Disallow: /
|
|
|
|
1415
|
-User-agent: Applebot
|
|
|
|
1416
|
-Disallow: /
|
|
|
|
1417
|
-User-agent: SeznamBot
|
|
|
|
1418
|
-Disallow: /
|
|
|
|
1419
|
-User-agent: SemrushBot
|
|
|
|
1420
|
-Disallow: /
|
|
|
|
1421
|
-
|
|
|
|
1422
|
-Sitemap: https://".$domain."/sitemap.xml
|
|
|
|
1423
|
-$trans_string";
|
|
|
|
1424
|
- }
|
|
|
|
1425
|
-
|
|
|
|
1426
|
- /**
|
|
|
|
1427
|
- * 获取允许爬虫爬取robots内容
|
|
|
|
1428
|
- */
|
|
|
|
1429
|
- public function getRefuseRobotsStr($domain): string
|
|
|
|
1430
|
- {
|
|
|
|
1431
|
- return "User-agent: *
|
|
|
|
1432
|
-Disallow: /";
|
|
|
|
1433
|
- }
|
|
|
|
1434
|
-
|
|
|
|
1435
|
- /**
|
|
|
|
1436
|
- * 升级项目,并且以老版本展示
|
|
|
|
1437
|
- * @param $project
|
|
|
|
1438
|
- * @param $routerMap
|
|
|
|
1439
|
- * @param $old_domain_test
|
|
|
|
1440
|
- * @param $old_domain_online
|
|
|
|
1441
|
- * @param $language
|
|
|
|
1442
|
- * @return string
|
|
|
|
1443
|
- * @author Akun
|
|
|
|
1444
|
- * @date 2023/11/29 14:52
|
|
|
|
1445
|
- */
|
|
|
|
1446
|
- public function getOldHtml($project, $routerMap, $old_domain_test, $old_domain_online, $language=''){
|
|
|
|
1447
|
- $collect_info = CollectTask::where('project_id',$project->id)->where('language',$language)->where('source',$routerMap->source)->where('source_id',$routerMap->source_id)->where('status',CollectTask::STATUS_COM)->first();
|
|
|
|
1448
|
- if($collect_info){
|
|
|
|
1449
|
- $html = $collect_info->html;
|
|
|
|
1450
|
- if(strpos($html,'404 Not Found') !== false){
|
|
|
|
1451
|
- return '';
|
|
|
|
1452
|
- }
|
|
|
|
1453
|
- //替换域名
|
|
|
|
1454
|
- $html = str_replace("http://".$old_domain_test,"",$html);
|
|
|
|
1455
|
- $html = str_replace("https://".$old_domain_test,"",$html);
|
|
|
|
1456
|
- $html = str_replace("http://".$old_domain_online,"",$html);
|
|
|
|
1457
|
- $html = str_replace("https://".$old_domain_online,"",$html);
|
|
|
|
1458
|
-// //暂时隐藏小语种
|
|
|
|
1459
|
-// $html = str_replace('<div class="change-language ensemble">','<div class="change-language ensemble" style="display: none">',$html);
|
|
|
|
1460
|
-// $html = str_replace('<div class="language_more">','<div class="language_more" style="display: none">',$html);
|
|
|
|
1461
|
- //处理搜索
|
|
|
|
1462
|
- preg_match_all('/<form\s+[^>]*?action\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_search);
|
|
|
|
1463
|
- $search = $result_search[2] ?? [];
|
|
|
|
1464
|
- foreach ($search as $vc) {
|
|
|
|
1465
|
- if((strpos($vc,'search.php') !== false) || (strpos($vc,'index.php') !== false)){
|
|
|
|
1466
|
- $html = str_replace($vc,'/search/',$html);
|
|
|
|
1467
|
- }
|
|
|
|
1468
|
- }
|
|
|
|
1469
|
- //增加统计代码
|
|
|
|
1470
|
- $html = str_replace('</body>','<script src="https://ecdn6.globalso.com/public/customerVisit.min.js"></script></body>',$html);
|
|
|
|
1471
|
- return $html;
|
|
|
|
1472
|
- }else{
|
|
|
|
1473
|
- return '';
|
|
|
|
1474
|
- }
|
|
|
|
1475
|
- }
|
|
|
|
1476
|
-
|
|
|
|
1477
|
- /**
|
|
|
|
1478
|
- * 更新获取路由
|
|
|
|
1479
|
- */
|
|
|
|
1480
|
- public function getRouters($updateNotifyData,$pageNum): array
|
|
|
|
1481
|
- {
|
|
|
|
1482
|
- $routers = null;
|
|
|
|
1483
|
- $perPage = 100;
|
|
|
|
1484
|
- $offset = ($pageNum - 1) * $perPage;
|
|
|
|
1485
|
- $updateNotifyQuery = UpdateNotify::where("project_id",$updateNotifyData->project_id);
|
|
|
|
1486
|
- if ($updateNotifyData->route == Notify::ROUTE_ALL){
|
|
|
|
1487
|
- //所有更新
|
|
|
|
1488
|
- if ($updateNotifyData->type == Notify::TYPE_MASTER){
|
|
|
|
1489
|
- $updateNotifyQuery->where("status","<",2)->update(['status' => 2]);
|
|
|
|
1490
|
- $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->offset($offset)->limit($perPage)->get()->sortBy(function($item) {
|
|
|
|
1491
|
- return array_search($item->source, ['page', 'product_category', 'product', 'news_category', 'news', 'blog_category', 'blog', 'product_keyword']);
|
|
|
|
1492
|
- });
|
|
|
|
1493
|
- }else{
|
|
|
|
1494
|
- $updateNotifyQuery->where("minor_languages_status","<",2)->update(['minor_languages_status' => 2]);
|
|
|
|
1495
|
- $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->where("source","!=","product_keyword")->offset($offset)->limit($perPage)->get()->sortBy(function($item) {
|
|
|
|
1496
|
- return array_search($item->source, ['page', 'product_category', 'product', 'news_category', 'news', 'blog_category', 'blog']);
|
|
|
|
1497
|
- });
|
|
|
|
1498
|
- }
|
|
|
|
1499
|
- }else if($updateNotifyData->route == Notify::ROUTE_PRODUCT_KEYWORD){
|
|
|
|
1500
|
- //产品聚合页更新
|
|
|
|
1501
|
- $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->where("source","product_keyword")->offset($offset)->limit($perPage)->get();
|
|
|
|
1502
|
- }else if($updateNotifyData->route == Notify::ROUTE_PRODUCT_VIDEO_KEYWORD){
|
|
|
|
1503
|
- //产品视频聚合页更新
|
|
|
|
1504
|
- $videoKeywordIdList = Keyword::where("project_id",$updateNotifyData->project_id)->where("status",1)->whereNotNull("route")->whereNotNull("video")->pluck("id")->toArray();
|
|
|
|
1505
|
- if (!empty($videoKeywordIdList)){
|
|
|
|
1506
|
- $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->where("source","product_keyword")->whereIn("source_id",$videoKeywordIdList)->offset($offset)->limit($perPage)->get();
|
|
|
|
1507
|
- }
|
|
|
|
1508
|
- }else if($updateNotifyData->route == Notify::ROUTE_NOT_TRANSLATE){
|
|
|
|
1509
|
- //漏翻译
|
|
|
|
1510
|
- if ($updateNotifyData->type == Notify::TYPE_MINOR){
|
|
|
|
1511
|
- $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->offset($offset)->limit($perPage)->get()->sortBy(function($item) {
|
|
|
|
1512
|
- return array_search($item->source, ['page', 'product_category', 'product', 'news_category', 'news', 'blog_category', 'blog', 'product_keyword']);
|
|
|
|
1513
|
- });
|
|
|
|
1514
|
- }
|
|
|
|
1515
|
- }else if($updateNotifyData->route == Notify::ROUTE_NEED){
|
|
|
|
1516
|
- //按需更新
|
|
|
|
1517
|
- if ($updateNotifyData->type == Notify::TYPE_MASTER){
|
|
|
|
1518
|
- $routers = $updateNotifyQuery->where("status","<",2)->offset($offset)->limit($perPage)->get();
|
|
|
|
1519
|
- $updateNotifyQuery->where("status","<",2)->update(['status' => 2]);
|
|
|
|
1520
|
- }else{
|
|
|
|
1521
|
- $routers = $updateNotifyQuery->where("minor_languages_status","<",2)->offset($offset)->limit($perPage)->get();
|
|
|
|
1522
|
- $updateNotifyQuery->where("minor_languages_status","<",2)->update(['minor_languages_status' => 2]);
|
|
|
|
1523
|
- }
|
|
|
|
1524
|
- }else{
|
|
|
|
1525
|
- //按url更新
|
|
|
|
1526
|
- $urlArrMap = [];
|
|
|
|
1527
|
- $dataJson = json_decode($updateNotifyData->data);
|
|
|
|
1528
|
- $urlArr = $dataJson->url;
|
|
|
|
1529
|
- if (!empty($urlArr)){
|
|
|
|
1530
|
- if (count($urlArr) != 0){
|
|
|
|
1531
|
- foreach ($urlArr as $key => $item){
|
|
|
|
1532
|
- if (strpos($item, 'http://') !== false || strpos($item, 'https://') !== false) {
|
|
|
|
1533
|
- $pathUrl = parse_url($item);
|
|
|
|
1534
|
- if (isset($pathUrl["path"])){
|
|
|
|
1535
|
- $pathUrl = $pathUrl["path"];
|
|
|
|
1536
|
- if ($pathUrl == "/"){
|
|
|
|
1537
|
- $urlArrMap[] = "index";
|
|
|
|
1538
|
- }
|
|
|
|
1539
|
- }else{
|
|
|
|
1540
|
- $urlArrMap[] = "index";
|
|
|
|
1541
|
- }
|
|
|
|
1542
|
- $pathInfo = urldecode($pathUrl);
|
|
|
|
1543
|
- $pageService = new PageService();
|
|
|
|
1544
|
- $analysisRouteArr = $pageService->analysisRoute($pathInfo);
|
|
|
|
1545
|
- if (isset($analysisRouteArr["router"])){
|
|
|
|
1546
|
- $urlArrMap[] = $analysisRouteArr["router"];
|
|
|
|
1547
|
- }
|
|
|
|
1548
|
- }else{
|
|
|
|
1549
|
- $urlArrMap[] = $item;
|
|
|
|
1550
|
- }
|
|
|
|
1551
|
- }
|
|
|
|
1552
|
- }
|
|
|
|
1553
|
- $pageNum = 0;
|
|
|
|
1554
|
- }
|
|
|
|
1555
|
-
|
|
|
|
1556
|
- $routeNew = [];
|
|
|
|
1557
|
- if (!empty($urlArrMap)){
|
|
|
|
1558
|
- foreach ($urlArrMap as $v){
|
|
|
|
1559
|
- $routerItem = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route",$v)->first();
|
|
|
|
1560
|
- if (!empty($routerItem)){
|
|
|
|
1561
|
- $routeNew[] = $v;
|
|
|
|
1562
|
- }
|
|
|
|
1563
|
- }
|
|
|
|
1564
|
- }
|
|
|
|
1565
|
- if (!empty($routeNew)){
|
|
|
|
1566
|
- $routeNew = array_values(array_unique(array_filter($routeNew)));
|
|
|
|
1567
|
- $routers = RouteMap::where("project_id",$updateNotifyData->project_id)->whereIn("route",$routeNew)->get();
|
|
|
|
1568
|
- }
|
|
|
|
1569
|
- }
|
|
|
|
1570
|
- $routersInfo["routers"] = $routers;
|
|
|
|
1571
|
- $routersInfo["pageNum"] = $pageNum;
|
|
|
|
1572
|
- return $routersInfo;
|
|
|
|
1573
|
- }
|
|
|
|
1574
|
-
|
|
|
|
1575
|
- /**
|
|
|
|
1576
|
- * 数据详情入库数据处理
|
|
|
|
1577
|
- */
|
|
|
|
1578
|
- public function htmlPageQueryDataHandle($routers,$updateNotifyData,$task_id,$isHasData = true)
|
|
|
|
1579
|
- {
|
|
|
|
1580
|
- $page = null;
|
|
|
|
1581
|
- $updateData = [];
|
|
|
|
1582
|
- $data = json_decode($updateNotifyData->data, true);
|
|
|
|
1583
|
- $updateNotifyData->domain = $data['domain'];
|
|
|
|
1584
|
- if ($updateNotifyData->route == Notify::ROUTE_ALL || $updateNotifyData->route == Notify::ROUTE_URL || $updateNotifyData->route == Notify::ROUTE_PRODUCT_KEYWORD || $updateNotifyData->route == Notify::ROUTE_NOT_TRANSLATE){
|
|
|
|
1585
|
- //全部更新
|
|
|
|
1586
|
- if ($isHasData && !empty($routers) && !$routers->isEmpty()){
|
|
|
|
1587
|
- foreach ($routers as $item){
|
|
|
|
1588
|
- $count = $this->isListAndGetCount($item,$updateNotifyData);
|
|
|
|
1589
|
- if ($count == 0 || $item->route == "index"){
|
|
|
|
1590
|
- $updateData['project_id'] = $updateNotifyData->project_id;
|
|
|
|
1591
|
- $updateData['id'] = $task_id;
|
|
|
|
1592
|
- $updateData['type'] = $item->source;
|
|
|
|
1593
|
- $updateData['route'] = $item->route;
|
|
|
|
1594
|
- $updateData['page'] = $page;
|
|
|
|
1595
|
- $updateData['domain'] =$updateNotifyData->domain;
|
|
|
|
1596
|
- $updateDataJson = json_encode($updateData);
|
|
|
|
1597
|
- //更新页面
|
|
|
|
1598
|
- $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);
|
|
|
|
1599
|
- }else{
|
|
|
|
1600
|
- for ($i = 1; $i <= $count; $i++) {
|
|
|
|
1601
|
- if ($i == 1){
|
|
|
|
1602
|
- $updateData['page'] = null;
|
|
|
|
1603
|
- }else{
|
|
|
|
1604
|
- $updateData['page'] = $i;
|
|
|
|
1605
|
- }
|
|
|
|
1606
|
- $updateData['project_id'] = $updateNotifyData->project_id;
|
|
|
|
1607
|
- $updateData['id'] = $task_id;
|
|
|
|
1608
|
- $updateData['type'] = $item->source;
|
|
|
|
1609
|
- $updateData['route'] = $item->route;
|
|
|
|
1610
|
- $updateData['domain'] =$updateNotifyData->domain;
|
|
|
|
1611
|
- $updateDataJson = json_encode($updateData);
|
|
|
|
1612
|
- //更新页面
|
|
|
|
1613
|
- $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);
|
|
|
|
1614
|
- }
|
|
|
|
1615
|
- }
|
|
|
|
1616
|
- }
|
|
|
|
1617
|
- }
|
|
|
|
1618
|
-
|
|
|
|
1619
|
- if (!$isHasData){
|
|
|
|
1620
|
- //判断products,news,blog三个列表页是否存在路由,不存在主动更新
|
|
|
|
1621
|
- //手动更新所有关键词列表页(自定义top-search系列页面)
|
|
|
|
1622
|
- $this->checkProductsNewsBlogListAndGetCount($updateNotifyData,$task_id);
|
|
|
|
1623
|
- if ($updateNotifyData->type == Notify::TYPE_MASTER){
|
|
|
|
1624
|
- $this->productKeywordListAdnGetCount($updateNotifyData,$task_id);
|
|
|
|
1625
|
- }else{
|
|
|
|
1626
|
- if ($updateNotifyData->route == Notify::ROUTE_PRODUCT_KEYWORD){
|
|
|
|
1627
|
- $this->productKeywordListAdnGetCount($updateNotifyData,$task_id);
|
|
|
|
1628
|
- }
|
|
|
|
1629
|
- }
|
|
|
|
1630
|
- }
|
|
|
|
1631
|
- }else{
|
|
|
|
1632
|
- //按需更新
|
|
|
|
1633
|
- if ($isHasData && !empty($routers) && !$routers->isEmpty()){
|
|
|
|
1634
|
- foreach ($routers as $item){
|
|
|
|
1635
|
- $count = $this->isListAndGetCount($item,$updateNotifyData);
|
|
|
|
1636
|
- if ($count == 0 || $item->type == "index"){
|
|
|
|
1637
|
- $updateData['project_id'] = $updateNotifyData->project_id;
|
|
|
|
1638
|
- $updateData['id'] = $task_id;
|
|
|
|
1639
|
- if ($item->type == "index"){
|
|
|
|
1640
|
- $updateData['type'] = "page";
|
|
|
|
1641
|
- $updateData['route'] = "index";
|
|
|
|
1642
|
- }else{
|
|
|
|
1643
|
- $updateData['type'] = $item->type;
|
|
|
|
1644
|
- $updateData['route'] = $item->route;
|
|
|
|
1645
|
- }
|
|
|
|
1646
|
- $updateData['page'] = $page;
|
|
|
|
1647
|
- $updateData['domain'] =$updateNotifyData->domain;
|
|
|
|
1648
|
- $updateDataJson = json_encode($updateData);
|
|
|
|
1649
|
- //更新页面
|
|
|
|
1650
|
- $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);
|
|
|
|
1651
|
- }else{
|
|
|
|
1652
|
- for ($i = 1; $i <= $count; $i++) {
|
|
|
|
1653
|
- if ($i == 1){
|
|
|
|
1654
|
- $updateData['page'] = null;
|
|
|
|
1655
|
- }else{
|
|
|
|
1656
|
- $updateData['page'] = $i;
|
|
|
|
1657
|
- }
|
|
|
|
1658
|
- $updateData['project_id'] = $updateNotifyData->project_id;
|
|
|
|
1659
|
- $updateData['id'] = $task_id;
|
|
|
|
1660
|
- $updateData['type'] = $item->type;
|
|
|
|
1661
|
- $updateData['route'] = $item->route;
|
|
|
|
1662
|
- $updateData['domain'] =$updateNotifyData->domain;
|
|
|
|
1663
|
- $updateDataJson = json_encode($updateData);
|
|
|
|
1664
|
- //更新页面
|
|
|
|
1665
|
- $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);
|
|
|
|
1666
|
- }
|
|
|
|
1667
|
- }
|
|
|
|
1668
|
- }
|
|
|
|
1669
|
- }
|
|
|
|
1670
|
-
|
|
|
|
1671
|
- if (!$isHasData){
|
|
|
|
1672
|
- //判断products,news,blog三个列表页是否存在路由,不存在主动更新
|
|
|
|
1673
|
- $this->checkProductsNewsBlogListAndGetCount($updateNotifyData,$task_id);
|
|
|
|
1674
|
- }
|
|
|
|
1675
|
-
|
|
|
|
1676
|
- }
|
|
|
|
1677
|
- unset($routers);
|
|
|
|
1678
|
- }
|
|
|
|
1679
|
-
|
|
|
|
1680
|
- /**
|
|
|
|
1681
|
- * 是否是列表,并返回页数
|
|
|
|
1682
|
- */
|
|
|
|
1683
|
- public function isListAndGetCount($router,$updateNotifyData)
|
|
|
|
1684
|
- {
|
|
|
|
1685
|
- $count = 0;
|
|
|
|
1686
|
- $newsQuery = News::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1);
|
|
|
|
1687
|
- $blogQuery = Blog::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1);
|
|
|
|
1688
|
- $productsQuery = Product::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->whereNotNull('route');
|
|
|
|
1689
|
- if ($updateNotifyData->route == Notify::ROUTE_ALL || $updateNotifyData->route == Notify::ROUTE_URL){
|
|
|
|
1690
|
- if ($router->source == "news_category"){
|
|
|
|
1691
|
- if ($router->route == "news"){
|
|
|
|
1692
|
- $count = $newsQuery->count();
|
|
|
|
1693
|
- }else{
|
|
|
|
1694
|
- $count = $newsQuery->where("category_id","like","%".",".$router->source_id.","."%")->count();
|
|
|
|
1695
|
- }
|
|
|
|
1696
|
- }
|
|
|
|
1697
|
- if ($router->source == "blog_category"){
|
|
|
|
1698
|
- if ($router->route == "blog"){
|
|
|
|
1699
|
- $count = $blogQuery->count();
|
|
|
|
1700
|
- }else{
|
|
|
|
1701
|
- $count = $blogQuery->where("category_id","like","%".",".$router->source_id.","."%")->count();
|
|
|
|
1702
|
- }
|
|
|
|
1703
|
-
|
|
|
|
1704
|
- }
|
|
|
|
1705
|
- if ($router->source == "product_category"){
|
|
|
|
1706
|
- if ($router->route == "products"){
|
|
|
|
1707
|
- $count =$productsQuery->count();
|
|
|
|
1708
|
- }else{
|
|
|
|
1709
|
- $ids = [];
|
|
|
|
1710
|
- $productCategoryList = Category::getAllSonCategoryById($updateNotifyData->project_id,(int)$router->source_id);
|
|
|
|
1711
|
- if (!empty($productCategoryList)){
|
|
|
|
1712
|
- $productList = CategoryRelated::whereIn("cate_id",$productCategoryList)->get();
|
|
|
|
1713
|
- if (!empty($productList)){
|
|
|
|
1714
|
- foreach ($productList as $productV){
|
|
|
|
1715
|
- $ids[] = $productV->product_id;
|
|
|
|
1716
|
- }
|
|
|
|
1717
|
- }
|
|
|
|
1718
|
- }
|
|
|
|
1719
|
- $count =$productsQuery->whereIn("id",$ids)->count();
|
|
|
|
1720
|
- }
|
|
|
|
1721
|
-
|
|
|
|
1722
|
- }
|
|
|
|
1723
|
- }else{
|
|
|
|
1724
|
- $routerMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route",$router->route)->first();
|
|
|
|
1725
|
- if (!empty($routerMap)){
|
|
|
|
1726
|
- if ($router->type == "news_category"){
|
|
|
|
1727
|
- if ($router->route == "news"){
|
|
|
|
1728
|
- $count = $newsQuery->count();
|
|
|
|
1729
|
- }else{
|
|
|
|
1730
|
- $count = $newsQuery->where("category_id","like","%".",".$routerMap->source_id.","."%")->count();
|
|
|
|
1731
|
- }
|
|
|
|
1732
|
- }
|
|
|
|
1733
|
- if ($router->type == "blog_category"){
|
|
|
|
1734
|
- if ($router->route == "blog"){
|
|
|
|
1735
|
- $count = $blogQuery->count();
|
|
|
|
1736
|
- }else{
|
|
|
|
1737
|
- $count = $blogQuery->where("category_id","like","%".",".$routerMap->source_id.","."%")->count();
|
|
|
|
1738
|
- }
|
|
|
|
1739
|
-
|
|
|
|
1740
|
- }
|
|
|
|
1741
|
- if ($router->type == "product_category"){
|
|
|
|
1742
|
- if ($router->route == "products"){
|
|
|
|
1743
|
- $count = $productsQuery->count();
|
|
|
|
1744
|
- }else{
|
|
|
|
1745
|
- $count = $productsQuery->where("category_id","like","%,".(string)$routerMap->source_id.",%")->count();
|
|
|
|
1746
|
- }
|
|
|
|
1747
|
-
|
|
|
|
1748
|
- }
|
|
|
|
1749
|
- }
|
|
|
|
1750
|
- }
|
|
|
|
1751
|
-
|
|
|
|
1752
|
- if ($count != 0){
|
|
|
|
1753
|
- if ($router->type == "product_category"){
|
|
|
|
1754
|
- $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();
|
|
|
|
1755
|
- if (!empty($webSettingNum)){
|
|
|
|
1756
|
- $perPage = (int)$webSettingNum->num;
|
|
|
|
1757
|
- }else{
|
|
|
|
1758
|
- $perPage = Category::$productCategoryPagePercent; //产品每页条数
|
|
|
|
1759
|
- }
|
|
|
|
1760
|
- $total = (int)ceil($count / $perPage); //产品分类总页数
|
|
|
|
1761
|
- }elseif($router->type == "news_category"){
|
|
|
|
1762
|
- $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
|
|
|
|
1763
|
- if (!empty($webSettingNum)){
|
|
|
|
1764
|
- $perPage = (int)$webSettingNum->num;
|
|
|
|
1765
|
- }else{
|
|
|
|
1766
|
- $perPage = NewsCategory::$newsCategoryPagePercent; //新闻每页条数
|
|
|
|
1767
|
- }
|
|
|
|
1768
|
- $total = (int)ceil($count / $perPage); //新闻总页数
|
|
|
|
1769
|
- }else{
|
|
|
|
1770
|
- $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first();
|
|
|
|
1771
|
- if (!empty($webSettingNum)){
|
|
|
|
1772
|
- $perPage = (int)$webSettingNum->num;
|
|
|
|
1773
|
- }else{
|
|
|
|
1774
|
- $perPage = NewsCategory::$newsCategoryPagePercent; //博客每页条数
|
|
|
|
1775
|
- }
|
|
|
|
1776
|
- $total = (int)ceil($count / $perPage); //博客总页数
|
|
|
|
1777
|
- }
|
|
|
|
1778
|
- $count = $total;
|
|
|
|
1779
|
- }
|
|
|
|
1780
|
- return $count;
|
|
|
|
1781
|
-
|
|
|
|
1782
|
- }
|
|
|
|
1783
|
-
|
|
|
|
1784
|
- /**
|
|
|
|
1785
|
- * 需要更新的页面,主站页面或者小语种页面
|
|
|
|
1786
|
- */
|
|
|
|
1787
|
- public function pushHtmlPage($updateNotifyData, $updateDataJson,$taskId)
|
|
|
|
1788
|
- {
|
|
|
|
1789
|
- //更新页面
|
|
|
|
1790
|
- $mysqlData["created_at"] = now();
|
|
|
|
1791
|
- $mysqlData["updated_at"] = now();
|
|
|
|
1792
|
- $mysqlData["data"] =$updateDataJson;
|
|
|
|
1793
|
- $mysqlData["task_id"] =$taskId;
|
|
|
|
1794
|
- $data = json_decode($updateDataJson);
|
|
|
|
1795
|
- if (!empty($data->page)){
|
|
|
|
1796
|
- $page =",分页:".$data->page;
|
|
|
|
1797
|
- }else{
|
|
|
|
1798
|
- $page = "";
|
|
|
|
1799
|
- }
|
|
|
|
1800
|
- echo "创建项目路由:任务ID:" . $taskId .",项目ID:".$data->project_id.",域名:".$data->domain.",路由:".$data->route.$page. PHP_EOL;
|
|
|
|
1801
|
-
|
|
|
|
1802
|
- if ($updateNotifyData->type == Notify::TYPE_MASTER){
|
|
|
|
1803
|
- UpdateMasterWebsiteModel::insertGetId($mysqlData);
|
|
|
|
1804
|
- }else{
|
|
|
|
1805
|
- UpdateMinorLanguagesModel::insertGetId($mysqlData);
|
|
|
|
1806
|
- }
|
|
|
|
1807
|
- }
|
|
|
|
1808
|
-
|
|
|
|
1809
|
- /**
|
|
|
|
1810
|
- * 判断products,news,blog三个列表页是否存在路由,不存在主动更新
|
|
|
|
1811
|
- */
|
|
|
|
1812
|
- public function checkProductsNewsBlogListAndGetCount($updateNotifyData,$task_id)
|
|
|
|
1813
|
- {
|
|
|
|
1814
|
- $productsCount = 0;
|
|
|
|
1815
|
- $newsCount = 0;
|
|
|
|
1816
|
- $blogCount = 0;
|
|
|
|
1817
|
- //产品
|
|
|
|
1818
|
- $routerProductsMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","products")->first();
|
|
|
|
1819
|
- if (empty($routerProductsMap)){
|
|
|
|
1820
|
- $productsCount = Product::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->whereNotNull('route')->orderBy("id","DESC")->count();
|
|
|
|
1821
|
- if ($productsCount != 0){
|
|
|
|
1822
|
- $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$productListType)->orderBy("id","desc")->first();
|
|
|
|
1823
|
- if (!empty($webSettingNum)){
|
|
|
|
1824
|
- $perPage = (int)$webSettingNum->num;
|
|
|
|
1825
|
- }else{
|
|
|
|
1826
|
- $perPage = Category::$productCategoryPagePercent; //产品每页条数
|
|
|
|
1827
|
- }
|
|
|
|
1828
|
- $productsTotal = (int)ceil($productsCount / $perPage);
|
|
|
|
1829
|
- if ($productsTotal>=1){
|
|
|
|
1830
|
- for ($i = 1; $i <= $productsTotal; $i++) {
|
|
|
|
1831
|
- $updateData = [];
|
|
|
|
1832
|
- if ($i == 1){
|
|
|
|
1833
|
- $updateData['page'] = null;
|
|
|
|
1834
|
- }else{
|
|
|
|
1835
|
- $updateData['page'] = $i;
|
|
|
|
1836
|
- }
|
|
|
|
1837
|
- $updateData['project_id'] = $updateNotifyData->project_id;
|
|
|
|
1838
|
- $updateData['id'] = $task_id;
|
|
|
|
1839
|
- $updateData['type'] = "product_category";
|
|
|
|
1840
|
- $updateData['route'] = "products";
|
|
|
|
1841
|
- $updateData['domain'] =$updateNotifyData->domain;
|
|
|
|
1842
|
- $updateDataJson = json_encode($updateData);
|
|
|
|
1843
|
- //更新页面
|
|
|
|
1844
|
- $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);
|
|
|
|
1845
|
- }
|
|
|
|
1846
|
- }
|
|
|
|
1847
|
- }
|
|
|
|
1848
|
- }
|
|
|
|
1849
|
-
|
|
|
|
1850
|
- //新闻
|
|
|
|
1851
|
- $routerNewsMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","news")->first();
|
|
|
|
1852
|
- if (empty($routerNewsMap)){
|
|
|
|
1853
|
- $newsCount = News::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count();
|
|
|
|
1854
|
- $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$newsListType)->orderBy("id","desc")->first();
|
|
|
|
1855
|
- if (!empty($webSettingNum)){
|
|
|
|
1856
|
- $perPage = (int)$webSettingNum->num;
|
|
|
|
1857
|
- }else{
|
|
|
|
1858
|
- $perPage = NewsCategory::$newsCategoryPagePercent;
|
|
|
|
1859
|
- }
|
|
|
|
1860
|
- $NewsTotal = (int)ceil($newsCount / $perPage);
|
|
|
|
1861
|
- if ($NewsTotal>=1){
|
|
|
|
1862
|
- for ($i = 1; $i <= $NewsTotal; $i++) {
|
|
|
|
1863
|
- $updateData = [];
|
|
|
|
1864
|
- if ($i == 1){
|
|
|
|
1865
|
- $updateData['page'] = null;
|
|
|
|
1866
|
- }else{
|
|
|
|
1867
|
- $updateData['page'] = $i;
|
|
|
|
1868
|
- }
|
|
|
|
1869
|
- $updateData['project_id'] = $updateNotifyData->project_id;
|
|
|
|
1870
|
- $updateData['id'] = $task_id;
|
|
|
|
1871
|
- $updateData['type'] = "news_category";
|
|
|
|
1872
|
- $updateData['route'] = "news";
|
|
|
|
1873
|
- $updateData['domain'] =$updateNotifyData->domain;
|
|
|
|
1874
|
- $updateDataJson = json_encode($updateData);
|
|
|
|
1875
|
- //更新页面
|
|
|
|
1876
|
- $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);
|
|
|
|
1877
|
- }
|
|
|
|
1878
|
- }
|
|
|
|
1879
|
- }
|
|
|
|
1880
|
-
|
|
|
|
1881
|
- //博客
|
|
|
|
1882
|
- $routerBlogMap = RouteMap::where("project_id",$updateNotifyData->project_id)->where("route","blog")->first();
|
|
|
|
1883
|
- if (empty($routerBlogMap)){
|
|
|
|
1884
|
- $blogCount = Blog::where("project_id",$updateNotifyData->project_id)->select("id")->where("status",1)->orderBy("id","DESC")->count();
|
|
|
|
1885
|
- $webSettingNum = SettingNum::where("project_id",$updateNotifyData->project_id)->where("type",SettingNum::$blogListType)->orderBy("id","desc")->first();
|
|
|
|
1886
|
- if (!empty($webSettingNum)){
|
|
|
|
1887
|
- $perPage = (int)$webSettingNum->num;
|
|
|
|
1888
|
- }else{
|
|
|
|
1889
|
- $perPage = NewsCategory::$newsCategoryPagePercent;
|
|
|
|
1890
|
- }
|
|
|
|
1891
|
- $BlogTotal = (int)ceil($blogCount / $perPage);
|
|
|
|
1892
|
- if ($BlogTotal>=1){
|
|
|
|
1893
|
- for ($i = 1; $i <= $BlogTotal; $i++) {
|
|
|
|
1894
|
- $updateData = [];
|
|
|
|
1895
|
- if ($i == 1){
|
|
|
|
1896
|
- $updateData['page'] = null;
|
|
|
|
1897
|
- }else{
|
|
|
|
1898
|
- $updateData['page'] = $i;
|
|
|
|
1899
|
- }
|
|
|
|
1900
|
- $updateData['project_id'] = $updateNotifyData->project_id;
|
|
|
|
1901
|
- $updateData['id'] = $task_id;
|
|
|
|
1902
|
- $updateData['type'] = "blog_category";
|
|
|
|
1903
|
- $updateData['route'] = "blog";
|
|
|
|
1904
|
- $updateData['domain'] =$updateNotifyData->domain;
|
|
|
|
1905
|
- $updateDataJson = json_encode($updateData);
|
|
|
|
1906
|
- //更新页面
|
|
|
|
1907
|
- $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);
|
|
|
|
1908
|
- }
|
|
|
|
1909
|
- }
|
|
|
|
1910
|
- }
|
|
|
|
1911
|
-
|
|
|
|
1912
|
- }
|
|
|
|
1913
|
-
|
|
|
|
1914
|
- /**
|
|
|
|
1915
|
- * 手动更新所有关键词列表页(自定义top-search系列页面)
|
|
|
|
1916
|
- */
|
|
|
|
1917
|
- public function productKeywordListAdnGetCount($updateNotifyData,$task_id)
|
|
|
|
1918
|
- {
|
|
|
|
1919
|
- $productKeywordInfo = $this->projectProductKeywordsDataAndHandle($updateNotifyData->project_id);
|
|
|
|
1920
|
- if (isset($productKeywordInfo["productKeywordListInfo"]) && !empty($productKeywordInfo["productKeywordListInfo"])){
|
|
|
|
1921
|
- foreach ($productKeywordInfo["productKeywordListInfo"] as $productKeywordItem){
|
|
|
|
1922
|
- if ($productKeywordItem['total']>=1){
|
|
|
|
1923
|
- for ($i = 1; $i <= $productKeywordItem['total']; $i++) {
|
|
|
|
1924
|
- if ($i == 1){
|
|
|
|
1925
|
- $updateData['page'] = null;
|
|
|
|
1926
|
- }else{
|
|
|
|
1927
|
- $updateData['page'] = $i;
|
|
|
|
1928
|
- }
|
|
|
|
1929
|
- $updateData['project_id'] = $updateNotifyData->project_id;
|
|
|
|
1930
|
- $updateData['id'] = $task_id;
|
|
|
|
1931
|
- $updateData['type'] = "product_keyword_list";
|
|
|
|
1932
|
- $updateData['route'] = $productKeywordItem['route'];
|
|
|
|
1933
|
- $updateData['domain'] =$updateNotifyData->domain;
|
|
|
|
1934
|
- $updateDataJson = json_encode($updateData);
|
|
|
|
1935
|
- //更新页面
|
|
|
|
1936
|
- $this->pushHtmlPage($updateNotifyData,$updateDataJson,$task_id);
|
|
|
|
1937
|
- }
|
|
|
|
1938
|
- }
|
|
|
|
1939
|
- }
|
|
|
|
1940
|
- }
|
|
|
|
1941
|
- unset($productKeywordInfo);
|
|
|
|
1942
|
- }
|
|
|
|
1943
|
-
|
|
|
|
1944
|
- /**
|
|
|
|
1945
|
- * 获取更新进度表
|
|
|
|
1946
|
- */
|
|
|
|
1947
|
- public function getUpdateProgress($projectId,$type)
|
|
|
|
1948
|
- {
|
|
|
|
1949
|
- $updateProgressQuery = UpdateProgress::where("project_id",(int)$projectId)->orderBy("id","desc");
|
|
|
|
1950
|
- if ($type == "master_website"){
|
|
|
|
1951
|
- $updateProgressQuery = $updateProgressQuery->where("type",1)->first();
|
|
|
|
1952
|
- }else{
|
|
|
|
1953
|
- $updateProgressQuery = $updateProgressQuery->where("type",2)->first();
|
|
|
|
1954
|
- }
|
|
|
|
1955
|
- return $updateProgressQuery;
|
|
|
|
1956
|
- }
|
|
|
|
1957
|
-
|
|
|
|
1958
|
- /**
|
|
|
|
1959
|
- * 项目产品关键词列表路由,及数据处理
|
|
|
|
1960
|
- */
|
|
|
|
1961
|
- public function projectProductKeywordsDataAndHandle($projectId): array
|
|
|
|
1962
|
- {
|
|
|
|
1963
|
- $keywordsArr = [];
|
|
|
|
1964
|
- $keywordModel = new Keyword();
|
|
|
|
1965
|
- $keywords = $keywordModel->where("project_id",$projectId)->get();
|
|
|
|
1966
|
-
|
|
|
|
1967
|
- if (!empty($keywords)){
|
|
|
|
1968
|
- foreach ($keywords->toArray() as $item){
|
|
|
|
1969
|
- $firstLetter = mb_strtolower(mb_substr($item['title'], 0, 1, 'utf-8'), 'utf-8');
|
|
|
|
1970
|
- $keywordsArr["top-search"][] = $item;
|
|
|
|
1971
|
- if (in_array($firstLetter, $keywordModel->routeZ)){
|
|
|
|
1972
|
- $keywordsArr["top-search-0"][] = $item;
|
|
|
|
1973
|
- }else{
|
|
|
|
1974
|
- $keywordsArr["top-search-".$firstLetter][] = $item;
|
|
|
|
1975
|
- }
|
|
|
|
1976
|
- }
|
|
|
|
1977
|
- }
|
|
|
|
1978
|
- return [
|
|
|
|
1979
|
- "productKeywordListInfo"=>$this->projectProductKeywordsDataAndTotalPageHandle($keywordsArr),
|
|
|
|
1980
|
- "productKeywords"=>$keywords,
|
|
|
|
1981
|
- ];
|
|
|
|
1982
|
- }
|
|
|
|
1983
|
-
|
|
|
|
1984
|
- /**
|
|
|
|
1985
|
- * 项目产品关键词列表路由数据及总页数
|
|
|
|
1986
|
- */
|
|
|
|
1987
|
- public function projectProductKeywordsDataAndTotalPageHandle($data): array
|
|
|
|
1988
|
- {
|
|
|
|
1989
|
- $projectProjectKeywords = [];
|
|
|
|
1990
|
- $perPage = 80;
|
|
|
|
1991
|
- if (!empty($data)){
|
|
|
|
1992
|
- foreach ($data as $key => $item){
|
|
|
|
1993
|
- $count = count($item);
|
|
|
|
1994
|
- $total = (int)ceil($count / $perPage);
|
|
|
|
1995
|
- $projectProjectKeywords[$key]["route"] =$key;
|
|
|
|
1996
|
- $projectProjectKeywords[$key]["total"] =$total;
|
|
|
|
1997
|
- }
|
|
|
|
1998
|
- }
|
|
|
|
1999
|
- return $projectProjectKeywords;
|
|
|
|
2000
|
- }
|
|
|
|
2001
|
-
|
|
|
|
2002
|
- /**
|
|
|
|
2003
|
- * 站点域名处理
|
|
|
|
2004
|
- */
|
|
|
|
2005
|
- public function domainHandle($domain)
|
|
|
|
2006
|
- {
|
|
|
|
2007
|
- $langDomain = str_replace("http://","",$domain);
|
|
|
|
2008
|
- $langDomain = str_replace("https://","",$langDomain);
|
|
|
|
2009
|
- $langDomain = str_replace("/","",$langDomain);
|
|
|
|
2010
|
- return $langDomain;
|
|
|
|
2011
|
- }
|
|
|
|
2012
|
-
|
|
|
|
2013
|
- /**
|
|
|
|
2014
|
- * 小语种自定义创建站点目录页面拷贝
|
|
|
|
2015
|
- */
|
|
|
|
2016
|
- public function copyPageMinorWebsiteToCreateDomainDirectory($project)
|
|
|
|
2017
|
- {
|
|
|
|
2018
|
- $countryCustomInfo = CountryCustom::with("countryCustomLanguage")->where("language_id","!=",$project->main_lang_id)->where("project_id",$project->id)->where("status",1)->where("is_create",1)->get();
|
|
|
|
2019
|
- if (!empty($countryCustomInfo)){
|
|
|
|
2020
|
- $langDomain = $this->domainHandle($project->domain);
|
|
|
|
2021
|
- foreach ($countryCustomInfo as $countryCustomInfoItem){
|
|
|
|
2022
|
- $publicLangPath = public_path($langDomain."/".$countryCustomInfoItem->countryCustomLanguage->short);
|
|
|
|
2023
|
- $publicCreatePath = public_path($countryCustomInfoItem->custom_domain);
|
|
|
|
2024
|
- if (file_exists($publicLangPath)){
|
|
|
|
2025
|
- if (!file_exists($publicCreatePath)){
|
|
|
|
2026
|
- mkdir($publicCreatePath,0777);
|
|
|
|
2027
|
- }
|
|
|
|
2028
|
- File::copyDirectory($publicLangPath, $publicCreatePath);
|
|
|
|
2029
|
- }
|
|
|
|
2030
|
- }
|
|
|
|
2031
|
- }
|
|
|
|
2032
|
- }
|
|
|
|
2033
|
-} |
|
|