作者 zhl

Merge remote-tracking branch 'origin/master' into zhl

... ... @@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 439;
$project_id = 450;
ProjectServer::useProject($project_id);
$this->count($project_id);
DB::disconnect('custom_mysql');
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Com\UpdateOldInfo;
use App\Models\HomeCount\MonthCount;
use App\Models\Project\Project;
use App\Models\Visit\Visit;
... ... @@ -35,8 +36,10 @@ class UpgradeProjectCount extends Command
protected $description = '升级项目统计';
public function handle(){
$project_id = 439;
$url = 'www.cnzyl.com';
$project_id = 450;
$oldModel = new UpdateOldInfo();
$info = $oldModel->read(['project_id'=>$project_id]);
$url = $info['old_domain_online'];
ProjectServer::useProject($project_id);
$this->count($project_id,$url);
... ...
... ... @@ -544,21 +544,15 @@ class ProjectUpdate extends Command
$url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]);
$data = curl_c($url);
if (isset($data['code']) && $data['code'] == 200) {
$category = $data['data']['category'] ?? [];
if (empty($category)) {
$route_model = new RouteMap();
$route_page = $route_model->read(['source' => 'page', 'route' => $custom_info['route']], 'id');
if (!$route_page) {
$category = [
[
'id' => 0,
'name' => $custom_info['route'],
'url' => '/' . $custom_info['route'],
'parent' => 0
]
];
}
}
$category = [
[
'id' => 0,
'name' => $custom_info['route'],
'url' => '/' . $custom_info['route'],
'parent' => 0,
'children' => $data['data']['category'] ?? []
]
];
$this->category_custom_insert($project_id, $custom_info['id'], $category, 0);
$count = $data['data']['count'] ?? 0;
... ...
... ... @@ -50,7 +50,7 @@ class UpdateProductCategory extends Command
public function handle(){
//获取所有项目
$projectModel = new Project();
$list = $projectModel->list(['type'=>['in',[1,2,3,4]]],'id',['id']);
$list = $projectModel->list(['id'=>['in',[218]]],'id',['id']);
echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL;
try {
foreach ($list as $v) {
... ... @@ -94,9 +94,8 @@ class UpdateProductCategory extends Command
if(!empty($cate_arr) && is_array($cate_arr)){
foreach ($cate_arr as $v){
$categoryModel = new Category();
$info = $categoryModel->read(['pid'=>$v],['id']);
if($info !== false){
//有下级时,跳过
$info = $categoryModel->read(['id'=>$v],['id']);
if($info === false){
continue;
}else{
//更新关联表
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Console\Commands;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Product\CategoryRelated;
... ... @@ -54,16 +55,16 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>99]);
$list = $projectModel->list(['id'=>426]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
// $this->getProduct();
// $this->setProductKeyword();
$this->setProductKeyword();
// $this->getRouteMap();
// $this->getProductCategory();
// $this->delRouteMap();
$this->setCustomRoute($v['id']);
// $this->setCustomRoute($v['id']);
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ... @@ -100,10 +101,15 @@ class UpdateRoute extends Command
if(!empty($v['route'])){
$tag = "-tag";
if (!(substr($v['route'], -strlen($tag)) === $tag)) {
$route = $v['route'].$tag;
// $route = Translate::tran($v['route'], 'en').$tag;
// 如果不是以 '-tag' 结尾,则拼接上 '-tag'
$route = $v['route'].$tag;
$route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
// }else{
// $route = Translate::tran($v['title'], 'en').$tag;
// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
}
}else{
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
... ...
... ... @@ -9,7 +9,6 @@
namespace App\Http\Controllers\Aside\Com;
use App\Helper\Common;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateOldInfo;
... ... @@ -17,7 +16,6 @@ use App\Models\Domain\DomainInfo;
use App\Models\Project\ProjectUpdateTdk;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
/**
* @remark :b端网站更新相关
... ... @@ -105,12 +103,23 @@ class UpdateController extends BaseController
//关闭数据库
DB::disconnect('custom_mysql');
$update = ['collect_status' => 0];
if ($this->param['type'] == 2 && !$domain_info) {
$update['status'] = 0;
if ($domain_info) {
$old_info = UpdateOldInfo::where('project_id', $this->param['project_id'])->first();
if (!$old_info) {
$old_info = new UpdateOldInfo();
$old_info->project_id = $this->param['project_id'];
$old_info->link_type = 0;
$old_info->old_domain_online = $domain_info->domain;
}
$old_info->old_domain_test = $test_domain;
$old_info->save();
}
UpdateLog::where('project_id', $this->param['project_id'])->whereIn('api_type', ['post', 'page', 'news', 'blog'])->update($update);
UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news', 'website_info', 'tag'])->update(['collect_status' => 0]);
if ($this->param['type'] == 2 && !$domain_info) {
UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news'])->update(['status' => 0]);
}
$this->response('采集任务添加成功');
}
... ...
... ... @@ -70,7 +70,7 @@ class AyrReleaseController extends BaseController
//参数处理
$this->param['mediaUrls'] = $ayrReleaseLogic->image_file_param($data);
//时间处理
$datetime = new \DateTime($this->param['schedule_date']);
$datetime = new \DateTime($this->param['schedule_date'] ?? date('Y-m-d H:i:s'));
$formattedTime = $datetime->format("Y-m-d\TH:i:s\Z");
//统一生成发布
$param = [
... ...
... ... @@ -275,4 +275,37 @@ class BlogController extends BaseController
$logic->setSort();
$this->response('success');
}
/**
* @remark :批量排序
* @name :allSort
* @author :lyh
* @method :post
* @time :2024/1/11 9:46
*/
public function allSort(BlogLogic $logic){
$logic->setAllSort();
$this->response('success');
}
/**
* @remark :批量设置产品分类及状态
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:51
*/
public function batchSetCategory(BlogLogic $logic){
$this->request->validate([
'id'=>'required',
'category_id'=>'required',
'status'=>'required'
],[
'id.required' => '产品ID不能为空',
'category_id.required' => '分类ID不能为空',
'status.required'=>'状态不能为空'
]);
$logic->batchSetCategory();
$this->response('success');
}
}
... ...
... ... @@ -299,9 +299,4 @@ class LoginController extends BaseController
}
return $data;
}
public function ceshi(){
$ceshi = Translate::tran('Полностью Сварной Пластинчатый Теплообменник', 'en');
return $ceshi;
}
}
... ...
... ... @@ -267,4 +267,38 @@ class NewsController extends BaseController
$newsLogic->setSort();
$this->response('success');
}
/**
* @remark :批量排序
* @name :allSort
* @author :lyh
* @method :post
* @time :2024/1/11 9:47
*/
public function allSort(NewsLogic $newsLogic){
$newsLogic->setAllSort();
$this->response('success');
}
/**
* @remark :批量设置产品分类及状态
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:51
*/
public function batchSetCategory(NewsLogic $logic){
$this->request->validate([
'id'=>'required',
'category_id'=>'required',
'status'=>'required'
],[
'id.required' => '产品ID不能为空',
'category_id.required' => '分类ID不能为空',
'status.required'=>'状态不能为空'
]);
$logic->batchSetCategory();
$this->response('success');
}
}
... ...
... ... @@ -238,7 +238,11 @@ class ProductController extends BaseController
}
$v['keyword_id_text'] = trim($v['keyword_id_text'],',');
}
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
if(!empty($v['status'])){
$v['status_text'] = Product::statusMap()[$v['status']] ?? '';
}else{
$v['status_text'] = '';
}
//获取当前用户选择的模版
$v['video'] = json_decode($v['video'] ?? '');
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
... ...
<?php
/**
* @remark :
* @name :TranslateController.php
* @author :lyh
* @method :post
* @time :2024/1/12 9:39
*/
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Setting\TranslateLogic;
use App\Models\WebSetting\WebLanguage;
class TranslateController extends BaseController
{
/**
* @remark :获取翻译校队列表
* @name :lists
* @author :lyh
* @method :post
* @time :2024/1/12 9:39
*/
public function lists(TranslateLogic $logic){
$this->request->validate([
'type'=>'required',
'language_id'=>'required',
'url'=>'required',
],[
'type.required' => 'type不能为空',
'language_id.required' => 'language_id不能为空',
'url.required' => 'url不能为空',
]);
$data = $logic->getTranslateList();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :图片列表
* @name :imageList
* @author :lyh
* @method :post
* @time :2024/1/12 11:18
*/
public function imageList(TranslateLogic $logic){
$this->request->validate([
'type'=>'required',
'language_id'=>'required',
'url'=>'required',
],[
'type.required' => 'type不能为空',
'language_id.required' => 'language_id不能为空',
'url.required' => 'url不能为空',
]);
$data = $logic->getTranslateImageList();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存数据
* @name :save
* @author :lyh
* @method :post
* @time :2024/1/12 11:19
*/
public function save(TranslateLogic $logic){
$this->request->validate([
'type'=>'required',
'language_id'=>'required',
'url'=>'required',
'alias'=>'required',
],[
'type.required' => 'type不能为空',
'language_id.required' => 'language_id不能为空',
'url.required' => 'url不能为空',
'alias.required' => 'url不能为空',
]);
$logic->translateSave();
$this->response('success');
}
}
... ...
... ... @@ -38,7 +38,7 @@ class InitHtmlController extends BaseController
'type.required' => '类型不能为空',
]);
$html = $logic->getDetailHtml();
$this->response('success',Code::SUCCESS,['html'=>$html]);
$this->response('success',Code::SUCCESS,$html);
}
/**
... ...
... ... @@ -116,7 +116,7 @@ class CustomModuleLogic extends BaseLogic
public function checkIsName($name,$id = 0){
$param['name'] = $name;
if(!empty($id)){
$param['id'] = ['id'=>['!=',$id],];
$param['id'] = ['id'=>['!=',$id]];
}
$info = (new CustomModule())->read($param);
if($info !== false){
... ...
... ... @@ -60,6 +60,12 @@ class CreateKeywordLogic extends BaseLogic
if($info !== false){
$this->fail('当前名称已存在');
}
}else{
$data['id'] = ['!=',$param['id']];
$info = $this->model->read($data);
if($info !== false){
$this->fail('当前名称已存在');
}
}
return $this->success($data);
}
... ...
... ... @@ -149,7 +149,7 @@ class BTemplateLogic extends BaseLogic
return false;
}
//TODO::默认模块定制
$html = $this->isCustomizedPage($source,$is_list);//获取定制页面的html
$html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html
if(!empty($html)){
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
... ... @@ -361,7 +361,7 @@ class BTemplateLogic extends BaseLogic
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>$is_custom,
'is_custom'=>0,
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
... ...
... ... @@ -38,6 +38,7 @@ class InitHtmlLogic extends BaseLogic
$template_id = $this->getTemplateId();
$is_custom = $this->param['is_custom'] ?? 0;//TODO::1:代表扩展模块
$is_list = $this->param['is_list'] ?? 0;//TODO::1:代表分类列表模块
$data = array();
//获取设置的默认中间部分
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_list'=>$is_list,'is_custom'=>$is_custom]);
... ... @@ -47,11 +48,14 @@ class InitHtmlLogic extends BaseLogic
}else{
$main_html = $mainInfo['main_html'];
$main_style = $mainInfo['main_css'];
$data['id'] = $mainInfo['id'];
$data['updated_at'] = $mainInfo['updated_at'];
}
$commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);//组装数据
return $this->success($html);
$data['html'] = $html;
return $this->success($data);
}
/**
... ... @@ -259,14 +263,20 @@ class InitHtmlLogic extends BaseLogic
*/
public function getCustomizedHtml(){
$is_list = $this->param['is_list'] ?? 0;
$is_custom = $this->param['is_custom'] ?? 0;
$bTemplateMainModel = new BTemplateMain();
$info = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]);
$info = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($info === false){
$html = '';
}else{
$type = $this->getCustomizedType($this->param['type'],$is_list);
//扩展模块获取头部
if($is_custom == BTemplate::IS_CUSTOM){
$type = $this->param['type'];
}else{
$type = $this->getCustomizedType($this->param['type'],$is_list);
}
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type]);
$commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($commonInfo !== false){
$info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);
}
... ... @@ -303,21 +313,23 @@ class InitHtmlLogic extends BaseLogic
public function saveCustomizedHtml(){
try {
$is_list = $this->param['is_list'] ?? 0;
$is_custom = $this->param['is_custom'] ?? 0;
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_list'=>$is_list]);
$mainInfo = $bTemplateMainModel->read(['type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($mainInfo === false){
$mainData = [
'project_id'=>$this->user['project_id'],
'type'=>$this->param['type'],
'is_list'=>$is_list,
'main_html'=>$this->param['html']
'main_html'=>$this->param['html'],
'is_custom'=>$is_custom
];
$bTemplateMainModel->add($mainData);
}else{
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
}
//更新头部底部
$this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list);
$this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list,$is_custom);
}catch (\Exception $exception){
$this->fail('保存失败,请联系开发人员');
}
... ... @@ -331,16 +343,21 @@ class InitHtmlLogic extends BaseLogic
* @method :post
* @time :2024/1/6 10:29
*/
public function saveCustomizeCommon($html,$source,$is_list){
$type = $this->getCustomizedType($source,$is_list);
public function saveCustomizeCommon($html,$source,$is_list,$is_custom){
if($is_custom == BTemplate::IS_CUSTOM){
$type = $source;
}else{
$type = $this->getCustomizedType($source,$is_list);
}
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type]);//查看当前头部是否存在
$commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],
'is_custom'=>$is_custom,'is_list'=>$is_list
];
$templateCommonModel->add($data);
}else{
... ...
... ... @@ -234,6 +234,20 @@ class BlogLogic extends BaseLogic
}
/**
* @remark :
* @name :setAllSort
* @author :lyh
* @method :post
* @time :2024/1/10 15:40
*/
public function setAllSort(){
foreach ($this->param['data'] as $k => $v){
$this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
}
return $this->success();
}
/**
* 博客导入
* @param $project_id
* @param $user_id
... ... @@ -348,4 +362,32 @@ class BlogLogic extends BaseLogic
return false;
}
/**
* @remark :批量设置产品分类及状态
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:53
*/
public function batchSetCategory(){
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
DB::connection('custom_mysql')->beginTransaction();
$this->param['category_id'] = ','.implode(',',$this->param['category_id']).',';
try {
//批量
$param = [
'category_id'=>$this->param['category_id'],
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
DB::connection('custom_mysql')->commit();
//对应添加关联表
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
}
return $this->success();
}
}
... ...
... ... @@ -250,6 +250,21 @@ class NewsLogic extends BaseLogic
}
/**
* @remark :
* @name :setAllSort
* @author :lyh
* @method :post
* @time :2024/1/10 15:40
*/
public function setAllSort(){
foreach ($this->param['data'] as $k => $v){
$this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
}
return $this->success();
}
/**
* @remark :删除路由
* @name :delRoute
* @author :lyh
... ... @@ -381,4 +396,32 @@ class NewsLogic extends BaseLogic
return false;
}
/**
* @remark :批量设置产品分类及状态
* @name :batchSetCategory
* @author :lyh
* @method :post
* @time :2023/8/15 17:53
*/
public function batchSetCategory(){
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
DB::connection('custom_mysql')->beginTransaction();
$this->param['category_id'] = ','.implode(',',$this->param['category_id']).',';
try {
//批量
$param = [
'category_id'=>$this->param['category_id'],
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
DB::connection('custom_mysql')->commit();
//对应添加关联表
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
}
return $this->success();
}
}
... ...
... ... @@ -82,19 +82,19 @@ class RankDataLogic extends BaseLogic
$lang_data = $quanqiusou_api->getLangRankData($api_no);
$lang_data = Arr::setValueToKey($lang_data, 'language');
$data['langs'] = [];
foreach($project['deploy_optimize']['minor_languages']??[] as $lang){
$remain_day = $lang_data[$lang['tl']]['dabiao_day'] ?? 0;
$data['langs'][$lang['tl'] ?? ''] = [
'lang_text' => Translate::getTls($lang['tl'] ?? ''),
'keyword_num' => $lang['keywords'] ?? 0,
'reach_day' => $lang_data[$lang['tl']]['dabiao_day'] ?? 0,
'home_cnt' => $lang_data[$lang['tl']]['home_cnt'] ?? 0,
'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day,
'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
];
if(isset($project['deploy_optimize']['minor_languages']) && !empty($project['deploy_optimize']['minor_languages']) && is_array($project['deploy_optimize']['minor_languages'])){
foreach($project['deploy_optimize']['minor_languages']??[] as $lang){
$remain_day = $lang_data[$lang['tl']]['dabiao_day'] ?? 0;
$data['langs'][$lang['tl'] ?? ''] = [
'lang_text' => Translate::getTls($lang['tl'] ?? ''),
'keyword_num' => $lang['keywords'] ?? 0,
'reach_day' => $lang_data[$lang['tl']]['dabiao_day'] ?? 0,
'home_cnt' => $lang_data[$lang['tl']]['home_cnt'] ?? 0,
'remain_day' => ($lang['type']??0) == 1 ? $data['project']['remain_day'] : $lang['service_day'] - $remain_day,
'type' => $lang['type'] ?? 0, //1 项目关键词 项目天数 2 保证首页关键词 项目达标天数
];
}
}
//测速
$data['speed'] = $speed['data'] ?? [];
... ...
<?php
/**
* @remark :
* @name :TranslateLogic.php
* @author :lyh
* @method :post
* @time :2024/1/12 9:42
*/
namespace App\Http\Logic\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\Proofreading;
use App\Models\WebSetting\Translate as TranslateModel;
use App\Models\WebSetting\WebLanguage;
use App\Helper\Translate;
use Illuminate\Support\Facades\DB;
class TranslateLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new TranslateModel();
$this->param = $this->requestAll;
}
/**
* @remark :
* @name :getTranslateList
* @author :lyh
* @method :post
* @time :2024/1/12 9:43
*/
public function getTranslateList(){
$languageInfo = $this->getLanguage($this->param['language_id']);
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
//获取当前URl的所有文本内容
$new_key = $this->getUrlRead($this->param['url']);
if($info === false){
$data = [];
$translate_list = Translate::tran($new_key, $languageInfo['short']);
foreach ($new_key as $k=>$v){
$data[] = [
trim($v)=>$translate_list[$k],
];
}
return $this->response('success',Code::SUCCESS,$data);
}
$old_key = [];//key值组成数据
$data = json_decode($info['data'],true);
foreach ($data as $k => $v){
$old_key[] = $k;
}
$arr2 = array_values(array_diff($new_key, $old_key));
if(!empty($arr2)){
$translate_list = Translate::tran($arr2, $languageInfo['short']);
foreach ($arr2 as $k1=>$v1){
$data[] = [
trim($v1)=>$translate_list[$k1]
];
}
}
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取图片列表
* @name :imageList
* @author :lyh
* @method :post
* @time :2023/11/23 17:29
*/
public function getTranslateImageList(){
$info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
$data = [];
if($info === false){
$new_list = $this->getUrlImageRead($this->param['url']);
foreach ($new_list as $v){
$data[] = [
$v=>$v,
];
}
return $this->response('success',Code::SUCCESS,$data);
}
$new_list = $this->getUrlImageRead($this->param['url']);
$old_list = [];
$data = json_decode($info['data'],true);
foreach ($data as $k=>$v){
$old_list[] = $v;
$data[] = [
$k=>$v,
];
}
$arr2 = array_values(array_diff($new_list, $old_list));
if(!empty($arr2)){
foreach ($arr2 as $v1){
$data[] = [
$v1=>$v1
];
}
}
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取语种信息
* @name :getLanguage
* @author :lyh
* @method :post
* @time :2024/1/12 9:45
*/
public function getLanguage($language_id){
//获取语种信息
$languageModel = new WebLanguage();
$languageInfo = $languageModel->read(['id'=>$language_id]);
if($languageInfo === false){
$this->fail('请选择语种');
}
return $this->success($languageInfo);
}
/**
* @remark :获取Url内容
* @name :getUrlRead
* @author :lyh
* @method :post
* @time :2023/11/22 10:02
*/
public function getUrlRead($url){
$contextOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
];
$context = stream_context_create($contextOptions);
$sourceCode = file_get_contents($url, false, $context);
$pattern = '/<style\b[^>]*>(.*?)<\/style>/s'; // 定义匹配`<style>`标签及其内容的正则表达式
$strippedContent = preg_replace($pattern, '', $sourceCode); // 删除`<style>`标签及其内容
$pattern = '/<script\b[^>]*>(.*?)<\/script>/s'; // 定义匹配`<script>`标签及其内容的正则表达式
$strippedContent = preg_replace($pattern, '', $strippedContent); // 删除`<script>`标签及其内容
$pattern = '/<link\b[^>]*>/'; // 定义匹配 `<link>` 标签的正则表达式
$strippedContent = preg_replace($pattern, '', $strippedContent); // 删除 `<link>` 标签
$pattern = '/>([^<]+)</'; // 定义匹配中间内容不是标签的正则表达式
$matches = array();
preg_match_all($pattern, $strippedContent, $matches);
$textContentArray = array_filter($matches[1], function($item) {
return !empty(trim($item));
});
$data = [];
foreach ($textContentArray as $v){
$content = trim($v);
$trimmedString = preg_replace('/\s+/', ' ', $content);
$data[] = $trimmedString;
}
$data = array_values($data);
return $data;
}
/**
* @remark :获取Url内容
* @name :getUrlRead
* @author :lyh
* @method :post
* @time :2023/11/22 10:02
*/
public function getUrlImageRead($url){
$contextOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
];
$pattern = '/<img.*?src="(.*?)".*?>/i';
$matches = array();
$context = stream_context_create($contextOptions);
$sourceCode = file_get_contents($url, false, $context);
preg_match_all($pattern, $sourceCode, $matches);
$textContentArray = $matches[1];
$data = [];
foreach ($textContentArray as $v){
if(!empty($v)){
$data[] = $v;
}
}
$uniqueArray = array_unique($data);
$data = array_values($uniqueArray);
return $data;
}
/**
* @name :(新增/更新多语言)save
* @author :lyh
* @method :post
* @time :2023/6/12 10:52
*/
public function translateSave(){
try {
$info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
if($info === false){
$param = [
'type'=>1,
'project_id'=>$this->user['project_id'],
'url'=>$this->param['url'],
'language_id'=>$this->param['language_id'],
'alias'=>$this->param['alias'],
];
$param['data'] = json_encode($this->param['data'],true);
$this->model->add($param);
}else{
$data = json_encode($this->param['data'],true);
$this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
}
}catch (\Exception $e){
$this->fail('系统错误请联系管理员');
}
$this->response('success');
}
}
... ...
... ... @@ -27,6 +27,7 @@ class AyrReleaseRequest extends FormRequest
'content'=>'required',
'share_id'=>'required',
'platforms'=>'required|array',
'schedule_date'=>'required'
];
}
... ...
... ... @@ -2,9 +2,10 @@
namespace App\Models\Com;
use App\Models\Base;
use Illuminate\Database\Eloquent\Model;
class UpdateOldInfo extends Model
class UpdateOldInfo extends Base
{
//设置关联表名
protected $table = 'gl_update_old_info';
... ...
<?php
/**
* @remark :
* @name :Translate.php
* @author :lyh
* @method :post
* @time :2024/1/12 9:38
*/
namespace App\Models\WebSetting;
use App\Models\Base;
class Translate extends Base
{
protected $table = 'gl_translate';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
... ... @@ -74,6 +74,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/del', [\App\Http\Controllers\Bside\News\NewsController::class, 'del'])->name('news_del');
Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_status');
Route::any('/sort', [\App\Http\Controllers\Bside\News\NewsController::class, 'sort'])->name('news_sort');
Route::any('/allSort', [\App\Http\Controllers\Bside\News\NewsController::class, 'allSort'])->name('news_allSort');
Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\News\NewsController::class, 'batchSetCategory'])->name('news_batchSetCategory');
Route::any('/statusNum', [\App\Http\Controllers\Bside\News\NewsController::class, 'getStatusNumber'])->name('news_statusNum');
});
... ... @@ -89,6 +91,8 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/del', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'del'])->name('blog_del');
Route::any('/status', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'status'])->name('blog_status');
Route::any('/sort', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'sort'])->name('blog_sort');
Route::any('/allSort', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'allSort'])->name('blog_allSort');
Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'batchSetCategory'])->name('blog_batchSetCategory');
Route::any('/statusNum', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'getStatusNumber'])->name('blog_statusNum');
//分类
Route::any('/category/', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'lists'])->name('blog_category_lists');
... ... @@ -172,7 +176,12 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/save', [\App\Http\Controllers\Bside\Setting\ProofreadingController::class, 'save'])->name('web_proofreading_save');
Route::any('/saveImage', [\App\Http\Controllers\Bside\Setting\ProofreadingController::class, 'saveImage'])->name('web_proofreading_saveImage');
});
//新版翻译校队
Route::prefix('translate_check')->group(function () {//languageList
Route::any('/', [\App\Http\Controllers\Bside\Setting\TranslateController::class, 'lists'])->name('translate_check_lists');
Route::any('/imageList', [\App\Http\Controllers\Bside\Setting\TranslateController::class, 'imageList'])->name('translate_checkg_imageList');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\TranslateController::class, 'save'])->name('translate_check_save');
});
//seo设置
Route::prefix('seo')->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\Setting\WebSettingSeoController::class, 'info'])->name('web_seo_info');
... ...