dever 6 년 전
부모
커밋
ae1c220fa9
2개의 변경된 파일40개의 추가작업 그리고 10개의 파일을 삭제
  1. 12 4
      content/lib/Applet.php
  2. 28 6
      content/lib/Article.php

+ 12 - 4
content/lib/Applet.php

@@ -9,15 +9,23 @@ class Applet
     # 更新数据
     public function update_api()
     {
+        $applet = Dever::db('content/applet')->state();
+
+        $option = '';
+        if ($applet) {
+            foreach ($applet as $k => $v) {
+                $option .= '<option parent="" value="'.$v['appid'].'">'.$v['appid'].'</option>';
+            }
+        }
         $html = '<div class="layui-card-body">';
 
-        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">选择小程序</label></div><div><select lay-ignore="" class="update_value form-control layui-input layui-select   validate[required]" name="applet_id" id="applet_id"><option parent="" value="3">小镇怎么搞</option><option parent="" value="2" selected="">栏目管理</option><option parent="" value="1">默认作者</option></select></div></div></div>';
+        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">选择小程序</label></div><div><select lay-ignore="" class="update_value form-control layui-input layui-select   validate[required]" name="editor_applet_id" id="editor_applet_id">'.$option.'</select></div></div></div>';
 
-        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">路径</label></div><div><input type="text" class="update_value form-control layui-input validate[required]" value="" name="applet_path" id="applet_path" autocomplete="new-password" placeholder=""></div></div></div>';
+        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">路径</label></div><div><input type="text" class="update_value form-control layui-input validate[required]" value="" name="editor_applet_path" id="editor_applet_path" autocomplete="new-password" placeholder=""></div></div></div>';
 
-        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">1:1封面图<span style="font-size:12px;font-weight:normal;font-color:#bababa;margin-left:5px;">[图片尺寸570*570px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式]</span></label></div><div><input type="button" style="width:100px;display:inline;padding-left:0px;" class="form-control layui-input image_upload" v="applet_pic" id="file_applet_pic" key="1" value="本地上传" autocomplete="new-password">
+        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">封面图<span style="font-size:12px;font-weight:normal;font-color:#bababa;margin-left:5px;">[图片宽度750px高度自适应,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式]</span></label></div><div><input type="button" style="width:100px;display:inline;padding-left:0px;" class="form-control layui-input image_upload" v="editor_applet_pic" id="file_applet_pic" key="1" value="本地上传" autocomplete="new-password">
         <div style="margin-top:5px;">
-        <input type="text" class="update_value form-control layui-input " name="update_pic_cover" id="applet_pic" value="" autocomplete="new-password"></div></div></div></div>';
+        <input type="text" class="update_value form-control layui-input " name="editor_applet_pic" id="editor_applet_pic" value="" autocomplete="new-password"></div></div></div></div>';
         $html .= '</div>';
         return $html;
     }

+ 28 - 6
content/lib/Article.php

@@ -35,7 +35,7 @@ class Article
         # embed已废弃
         if (strstr($data['content'], 'embed')) {
             # 音频
-            preg_match_all('/<embed src="(.*?)"(.*?)\/>/i', $data['content'], $matches);
+            preg_match_all('/<embed src="(.*?)"(.*?)\/>/i', $content, $matches);
             if (isset($matches[1])) {
                 foreach ($matches[1] as $k => $v) {
                     $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
@@ -49,12 +49,29 @@ class Article
             }
         }
 
+        if (strstr($data['content'], 'data-applet')) {
+            # 小程序
+            preg_match_all('/<img(.*?)data-applet="(.*?)" \/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $temp = explode('||', $v);
+                    $pic = $temp[0];
+                    $appid = $temp[1];
+                    $path = $temp[2];
+
+                    $replace[] = array('type' => 7, 'pic_cover' => $pic, 'appid' => $appid, 'path' => $path);
+                }
+            }
+        }
+
         if (strstr($data['content'], 'data-file')) {
             # 音频
-            preg_match_all('/<img src="(.*?)" style="(.*?)" data-file="(.*?)" \/>/', $data['content'], $matches);
+            preg_match_all('/<img src="(.*?)" style="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
 
             if (!isset($matches[1][0])) {
-                preg_match_all('/<img style="(.*?)" src="(.*?)" data-file="(.*?)" \/>/', $data['content'], $matches);
+                preg_match_all('/<img style="(.*?)" src="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
                 $temp = array();
                 if (isset($matches[2][0])) {
                     $temp = $matches;
@@ -71,7 +88,12 @@ class Article
                         $file = $matches[3][$k];
                         $temp = explode('||', $file);
                         $file = $temp[0];
-                        $name = $temp[1];
+                        if (isset($temp[1])) {
+                            $name = $temp[1];
+                        } else {
+                            $name = '';
+                        }
+                        
                         $cover = $v;
 
                         if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
@@ -86,11 +108,11 @@ class Article
 
         if (strstr($data['content'], 'data-id')) {
             # 视频+直播
-            preg_match_all('/<img(.*?)data-id="(.*?)" data-key="(.*?)" \/>/', $data['content'], $matches);
+            preg_match_all('/<img(.*?)data-id="(.*?)" data-key="(.*?)" \/>/', $content, $matches);
             
             
             if (!isset($matches[2][0])) {
-                preg_match_all('/<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>/', $data['content'], $matches);
+                preg_match_all('/<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>/', $content, $matches);
                 $temp = array();
                 if (isset($matches[2][0]) && isset($matches[3][0])) {
                     $temp = $matches;