作者 lyh

gx

要显示太多修改。

为保证性能只显示 7 of 7+ 个文件。

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ReplaceHtml.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/10 17:20
  8 + */
  9 +
  10 +namespace App\Console\Commands\ReplaceHtml;
  11 +
  12 +use App\Models\Template\BTemplate;
  13 +use App\Models\Template\TemplateReplaceHtmlLog;
  14 +use App\Services\ProjectServer;
  15 +use Illuminate\Console\Command;
  16 +use Illuminate\Support\Facades\DB;
  17 +use Illuminate\Support\Facades\Log;
  18 +use App\Models\Template\TemplateReplaceHtml;
  19 +
  20 +class ReplaceHtml extends Command
  21 +{
  22 + /**
  23 + * The name and signature of the console command.
  24 + *
  25 + * @var string
  26 + */
  27 + protected $signature = 'replace_html';
  28 +
  29 + /**
  30 + * The console command description.
  31 + *
  32 + * @var string
  33 + */
  34 + protected $description = '替换html代码';
  35 +
  36 + /**
  37 + * Create a new command instance.
  38 + *
  39 + * @return void
  40 + */
  41 + public function __construct()
  42 + {
  43 + parent::__construct();
  44 + }
  45 +
  46 + /**
  47 + * @return bool
  48 + */
  49 + public function handle()
  50 + {
  51 + $replaceHtmlModel = new TemplateReplaceHtml();
  52 + $replaceHtmlList = $replaceHtmlModel->list(['status'=>$replaceHtmlModel::STATUS]);
  53 + foreach ($replaceHtmlList as $k => $v){
  54 + ProjectServer::useProject($v['project_id']);
  55 + echo '开始,任务id:'.$v['id'].PHP_EOL;
  56 + $this->createReplaceHtmlLog($v);
  57 + echo '结束'.PHP_EOL;
  58 + DB::disconnect('custom_mysql');
  59 + }
  60 + return true;
  61 + }
  62 +
  63 + /**
  64 + * @remark :生成子任务
  65 + * @name :createReplaceHtmlLog
  66 + * @author :lyh
  67 + * @method :post
  68 + * @time :2024/5/10 17:26
  69 + */
  70 + public function createReplaceHtmlLog($info){
  71 + //获取当前页面所有数据
  72 + $saveData = [];
  73 + $bTemplateModel = new BTemplate();
  74 + $condition = ['source'=>$info['source'],'template_id'=>$info['template_id'],'is_custom'=>$info['is_custom'],'is_list'=>$info['is_list']];
  75 + $bTemplateList = $bTemplateModel->list($condition,'id',['id']);
  76 + foreach ($bTemplateList as $v){
  77 + $saveData[] = [
  78 + 'replace_id'=>$info['id'],
  79 + 'project_id'=>$info['project_id'],
  80 + 'status'=>0,
  81 + 'old_html'=>$info['old_html'],
  82 + 'html'=>$info['html'],
  83 + 'source'=>$info['source'],
  84 + 'source_id'=>$v['id'],
  85 + 'is_custom'=>$info['is_custom'],
  86 + 'is_list'=>$info['is_list'],
  87 + ];
  88 + }
  89 + if(!empty($saveData)){
  90 + $templateHtmlLogModel = new TemplateReplaceHtmlLog();
  91 + $templateHtmlLogModel->insert($saveData);
  92 + }
  93 + return true;
  94 + }
  95 +}
