| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 | 
							- <?php
 
- namespace Content\Lib;
 
- use Dever;
 
- class Article
 
- {
 
-     # 根据文章id 获取文章信息
 
-     public function get($data)
 
-     {
 
-         if (!is_array($data)) {
 
-             $data = Dever::db('content/article')->getOne($data);
 
-         }
 
-         
 
-         if (!$data) {
 
-             Dever::alert('错误的文章信息');
 
-         }
 
-     
 
-         $data = $this->getContent($data);
 
-         return $data;
 
-     }
 
-     public function getContent($data)
 
-     {
 
-         //embed
 
-         $data['content_array'] = array();
 
-         $data['content'] = Dever::filter($data['content']);
 
-         $content = $data['content'];
 
-         $replace = array();
 
-         # embed已废弃
 
-         if (strstr($data['content'], 'embed')) {
 
-             # 音频
 
-             preg_match_all('/<embed src="(.*?)"(.*?)\/>/i', $data['content'], $matches);
 
-             if (isset($matches[1])) {
 
-                 foreach ($matches[1] as $k => $v) {
 
-                     $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
 
-                     if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
 
-                         $replace[] = array('type' => 6, 'content' => $v);
 
-                     } else {
 
-                         $replace[] = array('type' => 5, 'content' => $v);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         if (strstr($data['content'], 'data-file')) {
 
-             # 音频
 
-             preg_match_all('/<img src="(.*?)" style="(.*?)" data-file="(.*?)" \/>/', $data['content'], $matches);
 
-             if (!isset($matches[1][0])) {
 
-                 preg_match_all('/<img style="(.*?)" src="(.*?)" data-file="(.*?)" \/>/', $data['content'], $matches);
 
-                 $temp = array();
 
-                 if (isset($matches[2][0])) {
 
-                     $temp = $matches;
 
-                     $matches[1] = $temp[2];
 
-                     unset($temp);
 
-                 }
 
-             }
 
-             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);
 
-             
 
-             
 
-             if (!isset($matches[2][0])) {
 
-                 preg_match_all('/<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>/', $data['content'], $matches);
 
-                 $temp = array();
 
-                 if (isset($matches[2][0]) && isset($matches[3][0])) {
 
-                     $temp = $matches;
 
-                     $matches[2] = $temp[3];
 
-                     $matches[3] = $temp[2];
 
-                     unset($temp);
 
-                 }
 
-             }
 
-             
 
-             if (isset($matches[2][0]) && isset($matches[3][0])) {
 
-                 foreach ($matches[2] as $k => $v) {
 
-                     $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
 
-                     if ($matches[3][$k] == 'video/lib/core.vod') {
 
-                         $method = 'video/lib/vod';
 
-                         $type = 2;
 
-                     } else {
 
-                         $type = 3;
 
-                         $method = 'video/lib/live';
 
-                     }
 
-                     $info = Dever::load($method)->get($v);
 
-                     if (isset($info['content'])) {
 
-                         unset($info['content']);
 
-                     }
 
-                     $replace[] = array('id' => $v, 'type' => $type, 'content' => $info);
 
-                 }
 
-             }
 
-         }
 
-         //$data['content'] = preg_replace('/<div class="dever-drop">([\s\S]*?)<\/div>/i', '', $data['content']);
 
-         $content = explode('{replace}', $content);
 
-         $data['content_array'] = array();
 
-         //print_r($content);die;
 
-         foreach ($content as $k => $v) {
 
-             $v = trim($v);
 
-             if (is_numeric($v) && $v >= 0 && isset($replace[$v])) {
 
-                 $data['content_array'][] = $replace[$v];
 
-             } elseif ($v) {
 
-                 $data['content_array'][] = array
 
-                 (
 
-                     'type' => 1,
 
-                     'content' => $v,
 
-                 );
 
-             }
 
-         }
 
-         if (!$data['content_array']) {
 
-             $data['content_array'][] = array
 
-             (
 
-                 'type' => 1,
 
-                 'content' => $data['content'],
 
-             );
 
-         }
 
-         unset($data['content']);
 
-         return $data;
 
-     }
 
-     # 获取相关推荐
 
-     public function getRelation($info)
 
-     {
 
-         $where['noid'] = $info['id'];
 
-         $where['cate_id'] = $info['cate_id'];
 
-         return Dever::db('content/article')->getRelation($where);
 
-     }
 
-     # 增加浏览量
 
-     public function addView($id)
 
-     {
 
-         Dever::db('content/article')->addView($id);
 
-     }
 
- }
 
 
  |