dever 6 years ago
parent
commit
d5d98095ea
3 changed files with 29 additions and 3 deletions
  1. 1 1
      content/database/article.php
  2. 27 1
      content/lib/Article.php
  3. 1 1
      doc/apidoc.php

+ 1 - 1
content/database/article.php

@@ -418,7 +418,7 @@ return array
 					),
 					array
 					(
-						'name' => '音频',
+						'name' => '音频',
 						'key' => 5,
 						'type' => 'media',
 					),

+ 27 - 1
content/lib/Article.php

@@ -31,6 +31,8 @@ class Article
 
         $content = $data['content'];
         $replace = array();
+
+        # embed已废弃
         if (strstr($data['content'], 'embed')) {
             # 音频
             preg_match_all('/<embed src="(.*?)"(.*?)\/>/i', $data['content'], $matches);
@@ -47,8 +49,32 @@ class Article
             }
         }
 
+        if (strstr($data['content'], 'data-file')) {
+            # 音频
+            preg_match_all('/<img src="(.*?)" style="(.*?)" data-file="(.*?)" \/>/', $data['content'], $matches);
+            if (isset($matches[1])) {
+                foreach ($matches[1] as $k => $v) {
+                    if (isset($matches[3][$k])) {
+                        $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+
+                        $file = $matches[3][$k];
+                        $temp = explode('||', $file);
+                        $file = $temp[0];
+                        $name = $temp[1];
+                        $cover = $v;
+
+                        if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
+                            $replace[] = array('type' => 6, 'content' => $file, 'cover' => $cover, 'name' => $name);
+                        } else {
+                            $replace[] = array('type' => 5, 'content' => $file, 'cover' => $cover, 'name' => $name);
+                        }
+                    }
+                }
+            }
+        }
+
         if (strstr($data['content'], 'data-id')) {
-            # 视频
+            # 视频+直播
             preg_match_all('/<img(.*?)data-id="(.*?)" data-key="(.*?)" \/>/', $data['content'], $matches);
             
             

+ 1 - 1
doc/apidoc.php

@@ -429,7 +429,7 @@
  * @apiSuccess {String}   info.share_content 分享内容
  * @apiSuccess {String}   info.function 开启的功能,这是一个字符串,用逗号隔开的,1代表显示浏览量,2代表显示评论,3代表显示喜欢,如值为1,2,则显示浏览量、评论,不显示喜欢
  * @apiSuccess {String}   info.content 内容
- * @apiSuccess {String}   info.content_array 数组内容,请使用该字段循环,type为类型,请参考类型设置说明,content为内容,type为1时为图文内容,type为2时content为视频详情的字段,type为3时content为直播详情的字段,type为5时content为音频、type为6时是视频地址,后续增加type=56时的封面图,暂时没有
+ * @apiSuccess {String}   info.content_array 数组内容,请使用该字段循环,type为类型,请参考类型设置说明,content为内容,type为1时为图文内容,type为2时content为视频详情的字段,type为3时content为直播详情的字段,当type为5时content为音频地址,name为标题,cover为封面、type为6时是视频地址,name为标题,cover为封面
  *
  * @apiSuccess {Object[]} comment 评论列表
  * @apiSuccess {String}   comment.id