123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace Content\Lib;
- use Dever;
- class Video
- {
- # 获取文章信息
- public function getInfo()
- {
- $id = Dever::input('id');
- $data = Dever::db('content/video')->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'], 'main');
- $data['tag_html'] .= '<a href="'.$link.'" target="_blank">'.$v['name'].'</a>';
- }
- }
- }
- # 获取上一篇和下一篇
- $where['id'] = $id;
- $where['cate_id'] = $data['cate_id'];
- $data['prev'] = Dever::db('content/video')->findPrev($where);
- if ($data['prev']) {
- $data['prev']['link'] = Dever::load('content/lib/common')->getInfoLink(3, $data['prev']['id']);
- $data['prev']['cdate'] = date('Y年m月d日', $data['prev']['pdate']);
- }
- $data['next'] = Dever::db('content/video')->findNext($where);
- if ($data['next']) {
- $data['next']['link'] = Dever::load('content/lib/common')->getInfoLink(3, $data['next']['id']);
- $data['next']['cdate'] = date('Y年m月d日', $data['next']['pdate']);
- }
- //print_r($data);die;
- $data['up_url'] = Dever::url('content/lib/video.addUp?id=' . $data['id']);
- $this->addView($id);
- 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/video')->getAll($where);
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['link'] = Dever::load('content/lib/common')->getInfoLink(3, $v['id']);
- $data[$k]['cdate'] = date('Y-m-d', $v['pdate']);
- }
- }
- return $data;
- }
- # 获取相关推荐
- public function getRelation($info)
- {
- $where['noid'] = Dever::input('id');
- $data = Dever::db('content/video')->getOne($where['noid']);
- $where['cate_id'] = $data['cate_id'];
- $data = Dever::db('content/video')->getRelation($where);
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['link'] = Dever::load('content/lib/common')->getInfoLink(3, $v['id']);
- }
- }
- return $data;
- }
- # 增加浏览量
- public function addView($id)
- {
- Dever::db('content/video')->addView(array('where_id' => $id, 'set_num_view' => 1));
- }
- # 点赞
- public function addUp_api()
- {
- $id = Dever::input('id');
- Dever::db('content/video')->addUp(array('where_id' => $id, 'set_num_up' => 1));
- }
- # 获取精彩推荐
- public function getTop($cate_id = false)
- {
- $where = array();
- if ($cate_id) {
- $where['cate_id'] = $cate_id;
- }
-
- $data = Dever::db('content/video')->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(3, $v['id']);
- $data[$k]['cdate'] = date('Y-m-d', $v['pdate']);
- }
- }
- return $data;
- }
- }
|