|
@@ -3,9 +3,9 @@ use Dever;
|
|
class Content
|
|
class Content
|
|
{
|
|
{
|
|
# 获取内容分类以及默认分类
|
|
# 获取内容分类以及默认分类
|
|
- public function getCate($source_id)
|
|
|
|
|
|
+ public function getCate($source_id, $channel_id)
|
|
{
|
|
{
|
|
- $cate = Dever::db('psource/content_cate')->select(['info_id' => $source_id, 'status' => 1], ['col' => 'id,name']);
|
|
|
|
|
|
+ $cate = Dever::db('psource/content_cate')->select(['info_id' => $source_id, 'channel_id' => $channel_id, 'status' => 1], ['col' => 'id,name']);
|
|
# 获取当前的默认分类
|
|
# 获取当前的默认分类
|
|
$default = Dever::input('cate_id', '', '', 0);
|
|
$default = Dever::input('cate_id', '', '', 0);
|
|
if (!$default && $cate) {
|
|
if (!$default && $cate) {
|
|
@@ -15,9 +15,10 @@ class Content
|
|
}
|
|
}
|
|
|
|
|
|
# 获取内容列表
|
|
# 获取内容列表
|
|
- public function getList($uid, $source_id, $cate_id = 0)
|
|
|
|
|
|
+ public function getList($uid, $source_id, $channel_id, $cate_id = 0)
|
|
{
|
|
{
|
|
$where['info_id'] = $source_id;
|
|
$where['info_id'] = $source_id;
|
|
|
|
+ $where['channel_id'] = $channel_id;
|
|
if ($cate_id > 0) {
|
|
if ($cate_id > 0) {
|
|
$where['cate_id'] = $cate_id;
|
|
$where['cate_id'] = $cate_id;
|
|
}
|
|
}
|
|
@@ -25,50 +26,65 @@ class Content
|
|
if ($search) {
|
|
if ($search) {
|
|
$where['name'] = ['like', $search];
|
|
$where['name'] = ['like', $search];
|
|
}
|
|
}
|
|
- $data = Dever::db('psource/content')->select($where, ['col' => 'id,name,info,info_id,sku_id,score_id,score_num,score_time,content', 'num' => 10]);
|
|
|
|
|
|
+ $score_time = Dever::db('psource/content')->config['struct']['score_time']['value'];
|
|
|
|
+ $data = Dever::db('psource/content')->select($where, ['col' => 'id,name,info,info_id,sku_id,score_id,score_num,score_time,content,udate', 'num' => 10]);
|
|
if ($data) {
|
|
if ($data) {
|
|
foreach ($data as &$v) {
|
|
foreach ($data as &$v) {
|
|
|
|
+ if (!$v['info'] && $v['content']) {
|
|
|
|
+ $v['content'] = strip_tags(htmlspecialchars_decode($v['content']));
|
|
|
|
+ $v['info'] = mb_substr($v['content'], 0, 30, 'UTF-8');
|
|
|
|
+ }
|
|
|
|
+ unset($v['content']);
|
|
|
|
+
|
|
|
|
+ $v['price'] = '';
|
|
$v['look'] = $this->getLook($uid, $v);
|
|
$v['look'] = $this->getLook($uid, $v);
|
|
if ($v['look'] == 2) {
|
|
if ($v['look'] == 2) {
|
|
$v['price'] = '需解锁';
|
|
$v['price'] = '需解锁';
|
|
- } else {
|
|
|
|
|
|
+ if ($v['info']) {
|
|
|
|
+ $v['info'] = $v['price'] . ',' . $v['info'];
|
|
|
|
+ } else {
|
|
|
|
+ $v['info'] = $v['price'];
|
|
|
|
+ }
|
|
|
|
+ } elseif ($v['look'] >= 3) {
|
|
$v['price'] = Dever::load(\Pscore\Lib\Info::class)->getText($v['score_num'], $v['score_id']);
|
|
$v['price'] = Dever::load(\Pscore\Lib\Info::class)->getText($v['score_num'], $v['score_id']);
|
|
|
|
+ if ($v['info']) {
|
|
|
|
+ $v['info'] = '需付费,' . $v['info'];
|
|
|
|
+ } else {
|
|
|
|
+ $v['info'] = '需付费';
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (!$v['info']) {
|
|
|
|
- $v['content'] = strip_tags(htmlspecialchars_decode($v['content']));
|
|
|
|
- $v['info'] = mb_substr($v['content'], 0, 30, 'UTF-8');
|
|
|
|
|
|
+ $v['cate_id'] = Dever::db('psource/info')->column($v['info_id'], 'cate_id');
|
|
|
|
+ $v['buy'] = '您需要解锁后才能继续访问,点击确定将跳转至解锁页面';
|
|
|
|
+ if ($v['price']) {
|
|
|
|
+ $v['score_time'] = $score_time[$v['score_time']];
|
|
|
|
+ $v['score'] = '您需要付费'.$v['price'].'才能继续访问,付费后' . $v['score_time'] . '内免费访问';
|
|
}
|
|
}
|
|
- unset($v['content']);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
|
|
|
|
# 获取内容信息
|
|
# 获取内容信息
|
|
- public function getInfo($uid, $content_id)
|
|
|
|
|
|
+ public function getInfo($uid, $content_id, $kou = false)
|
|
{
|
|
{
|
|
- $info = Dever::db('psource/content')->find($content_id, ['col' => 'id,name,info_id,sku_id,score_id,score_num,score_time,info,content,attachment']);
|
|
|
|
|
|
+ $info = Dever::db('psource/content')->find($content_id, ['col' => 'id,name,info_id,sku_id,score_id,score_num,score_time,info,content']);
|
|
if (!$info) {
|
|
if (!$info) {
|
|
Dever::error('内容不存在');
|
|
Dever::error('内容不存在');
|
|
}
|
|
}
|
|
- $info['look'] = $this->getLook($uid, $info, true);
|
|
|
|
|
|
+ $info['look'] = $this->getLook($uid, $info, $kou);
|
|
if ($info['look'] == 2) {
|
|
if ($info['look'] == 2) {
|
|
- Dever::error('请先购买', -1);
|
|
|
|
|
|
+ Dever::error('请先解锁', -1);
|
|
}
|
|
}
|
|
if ($info['look'] == 4) {
|
|
if ($info['look'] == 4) {
|
|
Dever::error('积分不足', -2);
|
|
Dever::error('积分不足', -2);
|
|
}
|
|
}
|
|
- $info['content'] = htmlspecialchars_decode($info['content']);
|
|
|
|
- $info['attachment'] = [];
|
|
|
|
- $attachment = explode(',', $attachment);
|
|
|
|
- if ($attachment) {
|
|
|
|
- foreach ($attachment as $k => $v) {
|
|
|
|
- $path = parse_url($v, PHP_URL_PATH);
|
|
|
|
- $filename = pathinfo($path, PATHINFO_FILENAME);
|
|
|
|
- $info = Dever::db('upload/file')->find(['name' => $filename]);
|
|
|
|
- $info['attachment'][] = ['name' => $info['source_name'], 'link' => $v];
|
|
|
|
- }
|
|
|
|
|
|
+ if ($kou) {
|
|
|
|
+ return $info;
|
|
}
|
|
}
|
|
|
|
+ $info['content'] = htmlspecialchars_decode($info['content']);
|
|
|
|
+ $info['media'] = Dever::db('psource/content_media')->select(['content_id' => $info['id']], ['col' => 'id,name as title,file as url']);
|
|
|
|
+ $info['data'] = Dever::db('psource/content_data')->select(['content_id' => $info['id']], ['col' => 'id,name,file']);
|
|
|
|
+ $info['link'] = Dever::db('psource/content_link')->select(['content_id' => $info['id']], ['col' => 'id,name,link']);
|
|
return $info;
|
|
return $info;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -79,7 +95,7 @@ class Content
|
|
# 先验证是否需要解锁
|
|
# 先验证是否需要解锁
|
|
if ($info['sku_id'] == -1) {
|
|
if ($info['sku_id'] == -1) {
|
|
# 免费
|
|
# 免费
|
|
- $state = -1;
|
|
|
|
|
|
+ $state = 1;
|
|
} else {
|
|
} else {
|
|
# 检测是否解锁
|
|
# 检测是否解锁
|
|
if ($uid) {
|
|
if ($uid) {
|