|
@@ -5,6 +5,7 @@ namespace app\admin\controller;
|
|
|
use app\data\model\DataXw;
|
|
|
use app\data\model\DataXwAd;
|
|
|
use app\data\model\DataXwCategory;
|
|
|
+use app\data\controller\api\auth\Center;
|
|
|
use think\admin\Controller;
|
|
|
/**
|
|
|
* 新闻报道
|
|
@@ -206,7 +207,17 @@ class Xw extends Controller
|
|
|
if ($this->request->isGet()) {
|
|
|
|
|
|
}elseif ($this->request->isPost()){
|
|
|
- $vo['user_id'] = null;
|
|
|
+ $vo['content'] = $this->textcl($vo['content']);
|
|
|
+// $vo['user_id'] = null;
|
|
|
+// var_dump($vo);die;
|
|
|
+ if($this->request->action() == 'edit' || $this->request->action() == 'add'){
|
|
|
+ isset($vo['id']) ? DataXw::mk()->where('id',$vo['id'])->update($vo) : DataXw::mk()->insert($vo);
|
|
|
+ $this->success('数据更新成功',in_array($this->request->action(),['add','edit','ad_add','ad_edit'])? 'javascript:history.back()':'');
|
|
|
+ }else if(($this->request->action() == 'ad_add' || $this->request->action() == 'ad_edit')){
|
|
|
+ isset($vo['id']) ? DataXwAd::mk()->where('id',$vo['id'])->update($vo) : DataXwAd::mk()->insert($vo);
|
|
|
+ $this->success('数据更新成功',in_array($this->request->action(),['add','edit','ad_add','ad_edit'])? 'javascript:history.back()':'');
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -214,7 +225,7 @@ class Xw extends Controller
|
|
|
* 表单结果处理
|
|
|
* @param boolean $state
|
|
|
*/
|
|
|
- protected function _form_result(bool $state)
|
|
|
+ protected function _form_result(bool $state,array $data)
|
|
|
{
|
|
|
if ($state) {
|
|
|
$this->success('保存成功1!',in_array($this->request->action(),['add','edit','ad_add','ad_edit'])? 'javascript:history.back()':'');
|
|
@@ -222,6 +233,68 @@ class Xw extends Controller
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //视频加封面(阿里云文件)
|
|
|
+ public function textcl($string = ''){
|
|
|
+
|
|
|
+// $string = '<div>
|
|
|
+// <video controls="controls" width="100%"><source src="https://shipcccn.oss-cn-shanghai.aliyuncs.com/dd/天文学家系列.mp4" type="audio/mp4" /></video>
|
|
|
+// </div>
|
|
|
+//
|
|
|
+// <p>11111</p>
|
|
|
+//
|
|
|
+// <div>
|
|
|
+// <video controls="controls" width="100%"><source src="https://shipcccn.oss-cn-shanghai.aliyuncs.com/dd/96326ec38bb7761ef74b7623e94e886c.mp4" type="audio/mp4" /></video>
|
|
|
+// </div>
|
|
|
+//
|
|
|
+// <p>111216546485465468</p>'; // 原始字符串
|
|
|
+
|
|
|
+ $position = strpos($string, '<video '); // 获取'video'在字符串中的位置
|
|
|
+
|
|
|
+ if ($position !== false) {
|
|
|
+ preg_match_all('/<video[^>]*>(.*?)<\/video>/s', $string, $matches);
|
|
|
+
|
|
|
+ if (isset($matches[1])) {
|
|
|
+// echo "视频标签内容为:" . htmlspecialchars($matches[0][1]);die;
|
|
|
+ } else {
|
|
|
+ return $string;
|
|
|
+// echo "未找到视频标签";
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($matches[0] as $k => $v){
|
|
|
+//获取src部分 拼凑封面地址
|
|
|
+ $pattern_src = '/\bsrc\b\s*=\s*[\'\"]?([^\'\"]*)[\'\"]?/i';
|
|
|
+ preg_match_all($pattern_src,$matches[0][$k],$matchSrc);
|
|
|
+ $url = $matchSrc[1][0];
|
|
|
+ $url = $url.'?x-oss-process=video/snapshot,t_10000,m_fast';
|
|
|
+ $replacement_d = '<video controls="controls" poster="'.$url.'" width="100%">';
|
|
|
+
|
|
|
+ //第一次替换
|
|
|
+ $originalString = $matches[0][$k]; //这是原始字符串
|
|
|
+ $replacement = $replacement_d; //被替换后的内容
|
|
|
+ $searchValue = '<video controls="controls" width="100%">'; //要替换的部分
|
|
|
+
|
|
|
+// 将 $searchValue 替换为 $replacement
|
|
|
+ $newString = str_replace($searchValue, $replacement, $originalString);
|
|
|
+
|
|
|
+
|
|
|
+ //第二次替换
|
|
|
+ $originalString = $string; //这是原始字符串
|
|
|
+ $replacement = $newString; //被替换后的内容
|
|
|
+ $searchValue = $matches[0][$k]; //要替换的部分
|
|
|
+ $newString = str_replace($searchValue, $replacement, $originalString);
|
|
|
+
|
|
|
+ $string = $newString;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //echo $newString;die; // 输出结果为"这是被替换后的内容";
|
|
|
+ return $newString;
|
|
|
+ } else {
|
|
|
+ return $string;
|
|
|
+// echo "未找到'video'关键词";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新闻报道设置
|
|
|
* @auth true
|