作者 lyh
@@ -154,6 +154,7 @@ class ProjectUpdate extends Command @@ -154,6 +154,7 @@ class ProjectUpdate extends Command
154 'seo_title' => $item['seo_title'] ?? '', 154 'seo_title' => $item['seo_title'] ?? '',
155 'seo_keywords' => $item['seo_keywords'] ?? '', 155 'seo_keywords' => $item['seo_keywords'] ?? '',
156 'seo_description' => $item['seo_description'] ?? '', 156 'seo_description' => $item['seo_description'] ?? '',
  157 + 'is_upgrade' => 1,
157 'route' => $route 158 'route' => $route
158 ]); 159 ]);
159 $this->set_map($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id); 160 $this->set_map($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id);
@@ -272,7 +273,7 @@ class ProjectUpdate extends Command @@ -272,7 +273,7 @@ class ProjectUpdate extends Command
272 } 273 }
273 try { 274 try {
274 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 275 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
275 - $id = $model->addReturnId([ 276 + $id = $model->insertGetId([
276 'project_id' => $project_id, 277 'project_id' => $project_id,
277 'title' => $item['ttile'], 278 'title' => $item['ttile'],
278 'intro' => $item['description'] ?? '', 279 'intro' => $item['description'] ?? '',
@@ -286,6 +287,9 @@ class ProjectUpdate extends Command @@ -286,6 +287,9 @@ class ProjectUpdate extends Command
286 'description' => $item['description'] ?? '' 287 'description' => $item['description'] ?? ''
287 ]), 288 ]),
288 'status' => Product::STATUS_ON, 289 'status' => Product::STATUS_ON,
  290 + 'created_at' => $item['post_date'] ?? date('Y-m-d H:i:s'),
  291 + 'updated_at' => $item['post_date'] ?? date('Y-m-d H:i:s'),
  292 + 'sort' => $item['sort'] ?? 0,
289 'is_upgrade' => 1, 293 'is_upgrade' => 1,
290 'route' => $route 294 'route' => $route
291 ]); 295 ]);
@@ -338,7 +342,7 @@ class ProjectUpdate extends Command @@ -338,7 +342,7 @@ class ProjectUpdate extends Command
338 $image = $item['images'] ?? ''; 342 $image = $item['images'] ?? '';
339 } 343 }
340 344
341 - $id = $model->addReturnId([ 345 + $id = $model->insertGetId([
342 'project_id' => $project_id, 346 'project_id' => $project_id,
343 'name' => $item['ttile'], 347 'name' => $item['ttile'],
344 'seo_title' => $item['ttile'], 348 'seo_title' => $item['ttile'],
@@ -347,6 +351,9 @@ class ProjectUpdate extends Command @@ -347,6 +351,9 @@ class ProjectUpdate extends Command
347 'text' => $item['content'] ?? '', 351 'text' => $item['content'] ?? '',
348 'image' => $this->source_download($image, $project_id, $domain_arr['host'], $web_url_domain, $home_url), 352 'image' => $this->source_download($image, $project_id, $domain_arr['host'], $web_url_domain, $home_url),
349 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE, 353 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE,
  354 + 'created_at' => $item['post_date'] ?? date('Y-m-d H:i:s'),
  355 + 'updated_at' => $item['post_date'] ?? date('Y-m-d H:i:s'),
  356 + 'sort' => $item['sort'] ?? 0,
350 'is_upgrade' => 1, 357 'is_upgrade' => 1,
351 'url' => $route 358 'url' => $route
352 ]); 359 ]);
@@ -388,7 +395,7 @@ class ProjectUpdate extends Command @@ -388,7 +395,7 @@ class ProjectUpdate extends Command
388 if (!$custom) { 395 if (!$custom) {
389 try { 396 try {
390 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 397 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
391 - $id = $model->addReturnId([ 398 + $id = $model->insertGetId([
392 'project_id' => $project_id, 399 'project_id' => $project_id,
393 'name' => $item['ttile'], 400 'name' => $item['ttile'],
394 'title' => $item['ttile'], 401 'title' => $item['ttile'],
@@ -396,6 +403,8 @@ class ProjectUpdate extends Command @@ -396,6 +403,8 @@ class ProjectUpdate extends Command
396 'description' => $item['description'] ?? '', 403 'description' => $item['description'] ?? '',
397 'html' => $item['content'] ?? '', 404 'html' => $item['content'] ?? '',
398 'status' => 1, 405 'status' => 1,
  406 + 'created_at' => $item['post_date'] ?? date('Y-m-d H:i:s'),
  407 + 'updated_at' => $item['post_date'] ?? date('Y-m-d H:i:s'),
399 'is_upgrade' => 1, 408 'is_upgrade' => 1,
400 'url' => $route 409 'url' => $route
401 ]); 410 ]);
@@ -268,13 +268,21 @@ class BlogLogic extends BaseLogic @@ -268,13 +268,21 @@ class BlogLogic extends BaseLogic
268 $text = ''; 268 $text = '';
269 if($data[4]){ 269 if($data[4]){
270 //处理内容中的图片 270 //处理内容中的图片
271 - $pattern = '/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';  
272 - preg_match_all($pattern, $data[4], $result);  
273 - if($result[2]){ 271 + preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result);
  272 + if($result[2]??[]){
274 foreach ($result[2] as $img){ 273 foreach ($result[2] as $img){
275 $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]); 274 $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
276 } 275 }
277 } 276 }
  277 +
  278 + //处理内容中的视频
  279 + preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result_video);
  280 + if($result_video[2]??[]){
  281 + foreach ($result_video[2] as $video){
  282 + $data[4] = str_replace($video,getImageUrl(CosService::uploadRemote($project_id,'image_news',$video)),$data[4]);
  283 + }
  284 + }
  285 +
278 $text = $data[4]; 286 $text = $data[4];
279 } 287 }
280 288
@@ -304,13 +304,21 @@ class NewsLogic extends BaseLogic @@ -304,13 +304,21 @@ class NewsLogic extends BaseLogic
304 $text = ''; 304 $text = '';
305 if($data[4]){ 305 if($data[4]){
306 //处理内容中的图片 306 //处理内容中的图片
307 - $pattern = '/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';  
308 - preg_match_all($pattern, $data[4], $result);  
309 - if($result[2]){ 307 + preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result);
  308 + if($result[2]??[]){
310 foreach ($result[2] as $img){ 309 foreach ($result[2] as $img){
311 $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]); 310 $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
312 } 311 }
313 } 312 }
  313 +
  314 + //处理内容中的视频
  315 + preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[4], $result_video);
  316 + if($result_video[2]??[]){
  317 + foreach ($result_video[2] as $video){
  318 + $data[4] = str_replace($video,getImageUrl(CosService::uploadRemote($project_id,'image_news',$video)),$data[4]);
  319 + }
  320 + }
  321 +
