作者 刘锟

产品、新闻、博客导入

... ... @@ -280,11 +280,24 @@ class BlogLogic extends BaseLogic
$category_id = $blogCategoryLogic->importBlogCategory($project_id, $user_id, $data[2]);
}
$text = '';
if($data[4]){
//处理内容中的图片
$pattern = '<img src="(.*?)">';
preg_match_all($pattern, $data[4], $result);
if($result[1]){
foreach ($result[1] as $img){
$data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
}
}
$text = $data[4];
}
$id = $this->model->addReturnId(
[
'name' => $data[0],
'category_id' => $category_id,
'text' => $data[4] ?? '',
'text' => $text,
'remark' => $data[3] ?? '',
'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_blog', $data[5]) : '',
'seo_title' => $data[6] ?? '',
... ...
... ... @@ -279,11 +279,24 @@ class NewsLogic extends BaseLogic
$category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]);
}
$text = '';
if($data[4]){
//处理内容中的图片
$pattern = '<img src="(.*?)">';
preg_match_all($pattern, $data[4], $result);
if($result[1]){
foreach ($result[1] as $img){
$data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]);
}
}
$text = $data[4];
}
$id = $this->model->addReturnId(
[
'name' => $data[0],
'category_id' => $category_id,
'text' => $data[4] ?? '',
'text' => $text,
'remark' => $data[3] ?? '',
'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : '',
'seo_title' => $data[6] ?? '',
... ...