|
@@ -11,9 +11,11 @@ namespace App\Http\Logic\Bside\Setting; |
|
@@ -11,9 +11,11 @@ namespace App\Http\Logic\Bside\Setting; |
|
11
|
|
11
|
|
|
12
|
use App\Enums\Common\Code;
|
12
|
use App\Enums\Common\Code;
|
|
13
|
use App\Http\Logic\Bside\BaseLogic;
|
13
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
14
|
+use App\Models\WebSetting\Proofreading;
|
|
14
|
use App\Models\WebSetting\Translate as TranslateModel;
|
15
|
use App\Models\WebSetting\Translate as TranslateModel;
|
|
15
|
use App\Models\WebSetting\WebLanguage;
|
16
|
use App\Models\WebSetting\WebLanguage;
|
|
16
|
use App\Helper\Translate;
|
17
|
use App\Helper\Translate;
|
|
|
|
18
|
+use Illuminate\Support\Facades\DB;
|
|
17
|
|
19
|
|
|
18
|
class TranslateLogic extends BaseLogic
|
20
|
class TranslateLogic extends BaseLogic
|
|
19
|
{
|
21
|
{
|
|
@@ -62,7 +64,44 @@ class TranslateLogic extends BaseLogic |
|
@@ -62,7 +64,44 @@ class TranslateLogic extends BaseLogic |
|
62
|
}
|
64
|
}
|
|
63
|
$this->response('success',Code::SUCCESS,$data);
|
65
|
$this->response('success',Code::SUCCESS,$data);
|
|
64
|
}
|
66
|
}
|
|
65
|
-
|
67
|
+ /**
|
|
|
|
68
|
+ * @remark :获取图片列表
|
|
|
|
69
|
+ * @name :imageList
|
|
|
|
70
|
+ * @author :lyh
|
|
|
|
71
|
+ * @method :post
|
|
|
|
72
|
+ * @time :2023/11/23 17:29
|
|
|
|
73
|
+ */
|
|
|
|
74
|
+ public function getTranslateImageList(){
|
|
|
|
75
|
+ $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]);
|
|
|
|
76
|
+ $data = [];
|
|
|
|
77
|
+ if($info === false){
|
|
|
|
78
|
+ $new_list = $this->getUrlImageRead($this->param['url']);
|
|
|
|
79
|
+ foreach ($new_list as $v){
|
|
|
|
80
|
+ $data[] = [
|
|
|
|
81
|
+ $v=>$v,
|
|
|
|
82
|
+ ];
|
|
|
|
83
|
+ }
|
|
|
|
84
|
+ return $this->response('success',Code::SUCCESS,$data);
|
|
|
|
85
|
+ }
|
|
|
|
86
|
+ $new_list = $this->getUrlImageRead($this->param['url']);
|
|
|
|
87
|
+ $old_list = [];
|
|
|
|
88
|
+ $data = json_decode($info['data'],true);
|
|
|
|
89
|
+ foreach ($data as $k=>$v){
|
|
|
|
90
|
+ $old_list[] = $v;
|
|
|
|
91
|
+ $data[] = [
|
|
|
|
92
|
+ $k=>$v,
|
|
|
|
93
|
+ ];
|
|
|
|
94
|
+ }
|
|
|
|
95
|
+ $arr2 = array_values(array_diff($new_list, $old_list));
|
|
|
|
96
|
+ if(!empty($arr2)){
|
|
|
|
97
|
+ foreach ($arr2 as $v1){
|
|
|
|
98
|
+ $data[] = [
|
|
|
|
99
|
+ $v1=>$v1
|
|
|
|
100
|
+ ];
|
|
|
|
101
|
+ }
|
|
|
|
102
|
+ }
|
|
|
|
103
|
+ $this->response('success',Code::SUCCESS,$data);
|
|
|
|
104
|
+ }
|
|
66
|
/**
|
105
|
/**
|
|
67
|
* @remark :获取语种信息
|
106
|
* @remark :获取语种信息
|
|
68
|
* @name :getLanguage
|
107
|
* @name :getLanguage
|
|
@@ -117,4 +156,64 @@ class TranslateLogic extends BaseLogic |
|
@@ -117,4 +156,64 @@ class TranslateLogic extends BaseLogic |
|
117
|
$data = array_values($data);
|
156
|
$data = array_values($data);
|
|
118
|
return $data;
|
157
|
return $data;
|
|
119
|
}
|
158
|
}
|
|
|
|
159
|
+
|
|
|
|
160
|
+ /**
|
|
|
|
161
|
+ * @remark :获取Url内容
|
|
|
|
162
|
+ * @name :getUrlRead
|
|
|
|
163
|
+ * @author :lyh
|
|
|
|
164
|
+ * @method :post
|
|
|
|
165
|
+ * @time :2023/11/22 10:02
|
|
|
|
166
|
+ */
|
|
|
|
167
|
+ public function getUrlImageRead($url){
|
|
|
|
168
|
+ $contextOptions = [
|
|
|
|
169
|
+ 'ssl' => [
|
|
|
|
170
|
+ 'verify_peer' => false,
|
|
|
|
171
|
+ 'verify_peer_name' => false,
|
|
|
|
172
|
+ ],
|
|
|
|
173
|
+ ];
|
|
|
|
174
|
+ $pattern = '/<img.*?src="(.*?)".*?>/i';
|
|
|
|
175
|
+ $matches = array();
|
|
|
|
176
|
+ $context = stream_context_create($contextOptions);
|
|
|
|
177
|
+ $sourceCode = file_get_contents($url, false, $context);
|
|
|
|
178
|
+ preg_match_all($pattern, $sourceCode, $matches);
|
|
|
|
179
|
+ $textContentArray = $matches[1];
|
|
|
|
180
|
+ $data = [];
|
|
|
|
181
|
+ foreach ($textContentArray as $v){
|
|
|
|
182
|
+ if(!empty($v)){
|
|
|
|
183
|
+ $data[] = $v;
|
|
|
|
184
|
+ }
|
|
|
|
185
|
+ }
|
|
|
|
186
|
+ $uniqueArray = array_unique($data);
|
|
|
|
187
|
+ $data = array_values($uniqueArray);
|
|
|
|
188
|
+ return $data;
|
|
|
|
189
|
+ }
|
|
|
|
190
|
+
|
|
|
|
191
|
+ /**
|
|
|
|
192
|
+ * @name :(新增/更新多语言)save
|
|
|
|
193
|
+ * @author :lyh
|
|
|
|
194
|
+ * @method :post
|
|
|
|
195
|
+ * @time :2023/6/12 10:52
|
|
|
|
196
|
+ */
|
|
|
|
197
|
+ public function translateSave(){
|
|
|
|
198
|
+ try {
|
|
|
|
199
|
+ $info = $this->model->read(['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
|
|
|
|
200
|
+ if($info === false){
|
|
|
|
201
|
+ $param = [
|
|
|
|
202
|
+ 'type'=>1,
|
|
|
|
203
|
+ 'project_id'=>$this->user['project_id'],
|
|
|
|
204
|
+ 'url'=>$this->param['url'],
|
|
|
|
205
|
+ 'language_id'=>$this->param['language_id'],
|
|
|
|
206
|
+ 'alias'=>$this->param['alias'],
|
|
|
|
207
|
+ ];
|
|
|
|
208
|
+ $param['data'] = json_encode($this->param['data'],true);
|
|
|
|
209
|
+ $this->model->add($param);
|
|
|
|
210
|
+ }else{
|
|
|
|
211
|
+ $data = json_encode($this->param['data'],true);
|
|
|
|
212
|
+ $this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]);
|
|
|
|
213
|
+ }
|
|
|
|
214
|
+ }catch (\Exception $e){
|
|
|
|
215
|
+ $this->fail('系统错误请联系管理员');
|
|
|
|
216
|
+ }
|
|
|
|
217
|
+ $this->response('success');
|
|
|
|
218
|
+ }
|
|
120
|
} |
219
|
} |