getCate($cate_id); $pdate = Dever::input('pdate'); $source_id = Dever::input('source_id'); $update['template'] = $template; $update['source_id'] = $source_id; $info = Dever::db('article/info')->one($update); //$parse = $this->parseContent($content); //print_r($parse);die; if ($content) { $content = Dever::json_decode($content); $content = $this->getContentHtml($content); } $update['name'] = $name; $update['desc'] = $desc; $update['pic_cover'] = $pic_cover; $update['pic_index'] = $pic_index; $update['content'] = $content; $update['cate_id'] = $cate_id; if (isset($video) && $video) { $update['video'] = $video; } if (!$info) { $update['pdate'] = $pdate; Dever::db('article/info')->insert($update); } else { $update['where_id'] = $info['id']; Dever::db('article/info')->update($update); } return 'ok'; } public function getCate($id) { $config = array ( 1 => 6, 2 => 4, 3 => 1, 4 => 2, 5 => 3, 6 => 6, 7 => 6, 9 => 5, 12 => 6, ); if (isset($config[$id])) { return $config[$id]; } return $id; } public function vod_api() { $data['name'] = '视频'; $where = array(); $name = Dever::input('search_name'); $cate = Dever::input('search_cate'); if ($name) { $where['name'] = $name; } if ($cate > 0) { $where['cate_id'] = $cate; } $where['template'] = 2; $data['file'] = Dever::db('article/info')->list($where); $data['cate'] = Dever::db('article/cate')->state(); if ($data['file']) { foreach ($data['file'] as $k => $v) { $data['file'][$k]['source_name'] = $v['name']; $data['file'][$k]['file'] = $v['pic_cover']; $data['file'][$k]['pic'] = $v['pic_cover']; } } return $data; } public function vod_info($id) { $data = Dever::db('article/info')->one($id); return $data; } # 根据文章id 获取文章信息 public function get($data, $uid = false) { if (!is_array($data)) { $data = Dever::db('article/info')->one($data); } if (!$data) { Dever::alert('错误的文章信息'); } if ($data['author_id']) { $data['author'] = Dever::db('article/author')->one($data['author_id']); } $data = $this->getContent($data, $uid); return $data; } public function getContent($data, $uid = false) { //embed $data['content_array'] = $data['content_pic'] = array(); $data['content'] = Dever::filter($data['content']); $content = $data['content']; $replace = array(); # 过滤宽度 if (strstr($data['content'], 'width:')) { $content = preg_replace('/width:(.*?)px/', 'width:100%', $content); } # 图片 if (strstr($data['content'], '/', $content, $matches); if (isset($matches[2])) { foreach ($matches[2] as $k => $v) { $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content); $pic = $v; $replace[] = array('type' => 'pic', 'content' => $pic); $data['content_pic'][] = $pic; } } } //$data['content'] = preg_replace('/
([\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' => 'html', 'content' => $v, ); } } if (!$data['content_array']) { $data['content_array'][] = array ( 'type' => 'html', 'content' => $data['content'], ); } unset($data['content']); //print_r($data['content_array']);die; return $data; } # 获取相关推荐 public function getRelation($info) { $where['noid'] = $info['id']; $where['cate_id'] = $info['cate_id']; return Dever::db('article/info')->getRelation($where); } # 增加浏览量 public function addView($id) { Dever::db('article/info')->addView($id); } }