314 $text = $data[4]; 322 $text = $data[4];
315 } 323 }
316 324
@@ -602,26 +602,42 @@ class ProductLogic extends BaseLogic @@ -602,26 +602,42 @@ class ProductLogic extends BaseLogic
602 $intro = ''; 602 $intro = '';
603 if($data[5]){ 603 if($data[5]){
604 //处理短描述中的图片 604 //处理短描述中的图片
605 - $pattern = '/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';  
606 - preg_match_all($pattern, $data[5], $result_intro);  
607 - if($result_intro[2]){ 605 + preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[5], $result_intro);
  606 + if($result_intro[2]??[]){
608 foreach ($result_intro[2] as $vi_img){ 607 foreach ($result_intro[2] as $vi_img){
609 $data[5] = str_replace($vi_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_img)),$data[5]); 608 $data[5] = str_replace($vi_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_img)),$data[5]);
610 } 609 }
611 } 610 }
  611 +
  612 + //处理短描述中的视频
  613 + preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[5], $result_intro_video);
  614 + if($result_intro_video[2]??[]){
  615 + foreach ($result_intro_video[2] as $vi_video){
  616 + $data[5] = str_replace($vi_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_video)),$data[5]);
  617 + }
  618 + }
  619 +
612 $intro = $data[5]; 620 $intro = $data[5];
613 } 621 }
614 622
615 $content = ''; 623 $content = '';
616 if($data[6]){ 624 if($data[6]){
617 //处理内容中的图片 625 //处理内容中的图片
618 - $pattern = '/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i';  
619 - preg_match_all($pattern, $data[6], $result_content);  
620 - if($result_content[2]){ 626 + preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[6], $result_content);
  627 + if($result_content[2]??[]){
621 foreach ($result_content[2] as $vc_img){ 628 foreach ($result_content[2] as $vc_img){
622 $data[6] = str_replace($vc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_img)),$data[6]); 629 $data[6] = str_replace($vc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_img)),$data[6]);
623 } 630 }
624 } 631 }
  632 +
  633 + //处理内容中的视频
  634 + preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[6], $result_content_video);
  635 + if($result_content_video[2]??[]){
  636 + foreach ($result_content_video[2] as $vc_video){
  637 + $data[6] = str_replace($vc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_video)),$data[6]);
  638 + }
  639 + }
  640 +
625 $content = $data[6]; 641 $content = $data[6];
626 } 642 }
627 643