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'] .= ''.$v['name'].'';
}
}
}
$data['pic'] = explode(',', $data['pic']);
$data['pic_html'] = '';
if ($data['pic']) {
foreach ($data['pic'] as $k => $v) {
$data['pic_html'] .= '
';
}
}
$data['pic_num'] = count($data['pic']);
# 获取上一篇和下一篇
$where['id'] = $id;
$where['cate_id'] = $data['cate_id'];
$data['prev'] = Dever::db('content/album')->findPrev($where);
if ($data['prev']) {
$data['prev']['link'] = Dever::load('content/lib/common')->getInfoLink(2, $data['prev']['id']);
$data['prev']['cdate'] = date('Y年m月d日创建', $data['prev']['pdate']);
}
$data['next'] = Dever::db('content/album')->findNext($where);
if ($data['next']) {
$data['next']['link'] = Dever::load('content/lib/common')->getInfoLink(2, $data['next']['id']);
$data['next']['cdate'] = date('Y年m月d日创建', $data['next']['pdate']);
}
//print_r($data);die;
$data['up_url'] = Dever::url('content/lib/album.addUp?id=' . $data['id']);
$this->addView($id);
return $data;
}
# 获取最新列表
public function getList()
{
$data = Dever::db('content/album')->getList();
if ($data) {
foreach ($data as $k => $v) {
$data[$k]['link'] = Dever::load('content/lib/common')->getInfoLink(2, $v['id']);
$data[$k]['pic_num'] = count(explode(',', $v['pic']));
}
}
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/album')->getAll($where);
if ($data) {
foreach ($data as $k => $v) {
$data[$k]['link'] = Dever::load('content/lib/common')->getInfoLink(2, $v['id']);
$data[$k]['cdate'] = date('Y-m-d', $v['pdate']);
$data[$k]['pic_num'] = count(explode(',', $v['pic']));
}
}
return $data;
}
# 获取相关推荐
public function getRelation($info)
{
$where['noid'] = $info['id'];
$where['cate_id'] = $info['cate_id'];
return Dever::db('content/album')->getRelation($where);
}
# 增加浏览量
public function addView($id)
{
Dever::db('content/album')->addView(array('where_id' => $id, 'set_num_view' => 1));
}
# 点赞
public function addUp_api()
{
$id = Dever::input('id');
Dever::db('content/album')->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/album')->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(2, $v['id']);
$data[$k]['cdate'] = date('Y-m-d', $v['pdate']);
}
}
return $data;
}
}