|
|
@@ -500,7 +500,7 @@ class NewsService implements NewsServiceInterface
|
|
|
$levelArr = json_decode($articleData['level'], true);
|
|
|
var_dump($levelArr, '----------levelArr-----------1');
|
|
|
//content中提取图片第一个图,正则提取
|
|
|
- $reg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
|
|
|
+ $reg = '/<img.*?src=[\'"]?([^\'" >]+)[\'"]?.*?>/i';
|
|
|
preg_match_all($reg, $data['content'], $matches);
|
|
|
if (isset($matches[1][0])) {
|
|
|
//截取varchar240
|
|
|
@@ -2796,6 +2796,7 @@ class NewsService implements NewsServiceInterface
|
|
|
$childImgArticles = Book::where('cat_id', $childCatId)
|
|
|
->where('status', 2)
|
|
|
->where('img_url', '!=', '')
|
|
|
+ ->where('book.website_id', $website['website_id'])
|
|
|
->leftJoin('website_category', function ($join) use ($website) {
|
|
|
$join->on('book.cat_id', '=', 'website_category.category_id')
|
|
|
->where('website_category.website_id', '=', $website['website_id']);
|
|
|
@@ -2818,6 +2819,7 @@ class NewsService implements NewsServiceInterface
|
|
|
// 查询子栏目文字新闻
|
|
|
$childTextArticles = Book::where('cat_id', $childCatId)
|
|
|
->where('status', 2)
|
|
|
+ ->where('book.website_id', $website['website_id'])
|
|
|
->leftJoin('website_category', function ($join) use ($website) {
|
|
|
$join->on('book.cat_id', '=', 'website_category.category_id')
|
|
|
->where('website_category.website_id', '=', $website['website_id']);
|
|
|
@@ -5217,7 +5219,21 @@ class NewsService implements NewsServiceInterface
|
|
|
$segList1 = array_slice($segList, 0, 8);
|
|
|
$data['keyword'] = implode(',', $segList1);
|
|
|
}
|
|
|
-
|
|
|
+ if(!isset($data['eso_description']) || empty($data['eso_description'])){
|
|
|
+ $content = $data['description'];
|
|
|
+ // 去除 <style> 和 <script> 标签及其内容
|
|
|
+ $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
|
|
|
+ // 去除所有 HTML 标签
|
|
|
+ $content = strip_tags($content);
|
|
|
+ // 去除 HTML 实体
|
|
|
+ $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
|
|
+ // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
|
|
|
+ $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
|
|
|
+ // 去除多余空白
|
|
|
+ $content = preg_replace('/\s+/u', '', $content);
|
|
|
+ // 截取 100 个字符
|
|
|
+ $data['eso_descriprion'] = mb_substr($content, 0, 100);
|
|
|
+ }
|
|
|
|
|
|
// return Result::success($user);
|
|
|
$data['action_id'] = $data['user_id'] ?? null;
|
|
|
@@ -5387,6 +5403,21 @@ class NewsService implements NewsServiceInterface
|
|
|
$segList1 = array_slice($segList, 0, 8);
|
|
|
$data['keyword'] = implode(',', $segList1);
|
|
|
}
|
|
|
+ if(!isset($data['eso_description']) || empty($data['eso_description'])){
|
|
|
+ $content = $data['description'];
|
|
|
+ // 去除 <style> 和 <script> 标签及其内容
|
|
|
+ $content = preg_replace('/<(style|script)[^>]*>.*?<\/\1>/is', '', $content);
|
|
|
+ // 去除所有 HTML 标签
|
|
|
+ $content = strip_tags($content);
|
|
|
+ // 去除 HTML 实体
|
|
|
+ $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
|
|
+ // 只保留文本和标点符号(去除所有字母数字以外的特殊符号,可根据需要调整正则)
|
|
|
+ $content = preg_replace('/[^\p{L}\p{N}\p{P}\p{Zs}]+/u', '', $content);
|
|
|
+ // 去除多余空白
|
|
|
+ $content = preg_replace('/\s+/u', '', $content);
|
|
|
+ // 截取 100 个字符
|
|
|
+ $data['eso_descriprion'] = mb_substr($content, 0, 100);
|
|
|
+ }
|
|
|
$data['cat_arr_id'] = array_values(array_unique($data['cat_arr_id']));
|
|
|
if (isset($data['cat_arr_id']) && !empty($data['cat_arr_id']) && is_array($data['cat_arr_id'])) {
|
|
|
$data['catid'] = end($data['cat_arr_id']);
|