getCate($cate_id); $pdate = Dever::input('pdate'); $source_id = Dever::input('source_id'); $update['template'] = $template; $update['source_id'] = $source_id; $info = Dever::db('content/article')->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('content/article')->insert($update); } else { $update['where_id'] = $info['id']; Dever::db('content/article')->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('content/article')->list($where); $data['cate'] = Dever::db('content/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 getDataByNum() { $data = Dever::db('content/article')->getDataByNum(); return $data; } # 获取最新列表 public function getList() { $data = Dever::db('content/article')->getList(); if ($data) { foreach ($data as $k => $v) { $cate = Dever::db('content/cate')->one($v['cate_id']); $data[$k]['cate_name'] = $cate['name']; $data[$k]['link'] = Dever::load('content/lib/common')->getInfoLink(1, $v['id']); $data[$k]['cdate'] = date('Y-m-d', $v['pdate']); } } return $data; } # 获取最新列表 public function getAll() { $where = array(); $cate_id = Dever::input('cid'); if ($cate_id > 0) { $where['cate_id'] = $cate_id; } $data = Dever::db('content/article')->getAll($where); if ($data) { foreach ($data as $k => $v) { $cate = Dever::db('content/cate')->one($v['cate_id']); $data[$k]['cate_name'] = $cate['name']; $data[$k]['link'] = Dever::load('content/lib/common')->getInfoLink(1, $v['id']); $data[$k]['cdate'] = date('Y-m-d', $v['pdate']); } } return $data; } # 获取文章信息 public function getInfo() { $id = Dever::input('id'); $data = Dever::db('content/article')->getOne($id); if (!$data) { Dever::alert('错误的文章信息'); } if ($data['author_id']) { $data['author'] = Dever::db('content/author')->one($data['author_id']); } $data['cdate'] = date('Y-m-d', $data['pdate']); $data['tag_html'] = ''; if ($data['tag']) { $tag_data = Dever::load('tag/api')->tag_content($data['author_id']); if ($tag_data) { $data['tag_html'] = '标签:'; foreach ($tag_data as $k => $v) { $link = Dever::url('search_list?tid=' . $v['id']); $data['tag_html'] .= ''.$v['name'].''; } } } # 获取上一篇和下一篇 $where['id'] = $id; $where['cate_id'] = $data['cate_id']; $data['prev'] = Dever::db('content/article')->findPrev($where); if ($data['prev']) { $data['prev']['link'] = Dever::load('content/lib/common')->getInfoLink(1, $data['prev']['id']); } $data['next'] = Dever::db('content/article')->findNext($where); if ($data['next']) { $data['next']['link'] = Dever::load('content/lib/common')->getInfoLink(1, $data['next']['id']); } //print_r($data);die; $this->addView($id); return $data; } # 获取相关推荐 public function getRelation() { $where['noid'] = Dever::input('id'); $data = Dever::db('content/article')->getOne($where['noid']); $where['cate_id'] = $data['cate_id']; $data = Dever::db('content/article')->getRelation($where); if ($data) { foreach ($data as $k => $v) { $data[$k]['link'] = Dever::load('content/lib/common')->getInfoLink(1, $v['id']); $data[$k]['cdate'] = date('Y-m-d', $v['pdate']); } } return $data; } # 增加浏览量 public function addView($id) { Dever::db('content/article')->addView(array('where_id' => $id, 'set_num_view' => 1)); } # 获取精彩推荐 public function getTop($cate_id = false) { $where = array(); if ($cate_id) { $where['cate_id'] = $cate_id; } $data = Dever::db('content/article')->getTop($where); if ($data) { foreach ($data as $k => $v) { $cate = Dever::db('content/cate')->one($v['cate_id']); $data[$k]['cate_name'] = $cate['name']; $data[$k]['link'] = Dever::load('content/lib/common')->getInfoLink(1, $v['id']); $data[$k]['cdate'] = date('Y-m-d', $v['pdate']); } } return $data; } }