@@ -15,20 +15,7 @@ class Project extends Base @@ -15,20 +15,7 @@ class Project extends Base
15 { 15 {
16 //设置关联表名 16 //设置关联表名
17 protected $table = 'gl_project'; 17 protected $table = 'gl_project';
18 - public static $domainEndSlash = 1; //斜杠结尾  
19 - public static $projectLocationZero = 0; //普通项目  
20 - public static $projectLocationDangerous = 1; //危险项目  
21 - public static $storageTypeZero = 0; //默认腾讯压缩存储桶  
22 - public static $storageTypeOne = 1; //非压缩存储桶  
23 - //项目标识集合  
24 - public static $blockItems = "blockitems"; //html循环项父级标识  
25 - public static $blockAttrItems = "[blockitems]"; //html循环项父级属性标识  
26 - public static $blockItem = "blockitem"; //html循环项标识  
27 - public static $blockAttrItem = "[blockitem]"; //html循环项属性标识  
28 - public static $productListBlock = "productlistblock"; //html产品列表标识  
29 - public static $newListBlock = "newlistblock"; //html新闻列表标识  
30 - public static $blogListBlock = "bloglistblock"; //html博客列表标识  
31 - public static $productCategoryListBlock = "productcategorylistblock"; //html产品分类列表标识 18 +
32 const DATABASE_NAME_FIX = 'gl_data_'; 19 const DATABASE_NAME_FIX = 'gl_data_';
33 20
34 const CUSTOMIZED_ONE = 1;//定制项目 21 const CUSTOMIZED_ONE = 1;//定制项目
@@ -35,7 +35,7 @@ class TemplateReplaceHtml extends Base @@ -35,7 +35,7 @@ class TemplateReplaceHtml extends Base
35 '新闻列表'=>['source'=>4,'is_list'=>1,'is_custom'=>0], 35 '新闻列表'=>['source'=>4,'is_list'=>1,'is_custom'=>0],
36 '博客详情'=>['source'=>3,'is_list'=>0,'is_custom'=>0], 36 '博客详情'=>['source'=>3,'is_list'=>0,'is_custom'=>0],
37 '博客列表'=>['source'=>3,'is_list'=>1,'is_custom'=>0], 37 '博客列表'=>['source'=>3,'is_list'=>1,'is_custom'=>0],
38 - '单页面'=>['source'=>9,'is_list'=>0,'is_custom'=>0], 38 +// '单页面'=>['source'=>9,'is_list'=>0,'is_custom'=>0],
39 ]; 39 ];
40 } 40 }
41 } 41 }
1 -<?php  
2 -  
3 -  
4 -namespace App\Services\Html;  
5 -  
6 -  
7 -use App\Models\Blog\Blog;  
8 -use App\Models\News\News;  
9 -use App\Models\Product\Category;  
10 -use App\Models\Product\CategoryRelated;  
11 -use App\Models\Product\Keyword;  
12 -use App\Models\Product\Product;  
13 -use App\Models\RouteMap\RouteMap;  
14 -use App\Models\WebSetting\SettingNum;  
15 -use App\Models\WebSetting\WebSetting;  
16 -use App\Models\WebSetting\WebSettingAmp;  
17 -use App\Models\WebSetting\WebSettingSeo;  
18 -  
19 -class AmpService  
20 -{  
21 - /**  
22 - * 获取首页html  
23 - * @param $project  
24 - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View  
25 - * @author Akun  
26 - * @date 2024/03/14 15:04  
27 - */  
28 - public static function getIndexHtml($project)  
29 - {  
30 - //站点配置  
31 - $project_config = self::getProjectConfig($project->id);  
32 -  
33 - //产品所有分类  
34 - $category = self::getProductsCategory($project->id);  
35 -  
36 - //排序最前的3个产品  
37 - $products = self::getProductsList($project->id, 1, 3)['data'];  
38 -  
39 - //排序最前的3篇新闻  
40 - $news = self::getNewsBlogList($project->id, 1, 1, 3)['data'];  
41 -  
42 - //排序最前的3篇博客  
43 - $blogs = AmpService::getNewsBlogList($project->id, 2, 1, 3)['data'];  
44 -  
45 - //当前页面地址  
46 - $current_url = self::getCurrentUrl($project->domain);  
47 -  
48 - return view('amp/index', compact('project_config', 'category', 'products', 'news', 'blogs', 'current_url'));  
49 - }  
50 -  
51 - /**  
52 - * 获取路由页html  
53 - * @param $project  
54 - * @param $route  
55 - * @param $source  
56 - * @param $page  
57 - * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View  
58 - * @author Akun  
59 - * @date 2024/03/14 15:05  
60 - */  
61 - public static function getHtmlByRoute($project, $route, $source, $page)  
62 - {  
63 - //站点配置  
64 - $project_config = self::getProjectConfig($project->id);  
65 -  
66 - //产品所有分类  
67 - $category = self::getProductsCategory($project->id);  
68 -  
69 - //固定菜单页面  
70 - if ($route == '404') {  
71 - //404页面  
72 - $current_url = self::getCurrentUrl($project->domain, '/404/');  
73 - return view('amp/404', compact('project_config', 'category', 'current_url'));  
74 - } elseif ($route == 'contact-us') {  
75 - //contact-us页面  
76 - $current_url = self::getCurrentUrl($project->domain, '/contact-us/');  
77 - return view('amp/contact', compact('project_config', 'category', 'current_url'));  
78 - } elseif ($route == 'about-us') {  
79 - //about-us页面  
80 - $current_url = self::getCurrentUrl($project->domain, '/aboout-us/');  
81 - return view('amp/about', compact('project_config', 'category', 'current_url'));  
82 - } elseif ($route == 'products') {  
83 - //产品列表  
84 - $products = self::getProductsList($project->id, $page, 8);  
85 -  
86 - //当前分类详情  
87 - $category_info = self::getCategoryInfo($project->id, 0);  
88 -  
89 - $current_url = self::getCurrentUrl($project->domain, '/' . $category_info['route'] . '/' . ($page > 1 ? $page . '/' : ''));  
90 -  
91 - return view('amp/products', compact('project_config', 'category', 'products', 'category_info', 'page', 'current_url'));  
92 - } elseif ($route == 'news') {  
93 - //新闻列表  
94 - $news = self::getNewsBlogList($project->id, 1, $page, 5);  
95 -  
96 - $current_url = self::getCurrentUrl($project->domain, '/news/' . ($page > 1 ? $page . '/' : ''));  
97 - return view('amp/news', compact('project_config', 'category', 'news', 'page', 'current_url'));  
98 - } elseif ($route == 'blog') {  
99 - //博客列表  
100 - $blogs = self::getNewsBlogList($project->id, 2, $page, 5);  
101 -  
102 - $current_url = self::getCurrentUrl($project->domain, '/blog/' . ($page > 1 ? $page . '/' : ''));  
103 - return view('amp/blogs', compact('project_config', 'category', 'blogs', 'page', 'current_url'));  
104 - } elseif (strpos($route, 'top-search') !== false) {  
105 - //top-search页面  
106 - $pageService = new PageService();  
107 - $search_list = $pageService->getProductKeywordsByLetter($project, $route, $page);  
108 -  
109 - //处理路由后缀为-tag的关键词  
110 - foreach ($search_list['pageInfo']['pageListData'] as &$v) {  
111 - if (substr($v['route'], -4, 4) == '-tag') {  
112 - $v['route'] = substr($v['route'], 0, -4);  
113 - }  
114 - }  
115 -  
116 - //俄语站没有首字母筛选  
117 - if ($project->serve_id == 3) {  
118 - $search_list['keywordsLabel'] = [];  
119 - }  
120 -  
121 - $total_page = count($search_list['pageInfo']['pageNum']);  
122 - $search_list['pageInfo']['center_pages'] = page_init($page, $total_page);  
123 - $search_list['pageInfo']['prev'] = max($page - 1, 1);  
124 - $search_list['pageInfo']['next'] = min($page + 1, $total_page);  
125 -  
126 - $current_url = self::getCurrentUrl($project->domain, '/' . $route . '/' . ($page > 1 ? $page . '/' : ''));  
127 - return view('amp/top_search', compact('project_config', 'category', 'search_list', 'page', 'route', 'current_url'));  
128 - } else {  
129 - //剩下的页面:产品分类,产品详情,新闻详情,关键词详情  
130 - $map = ['route' => $route];  
131 - if ($source) {  
132 - $map['source'] = $source;  
133 - }  
134 - $route_info = RouteMap::where($map)->orderByRaw("FIELD(source, 'product_category','product','news','blog','product_keyword')")->first();  
135 - if (!$route_info) {  
136 - //特殊情况:关键词后缀为-tag  
137 - $map['route'] = $route . '-tag';  
138 - $map['source'] = 'product_keyword';  
139 - $route_info = RouteMap::where($map)->first();  
140 - }  
141 - if (!$route_info) {  
142 - $current_url = self::getCurrentUrl($project->domain, '/404/');  
143 - return view('amp/404', compact('project_config', 'category', 'current_url'));  
144 - }  
145 -  
146 - switch ($route_info->source) {  
147 - case 'product_category':  
148 - //产品列表  
149 - $products = self::getProductsList($project->id, $page, 8, $route_info->source_id);  
150 -  
151 - //当前分类详情  
152 - $category_info = self::getCategoryInfo($project->id, $route_info->source_id);  
153 -  
154 - $current_url = self::getCurrentUrl($project->domain, '/' . $category_info['route'] . '/' . ($page > 1 ? $page . '/' : ''));  
155 - return view('amp/products', compact('project_config', 'category', 'products', 'category_info', 'page', 'current_url'));  
156 - case 'product':  
157 - //获取产品详情  
158 - $product_info = self::getProductInfo($project->id, $route_info->source_id);  
159 -  
160 - //获取关联产品  
161 - $relate_products = self::getRelateProducts($project->id, $product_info['id'], $product_info['category_id'], 8);  
162 -  
163 - $current_url = self::getCurrentUrl($project->domain, '/' . $product_info['route'] . '/');  
164 - return view('amp/product_info', compact('project_config', 'category', 'product_info', 'relate_products', 'current_url'));  
165 - case 'news':  
166 - //新闻详情  
167 - $news_info = self::getNewsBlogInfo($project->id, 1, $route_info->source_id);  
168 -  
169 - $current_url = self::getCurrentUrl($project->domain, '/news/' . $news_info['url'] . '/');  
170 - return view('amp/news_info', compact('project_config', 'category', 'news_info', 'current_url'));  
171 - case 'blog':  
172 - //博客详情  
173 - $blog_info = self::getNewsBlogInfo($project->id, 2, $route_info->source_id);  
174 -  
175 - $current_url = self::getCurrentUrl($project->domain, '/blog/' . $blog_info['url'] . '/');  
176 - return view('amp/blog_info', compact('project_config', 'category', 'blog_info', 'current_url'));  
177 - case 'product_keyword':  
178 - //获取关键词详情  
179 - $tag_info = self::getTagInfo($project->id, $route_info->source_id);  
180 -  
181 - //获取关联产品和热门产品  
182 - $pageService = new PageService();  
183 - $products = $pageService->getRecommendAndHotProducts($project, $tag_info['route']) ?: [];  
184 -  
185 - //获取关联新闻  
186 - $news = self::getNewsBlogList($project->id, 1, 1, 2)['data'];  
187 -  
188 - //随机获取关键词列表  
189 - $relate_tags = self::getRelateTags($project->id);  
190 -  
191 - $current_url = self::getCurrentUrl($project->domain, '/' . $tag_info['route'] . '/');  
192 - return view('amp/tag', compact('project_config', 'category', 'tag_info', 'products', 'news', 'relate_tags', 'current_url'));  
193 - default:  
194 - $current_url = self::getCurrentUrl($project->domain, '/404/');  
195 - return view('amp/404', compact('project_config', 'category', 'current_url'));  
196 - }  
197 - }  
198 - }  
199 -  
200 - /**  
201 - * 拼接当前页面完整路径  
202 - * @param $domain  
203 - * @param $path  
204 - * @return string  
205 - * @author Akun  
206 - * @date 2024/03/15 15:48  
207 - */  
208 - public static function getCurrentUrl($domain, $path = '')  
209 - {  
210 - $host_array = explode('.', $domain);  
211 - if (count($host_array) <= 2) {  
212 - array_unshift($host_array, 'm');  
213 - } else {  
214 - $host_array[0] = 'm';  
215 - }  
216 - $amp_domain = implode('.', $host_array);  
217 -  
218 - return 'https://' . $amp_domain . $path;  
219 - }  
220 -  
221 - /**  
222 - * 获取站点amp配置  
223 - * @param $project_id  
224 - * @return mixed  
225 - * @author Akun  
226 - * @date 2024/01/26 16:07  
227 - */  
228 - public static function getProjectConfig($project_id)  
229 - {  
230 - $config_amp = WebSettingAmp::where('project_id', $project_id)->first();  
231 -  
232 - $config_index = WebSetting::where('project_id', $project_id)->first();  
233 -  
234 - $config_seo = WebSettingSeo::where('project_id', $project_id)->first();  
235 -  
236 - $show_news = News::where('project_id', $project_id)->where('status', 1)->count('id');  
237 -  
238 - $show_blogs = Blog::where('project_id', $project_id)->where('status', 1)->count('id');  
239 -  
240 - return [  
241 - 'show_news' => $show_news,  
242 - 'show_blogs' => $show_blogs,  
243 - 'top_backgroundcolor' => $config_amp->top_backgroundcolor ?? '',  
244 - 'web_icon' => $config_amp->web_icon ?? '',  
245 - 'top_logo' => $config_amp->top_logo ?? [],  
246 - 'index_banner' => $config_amp->index_banner ?? [],  
247 - 'index_intro' => $config_amp->index_intro ?? '',  
248 - 'company_image' => $config_amp->company_image ?? [],  
249 - 'company_about' => $config_amp->company_about ?? '',  
250 - 'company_email' => $config_amp->company_email ?? '',  
251 - 'company_address' => $config_amp->company_address ?? '',  
252 - 'company_tel' => $config_amp->company_tel ?? '',  
253 - 'third_code' => $config_amp->third_code ?? '',  
254 - 'index_title' => $config_index->title ?? '',  
255 - 'index_description' => $config_index->remark ?? '',  
256 - 'index_keywords' => $config_index->keyword ?? '',  
257 - 'single_page_suffix' => $config_seo->single_page_suffix ?? '',  
258 - 'tab_suffix' => $config_seo->tab_suffix ?? '',  
259 - 'tab_prefix' => $config_seo->tab_prefix ?? '',  
260 - 'product_cate_suffix' => $config_seo->product_cate_suffix ?? '',  
261 - 'product_cate_prefix' => $config_seo->product_cate_prefix ?? '',  
262 - 'product_suffix' => $config_seo->product_suffix ?? '',  
263 - 'product_prefix' => $config_seo->product_prefix ?? '',  
264 - ];  
265 - }  
266 -  
267 - /**  
268 - * 获取分类列表  
269 - * @param $project_id  
270 - * @return array  
271 - * @author Akun  
272 - * @date 2024/01/29 11:25  
273 - */  
274 - public static function getProductsCategory($project_id)  
275 - {  
276 - $category = [];  
277 - $result = Category::where('project_id', $project_id)->where('title', '!=', 'Featured Products')->where('status', 1)->orderBy("sort", "desc")->orderBy("id", "desc")->get();  
278 - if ($result->count() > 0) {  
279 - $result_tree = list_to_tree($result->toArray());  
280 - foreach ($result_tree as $cate) {  
281 - if ($cate['title'] == 'Products' || $cate['title'] == 'products') {  
282 - foreach ($cate['_child'] as $child) {  
283 - $category[] = $child;  
284 - }  
285 - } else {  
286 - $category[] = $cate;  
287 - }  
288 - }  
289 - }  
290 -  
291 -  
292 - return $category;  
293 - }  
294 -  
295 - /**  
296 - * 获取分类详情  
297 - * @param $project_id  
298 - * @param $category_id  
299 - * @return array  
300 - * @author Akun  
301 - * @date 2024/01/29 11:31  
302 - */  
303 - public static function getCategoryInfo($project_id, $category_id)  
304 - {  
305 - if ($category_id > 0) {  
306 - $category_info = Category::where('project_id', $project_id)->where('id', $category_id)->first();  
307 - } else {  
308 - $category_info = Category::where('project_id', $project_id)->whereIn('title', ['Products', 'products'])->first();  
309 - if ($category_info) {  
310 - $category_info->id = 0;  
311 - } else {  
312 - return [  
313 - 'id' => 0,  
314 - 'route' => 'products',  
315 - 'title' => 'Products',  
316 - 'keywords' => '',  
317 - 'describe' => '',  
318 - 'seo_title' => '',  
319 - 'seo_keywords' => '',  
320 - 'seo_description' => '',  
321 - ];  
322 - }  
323 - }  
324 -  
325 - return [  
326 - 'id' => $category_info->id ?? 0,  
327 - 'route' => $category_info->route ?? '',  
328 - 'title' => $category_info->title ?? '',  
329 - 'keywords' => $category_info->keywords ?? '',  
330 - 'describe' => $category_info->describe ?? '',  
331 - 'seo_title' => $category_info->seo_title ?? '',  
332 - 'seo_keywords' => $category_info->seo_keywords ?? '',  
333 - 'seo_description' => $category_info->seo_des ?? '',  
334 - ];  
335 - }  
336 -  
337 - /**  
338 - * 根据分类id获取产品id  
339 - * @param $category_id  
340 - * @return mixed  
341 - * @author Akun  
342 - * @date 2024/01/29 11:26  
343 - */  
344 - public static function getProductIdByCategory($category_id)  
345 - {  
346 - return CategoryRelated::where('cate_id', $category_id)->pluck('product_id')->toArray();  
347 - }  
348 -  
349 - /**  
350 - * 获取产品列表  
351 - * @param int $project_id  
352 - * @param int $page  
353 - * @param int $limit  
354 - * @param int $category_id  
355 - * @param string $search  
356 - * @return array  
357 - * @author Akun  
358 - * @date 2024/01/26 16:07  
359 - */  
360 - public static function getProductsList($project_id, $page = 1, $limit = 20, $category_id = 0, $search = '')  
361 - {  
362 - $total_page = 0;  
363 - $products = [];  
364 -  
365 - $model = Product::where('project_id', $project_id)->where('status', 1);  
366 - //根据分类id获取关联的产品id  
367 - if ($category_id > 0) {  
368 - $product_ids = self::getProductIdByCategory($category_id);  
369 - if ($product_ids) {  
370 - $model = $model->whereIn('id', $product_ids);  
371 - }  
372 - } else {  
373 - //获取所有产品需要排除掉Featured Products分类  
374 - $fp_cate_id = Category::where('title', 'Featured Products')->value('id');  
375 - $model->where('category_id', '!=', ',' . $fp_cate_id . ',');  
376 - }  
377 - //搜索条件  
378 - if ($search) {  
379 - if (strpos($search, '\\') !== false) {  
380 - $search = str_replace('\\', '\\\\', $search);  
381 - }  
382 - $model = $model->where('title', 'like', "%$search%");  
383 - }  
384 -  
385 - $count = $model->count('id');  
386 - if ($count > 0) {  
387 - $total_page = (int)ceil($count / $limit);  
388 -  
389 - //获取产品自定义排序规则  
390 - $sort_rule = self::getProductSortRule($project_id);  
391 - foreach ($sort_rule as $rk => $rv) {  
392 - $model = $model->orderBy($rk, $rv);  
393 - }  
394 -  
395 - $result = $model->select(['id', 'title', 'thumb', 'intro', 'content', 'route'])->offset(($page - 1) * $limit)->limit($limit)->get();  
396 - if ($result->count() > 0) {  
397 - foreach ($result as $value) {  
398 - $thumb = [];  
399 - if ($value->thumb) {  
400 - $thumb_arr = json_decode($value->thumb, true);  
401 - $thumb = [  
402 - 'alt' => (isset($thumb_arr['alt']) && $thumb_arr['alt']) ? $thumb_arr['alt'] : $value->title,  
403 - 'url' => getImageUrl($thumb_arr['url'] ?? '')  
404 - ];  
405 - }  
406 - $intro = $value->intro ?: $value->content;  
407 - $intro = strip_tags(special2str($intro));  
408 - $products[] = [  
409 - 'id' => $value->id,  
410 - 'title' => $value->title,  
411 - 'thumb' => $thumb,  
412 - 'route' => $value->route,  
413 - 'intro' => strlen($intro) > 200 ? substr($intro, 0, 200) . '...' : $intro,  
414 - ];  
415 - }  
416 - }  
417 - }  
418 -  
419 - $pre = max($page - 1, 1);  
420 - $next = min($page + 1, $total_page);  
421 - $center_pages = page_init($page, $total_page);  
422 -  
423 - return ['data' => $products, 'total_page' => $total_page, 'prev' => $pre, 'next' => $next, 'center_pages' => $center_pages];  
424 - }  
425 -  
426 - /**  
427 - * 获取产品自定义排序规则  
428 - * @param $project_id  
429 - * @return array|string[]  
430 - * @author Akun  
431 - * @date 2024/03/21 11:13  
432 - */  
433 - public static function getProductSortRule($project_id)  
434 - {  
435 - $order_list = [];  
436 - $orderDataFirst = SettingNum::where('project_id', $project_id)->where('type', 10)->first();  
437 - if ($orderDataFirst && $orderDataFirst->data) {  
438 - $orderData = json_decode($orderDataFirst->data, true);  
439 - foreach ($orderData as $key => $orderDataItem) {  
440 - $orderKey = $key == "created_at" ? "send_time" : $key;  
441 - $order_list[$orderKey] = $orderDataItem;  
442 - if ($key != "id") {  
443 - $order_list['id'] = 'desc';  
444 - }  
445 - }  
446 - } else {  
447 - $order_list = [  
448 - 'sort' => 'desc',  
449 - 'id' => 'desc'  
450 - ];  
451 - }  
452 -  
453 - return $order_list;  
454 - }  
455 -  
456 - /**  
457 - * 获取产品详情  
458 - * @param $project_id  
459 - * @param $id  
460 - * @return array  
461 - * @author Akun  
462 - * @date 2024/01/30 9:22  
463 - */  
464 - public static function getProductInfo($project_id, $id)  
465 - {  
466 - $gallery = [];  
467 - $seo = [  
468 - 'title' => '',  
469 - 'keywords' => '',  
470 - 'description' => ''  
471 - ];  
472 - $product_info = Product::where('project_id', $project_id)->where('status', 1)->where('id', $id)->first();  
473 - if ($product_info) {  
474 - if ($product_info->gallery) {  
475 - $gallery_arr = json_decode($product_info->gallery, true);  
476 - foreach ($gallery_arr as $vg) {  
477 - $gallery[] = [  
478 - 'alt' => (isset($vg['alt']) && $vg['alt']) ? $vg['alt'] : $product_info->title,  
479 - 'url' => getImageUrl($vg['url'] ?? '')  
480 - ];  
481 - }  
482 - }  
483 -  
484 - if ($product_info->seo_mate) {  
485 - $seo_arr = json_decode($product_info->seo_mate, true);  
486 - $seo['title'] = $seo_arr['title'] ?? '';  
487 - $seo['keywords'] = $seo_arr['keywords'] ?? '';  
488 - $seo['description'] = $seo_arr['description'] ?? '';  
489 - }  
490 - }  
491 -  
492 - return [  
493 - 'id' => $product_info->id ?? 0,  
494 - 'route' => $product_info->route ?? '',  
495 - 'gallery' => $gallery,  
496 - 'title' => $product_info->title ?? '',  
497 - 'intro' => $product_info->intro ?? '',  
498 - 'content' => $product_info->content ?? '',  
499 - 'seo' => $seo,  
500 - 'category_id' => $product_info->category_id ?? ''  
501 - ];  
502 - }  
503 -  
504 - /**  
505 - * 获取关联产品  
506 - * @param $project_id  
507 - * @param $id  
508 - * @param $category_id  
509 - * @param $limit  
510 - * @return array  
511 - * @author Akun  
512 - * @date 2024/01/30 9:34  
513 - */  
514 - public static function getRelateProducts($project_id, $id, $category_id, $limit = 2)  
515 - {  
516 - if (is_string($category_id)) {  
517 - $category_id = explode(',', $category_id);  
518 - }  
519 -  
520 - $relate_ids = CategoryRelated::whereIn('cate_id', $category_id)->where('product_id', '!=', $id)->limit($limit)->pluck('product_id')->toArray();  
521 -  
522 - $relate_products = [];  
523 - if ($relate_ids) {  
524 - $result = Product::where('project_id', $project_id)->whereIn('id', $relate_ids)->where('status', 1)->orderBy('sort', 'desc')->limit(8)->get();  
525 - if ($result->count() == 0) {  
526 - $result = Product::where('project_id', $project_id)->where('status', 1)->inRandomOrder()->take(8)->get();  
527 - }  
528 - if ($result->count() > 0) {  
529 - foreach ($result as $value) {  
530 - $thumb = '';  
531 - if ($value->thumb) {  
532 - $thumb_arr = json_decode($value->thumb, true);  
533 - $thumb = [  
534 - 'alt' => (isset($thumb_arr['alt']) && $thumb_arr['alt']) ? $thumb_arr['alt'] : $value->title,  
535 - 'url' => getImageUrl($thumb_arr['url'] ?? '')  
536 - ];  
537 - }  
538 - $relate_products[] = [  
539 - 'id' => $value->id,  
540 - 'route' => $value->route,  
541 - 'title' => $value->title,  
542 - 'thumb' => $thumb  
543 - ];  
544 - }  
545 - }  
546 - }  
547 -  
548 - return $relate_products;  
549 - }  
550 -  
551 - /**  
552 - * 获取新闻博客列表  
553 - * @param $project_id  
554 - * @param int $type  
555 - * @param int $page  
556 - * @param int $limit  
557 - * @return array  
558 - * @author Akun  
559 - * @date 2024/01/26 16:38  
560 - */  
561 - public static function getNewsBlogList($project_id, $type = 1, $page = 1, $limit = 10)  
562 - {  
563 - $total_page = 0;  
564 - $news = [];  
565 -  
566 - if ($type == 1) {  
567 - $model = new News();  
568 - } else {  
569 - $model = new Blog();  
570 - }  
571 - $count = $model->where('project_id', $project_id)->where('status', 1)->count('id');  
572 - if ($count > 0) {  
573 - $total_page = (int)ceil($count / $limit);  
574 -  
575 - $result = $model->select(['id', 'name', 'image', 'remark', 'text', 'release_at', 'created_at', 'url'])->where('project_id', $project_id)->where('status', 1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->offset(($page - 1) * $limit)->limit($limit)->get();  
576 - if ($result->count() > 0) {  
577 - foreach ($result as $value) {  
578 - $remark = $value->remark ?: $value->text;  
579 - $remark = strip_tags(special2str($remark));  
580 - $news[] = [  
581 - 'type' => $type,  
582 - 'id' => $value->id,  
583 - 'name' => $value->name,  
584 - 'url' => $value->url,  
585 - 'image' => getImageUrl($value->image),  
586 - 'remark' => strlen($remark) > 200 ? substr($remark, 0, 200) . '...' : $remark,  
587 - 'release_at' => $value->release_at ? $value->release_at : $value->created_at  
588 - ];  
589 - }  
590 - }  
591 - }  
592 -  
593 - $pre = max($page - 1, 1);  
594 - $next = min($page + 1, $total_page);  
595 - $center_pages = page_init($page, $total_page);  
596 -  
597 -  
598 - return ['data' => $news, 'total_page' => $total_page, 'prev' => $pre, 'next' => $next, 'center_pages' => $center_pages];  
599 - }  
600 -  
601 - /**  
602 - * 获取新闻博客详情  
603 - * @param $project_id  
604 - * @param $type  
605 - * @param $id  
606 - * @return array  
607 - * @author Akun  
608 - * @date 2024/01/30 11:17  
609 - */  
610 - public static function getNewsBlogInfo($project_id, $type, $id)  
611 - {  
612 - if ($type == 1) {  
613 - $model = new News();  
614 - } else {  
615 - $model = new Blog();  
616 - }  
617 -  
618 - $news_info = $model->where('project_id', $project_id)->where('status', 1)->where('id', $id)->first();  
619 -  
620 - $release_at = '';  
621 - if (isset($news_info->release_at) && $news_info->release_at) {  
622 - $release_at = $news_info->release_at;  
623 - } elseif (isset($news_info->created_at) && $news_info->created_at) {  
624 - $release_at = $news_info->created_at;  
625 - }  
626 -  
627 - return [  
628 - 'id' => $news_info->id ?? 0,  
629 - 'name' => $news_info->name ?? '',  
630 - 'sort' => $news_info->sort ?? 0,  
631 - 'url' => $news_info->url ?? 0,  
632 - 'text' => $news_info->text ?? '',  
633 - 'image' => getImageUrl($news_info->image ?? ''),  
634 - 'seo_title' => $news_info->seo_title ?? '',  
635 - 'seo_keywords' => $news_info->seo_keywords ?? '',  
636 - 'seo_description' => $news_info->seo_description ?? '',  
637 - 'release_at' => $release_at  
638 - ];  
639 - }  
640 -  
641 - /**  
642 - * 获取关键词详情  
643 - * @param $project_id  
644 - * @param $id  
645 - * @return array  
646 - * @author Akun  
647 - * @date 2024/01/30 16:17  
648 - */  
649 - public static function getTagInfo($project_id, $id)  
650 - {  
651 - $tag_info = Keyword::where('project_id', $project_id)->where('status', 1)->where('id', $id)->first();  
652 -  
653 - return [  
654 - 'id' => $tag_info->id ?? 0,  
655 - 'route' => $tag_info->route ?? '',  
656 - 'title' => $tag_info->title ?? '',  
657 - 'keyword_title' => $tag_info->keyword_title ?? '',  
658 - 'keyword_content' => $tag_info->keyword_content ?? '',  
659 - 'seo_title' => $tag_info->seo_title ?? '',  
660 - 'seo_keywords' => $tag_info->seo_keywords ?? '',  
661 - 'seo_description' => $tag_info->seo_description ?? '',  
662 - ];  
663 - }  
664 -  
665 - /**  
666 - * 获取关联关键词  
667 - * @param $project_id  
668 - * @return mixed  
669 - * @author Akun  
670 - * @date 2024/01/30 18:30  
671 - */  
672 - public static function getRelateTags($project_id)  
673 - {  
674 - return Keyword::select(['id', 'title', 'route'])->where('project_id', $project_id)->where('status', 1)->inRandomOrder()->take(10)->get()->toArray();  
675 - }  
676 -}  
1 -<?php  
2 -  
3 -  
4 -namespace App\Services\Html;  
5 -  
6 -use App\Helper\Translate;  
7 -use App\Models\Com\UpdateProgress;  
8 -use App\Models\Project\DeployBuild;  
9 -use App\Models\Project\DeployOptimize;  
10 -use App\Models\Project\DomainInfo;  
11 -use App\Models\Project\Project;  
12 -use App\Models\RouteMap\RouteMap;  
13 -use App\Models\WebSetting\Proofreading;  
14 -use App\Models\WebSetting\WebLanguage;  
15 -use App\Models\WebSetting\WebProofreading;  
16 -use App\Models\WebSetting\WebSetting;  
17 -use App\Models\WebSetting\WebSettingCountry;  
18 -use App\Models\WebSetting\WebSettingHtml;  
19 -use App\Models\WebSetting\WebSettingText;  
20 -use App\Models\WebSetting\WebTemplateCommon;  
21 -use App\Services\ProjectServer;  
22 -use Illuminate\Support\Facades\Redis;  
23 -use phpQuery;  
24 -  
25 -/**  
26 - * 生成静态页相关  
27 - */  
28 -class CommonService  
29 -{  
30 -  
31 - /**  
32 - * 翻译  
33 - */  
34 - public function webHtmlTranslate($project,$content, $lang,$domain)  
35 - {  
36 - //翻译过滤器  
37 - $lang = $lang == "zh-ct" ? "zh-TW" : $lang;  
38 - $tlsList = Translate::$tls_list;  
39 - if (isset($tlsList[$lang])){  
40 - $main_lang = $project->main_lang_id;  
41 - $mainLangInfo = WebLanguage::getProjectMainLang($main_lang);  
42 - $master_lang = $mainLangInfo ? $mainLangInfo->short : 'en';  
43 - //翻译  
44 - if ($master_lang != 'en') {  
45 - $result = Translate::translate($content, $lang, $master_lang);  
46 - $content = $result[0]['texts'] ?? '';  
47 - } else {  
48 - $content = Translate::tran($content, $lang);  
49 - }  
50 - // 翻译有时会返回空数据 再翻译一次 FIXME 后续需要重新封装  
51 - if (empty($content)) {  
52 - $result = Translate::translate($content, $lang, $master_lang);  
53 - $content = $result[0]['texts'] ?? '';  
54 - }  
55 -  
56 - //翻译校对  
57 - $content = $this->translationProofread($project,$content,$lang,$domain);  
58 - }  
59 - return $content;  
60 - }  
61 -  
62 - /**  
63 - * 翻译校对  
64 - */  
65 - public function translationProofread($project, $content, $lang,$domain)  
66 - {  
67 - $webProofreading = Proofreading::where("project_id",$project->id)->where("alias",$lang)->get();  
68 - if (!empty($webProofreading)){  
69 - foreach ($webProofreading as $item){  
70 - $content = str_ireplace($item->text,$item->translate,$content);  
71 - }  
72 - }  
73 - return $content;  
74 - }  
75 -  
76 - /**  
77 - * 处理第三方代码  
78 - */  
79 - public function thirdPartyCodeHandle($project,$content,$route,$routeMap=null): string  
80 - {  
81 - if (Redis::get("project_".$project->id."_third_party_code") != null){  
82 - $webSettingHtml = json_decode(Redis::get("project_".$project->id."_third_party_code"));  
83 - }else{  
84 - $webSettingHtml = WebSettingHtml::where("project_id",$project->id)->first();  
85 - Redis::set("project_".$project->id."_third_party_code", json_encode($webSettingHtml));  
86 - Redis::expire("project_".$project->id."_third_party_code", WebSetting::$redisExpireTime);  
87 - }  
88 - $phpQueryDom = phpQuery::newDocument($content);  
89 - //网站icon  
90 - $webIcon = WebSetting::where("project_id",$project->id)->first();  
91 - if (!empty($webIcon)){  
92 - $iconDom = $phpQueryDom->find("link[rel=icon]");  
93 - if (count($iconDom) >= 1){  
94 - if (isset($webIcon->web_site_icon) && !empty($webIcon->web_site_icon) && $webIcon->web_site_icon != "" && $webIcon->web_site_icon != 0){  
95 - $iconDom->attr("href",$webIcon->web_site_icon);  
96 - }else{  
97 - $iconDom->attr("href","");  
98 - }  
99 - }  
100 - }  
101 - //第三方代码(网页顶部,中间,底部),以后启用位置  
102 - if (!empty($webSettingHtml)) {  
103 - $phpQueryDom->find('head')->append($webSettingHtml->head_html?:'');  
104 - $phpQueryDom->find('body')->append($webSettingHtml->body_html?:'');  
105 - $phpQueryDom->find('html')->append($webSettingHtml->footer_html?:'');  
106 - }  
107 - //A端添加的网站追踪代码  
108 - $deployOptimize = DeployOptimize::where("project_id",$project->id)->first();  
109 - if (!empty($deployOptimize)){  
110 - if (isset($deployOptimize->meta) && !empty($deployOptimize->meta)){  
111 - $phpQueryDom->find('head')->append($deployOptimize->meta);  
112 - }  
113 - }  
114 - //首页头部独立样式  
115 - if ($route == "index"){  
116 - $phpQueryDom->find('header')->attr("headerprivate","");  
117 - }  
118 - //处理header顶部搜索跳转链接  
119 - $phpQueryDom->find('header form')->attr("action", "/search/");  
120 - //C端访问埋点  
121 - $isBodyEnd = $phpQueryDom->find('body')->eq(0);  
122 - if (count($isBodyEnd)>=1){  
123 - $phpQueryDom->find('body')->append("<script src='https://ecdn6.globalso.com/public/customerVisit.min.js'></script>");  
124 - }else{  
125 - $phpQueryDom->find('html')->append("<script src='https://ecdn6.globalso.com/public/customerVisit.min.js'></script>");  
126 - }  
127 - $data = date("Y-m-d H:i:s");  
128 - $phpQueryDom->find('html')->append("<!-- Globalso Cache file was created on ".$data." -->");  
129 - //这个功能其他类型页面移到面包屑导航处理  
130 - if ($route == "index" || (!empty($routeMap) && $routeMap->source == RouteMap::SOURCE_PAGE)){  
131 - $phpQueryDom->find('head')->append('<script>var currentPage = "'.$route.'"</script>');  
132 - }  
133 - if ($route == "search"){  
134 - //暂时先去掉小语种按钮显示  
135 - $phpQueryDom->find(".change-language")->remove();  
136 - $phpQueryDom->find('head')->append('<meta name="robots" content="noindex, nofollow"/>');  
137 - }  
138 - $phpQueryDom->find('body')->attr("unevents","");  
139 - $content = $phpQueryDom->htmlOuter();  
140 - unset($phpQueryDom);  
141 - phpQuery::unloadDocuments();  
142 - //处理全部内容,如果有上线正式域名,则把所有的测试域名替换为正式域名  
143 - $projectDomainInfo = DomainInfo::where("project_id",$project->id)->first();  
144 - if (!empty($projectDomainInfo)){  
145 - $deployBuild = DeployBuild::where("project_id",$project->id)->first();  
146 - if (!empty($deployBuild)){  
147 - $parsedUrl = parse_url($deployBuild->test_domain);  
148 - $domain = $projectDomainInfo->domain;  
149 - $testDomain = $parsedUrl['host'];  
150 - if ($domain != '' && $testDomain != ''){  
151 - $content = str_replace($testDomain,$domain,$content);  
152 - }  
153 - }  
154 - }  
155 - return $content;  
156 - }  
157 -  
158 - /**  
159 - * 处理锚文本  
160 - */  
161 - public function anchorTextHandle($project,$route,$content): string  
162 - {  
163 - $source = "";  
164 - //解析路由  
165 - if ($route != "index"){  
166 - $routerNewsMap = RouteMap::where("project_id",$project->id)->where("route",$route)->first();  
167 - if (!empty($routerNewsMap)){  
168 - $source = $routerNewsMap->source;  
169 - }  
170 - }else{  
171 - $source = "index";  
172 - }  
173 -  
174 - //判断来源类型  
175 - switch ($source) {  
176 - case 'news_category' || 'news':  
177 - $num = 4;  
178 - break;  
179 - case 'product_category' || 'product':  
180 - $num = 2;  
181 - break;  
182 - case 'blog_category' || 'blog':  
183 - $num = 6;  
184 - break;  
185 - case 'page':  
186 - $num = 1;  
187 - break;  
188 - default:  
189 - $num = 1;  
190 - }  
191 -  
192 - //网站设置锚文本  
193 - $webSetting = WebSetting::getWebSetting($project);  
194 - if (!empty($webSetting)){  
195 - $anchorIsEnable = $webSetting->anchor_is_enable;  
196 - if ($anchorIsEnable == 0){  
197 - $anchorSetting = $webSetting->anchor_setting;  
198 - $anchorSettingArr = explode(',', substr($anchorSetting, 1, -1));  
199 - foreach ($anchorSettingArr as $item){  
200 - $itemArr = explode('"', substr($item, 1, -1));  
201 - $tracingText[] = intval($itemArr[0]);  
202 - }  
203 - if (in_array($num, $tracingText)) {  
204 - $webSettingText = WebSettingText::getWebSettingText($project);  
205 - $phpQueryDom=phpQuery::newDocument($content);  
206 - $mainElement = $phpQueryDom->find('main');  
207 - $con = $mainElement->html();  
208 - if (!empty($webSettingText)){  
209 - foreach ($webSettingText as $v){  
210 - $con = str_replace( $v->key_words, '<a target="_blank" href="'. $v->url.'">'. $v->key_words.'</a>', $con);  
211 - }  
212 - }  
213 - $mainElement->html($con);  
214 - return $phpQueryDom->htmlOuter();  
215 - }  
216 - }  
217 - }  
218 - return $content;  
219 - }  
220 -  
221 - /**  
222 - * 链接项目  
223 - */  
224 - public function connectProject($updateData)  
225 - {  
226 - $project = null;  
227 - $projectIn = Project::getProjectByDomain($updateData->domain);  
228 - if (!empty($projectIn)){  
229 - $project = Project::where("id",$projectIn->project_id)->first();  
230 - if (!empty($project)){  
231 - $project->domain = $updateData->domain;  
232 - }  
233 - ProjectServer::useProject($project->id);  
234 - }  
235 - return $project;  
236 - }  
237 -  
238 - /**  
239 - * 获取小语种更新国家  
240 - */  
241 - public function getMinorLanguage($updateData)  
242 - {  
243 - $minorLanguage = [];  
244 - $updateProgressQuery = UpdateProgress::find($updateData->id);  
245 - if (!empty($updateProgressQuery)){  
246 - $extends = $updateProgressQuery->extends;  
247 - if (!empty($extends)){  
248 - $extends = json_decode($extends);  
249 - if (isset($extends->language) && !empty($extends->language)){  
250 - $language = $extends->language;  
251 - foreach ($language as $lang){  
252 - $minorLanguage[] = (int)$lang;  
253 - }  
254 - }  
255 - }  
256 - }  
257 - return WebSettingCountry::whereIn("id", $minorLanguage)->get();  
258 - }  
259 -}  
1 -<?php  
2 -  
3 -namespace App\Services\Html;  
4 -  
5 -  
6 -  
7 -use phpDocumentor\Reflection\Project;  
8 -  
9 -/**  
10 - * 生成页面  
11 - */  
12 -class CreateHtmlService{  
13 - /**  
14 - * 获取页面  
15 - */  
16 - public function getHtml($projectId, $route, $lang = "", $page = null)  
17 - {  
18 - $project = Project::find($projectId);  
19 - $createPageService = new CreatePageService();  
20 - return $createPageService->getPageByLangRoutePage($project,$route,$page);  
21 - }  
22 -}  
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 -}