update($update);
}
}
# 获取某一个合集的内容列表
public function getList($info_id, $page_id)
{
$where['info_id'] = $info_id;
$where['page_id'] = $page_id;
$data = Dever::db('collection/content')->getAllPage($where);
$result = array();
if ($data) {
$i = 0;
# 获取章节信息
$page = Dever::db('collection/page')->one($page_id);
if ($page && $page['desc']) {
$parent_page = Dever::db('collection/page')->one($page['page_id']);
$page['parent_name'] = $parent_page['name'];
$page['name'] = $page['name'];
$info = Dever::db('collection/info')->one($info_id);
if ($info && $info['uid'] > 0) {
$user = Dever::load('passport/api')->info($info['uid']);
$page['username'] = $user['username'];
$page['copyright'] = "如不慎侵害您的权益,请告知,我们将责令创作者修改";
} else {
$page['username'] = '官方';
$page['copyright'] = "所有内容仅供内部专用,禁止在互联网传播";
}
$result[$i] = $page;
//$result[$i]['copyright'] = $page['copyright'];
$result[$i]['data'] = -1;
$result[$i]['type'] = -1;
$result[$i]['times'] = $result[$i]['times_parent'] = '';
if ($page['times_id_parent'] && $page['times_id']) {
$times = Dever::db('collection/times')->one($page['times_id']);
$result[$i]['times'] = $times['name'];
$times = Dever::db('collection/times')->one($page['times_id_parent']);
$result[$i]['times_parent'] = $times['name'];
}
$i = 1;
}
foreach ($data as $k => $v) {
$data[$k] = $this->getOne($v);
if ($data[$k]['data']) {
$result[$i] = $data[$k];
$i++;
}
}
if ($page && $page['desc']) {
$result[$i] = $result[0];
if ($page['desc_end']) {
$result[$i]['name'] .= ' 已完结';
$result[$i]['desc'] = $page['desc_end'];
} else {
$result[$i]['name'] .= ' 连载中';
}
}
}
return $result;
}
public function getOne($data)
{
$type = Dever::db('collection/cate')->config['gettype'];
$table = $type[$data['type']]['table'];
if (!$table) {
return $data;
}
$method = 'one';
if (strstr($table, '-')) {
$temp = explode('-', $table);
$table = $temp[0];
$method = $temp[1];
}
$data['data'] = Dever::db($table)->$method(array('content_id' => $data['id'], 'info_id' => $data['info_id']));
if ($data['data']) {
if (isset($data['data']['id'])) {
$data['data'] = $this->getData($data['data']);
} else {
foreach ($data['data'] as $k => $v) {
$data['data'][$k] = $this->getData($v);
}
}
}
return $data;
}
public function getData($data)
{
$data['num_view'] = 1;
$data['date'] = '';
if (isset($data['cdate'])) {
$data['date'] = date('Y-m-d H:i:s', $data['cdate']);
}
if (isset($data['text'])) {
$data['text'] = Dever::array_decode($data['text']);
foreach ($data['text'] as $k => $v) {
if (isset($v['name']) && $v['name']) {
$data['text'][$k]['name_array'] = explode("\r\n", $v['name']);
}
if (isset($v['bgcolor_type']) && $v['bgcolor_type'][0] == 2) {
$data['text'][$k]['bgcolor'] = '';
}
if (isset($v['content']) && $v['content']) {
$data['text'][$k]['content_array'] = $this->getContent($v);
}
}
}
if (isset($data['author_id']) && $data['author_id'] > 0) {
$data['author'] = Dever::db('store/author')->one($data['author_id']);
}
if (isset($data['content']) && $data['content']) {
$data = $this->getContent($data);
}
if (isset($data['goods_id']) && $data['goods_id'] > 0) {
$data['goods'] = Dever::load('goods/lib/info')->getInfo($data['goods_id']);
$data['goods'] = $this->getContent($data['goods']);
}
unset($data['info_id']);
unset($data['content_id']);
unset($data['status']);
unset($data['state']);
unset($data['cdate']);
unset($data['reorder']);
unset($data['udate']);
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'], 'data-applet')) {
preg_match_all('//', $content, $matches);
if (isset($matches[2])) {
foreach ($matches[2] as $k => $v) {
$content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
$temp = explode('||', $v);
$pic = $temp[0];
$appid = $temp[1];
$path = $temp[2];
if ($appid) {
$appinfo = Dever::db('content/applet')->one(array('appid' => $appid));
} else {
$appinfo['name'] = '';
$appinfo['link'] = '';
}
if (isset($temp[3]) && $temp[3]) {
$appinfo['link'] = $temp[3];
}
$replace[] = array('type' => 'applet', 'pic_cover' => $pic, 'appid' => $appid, 'path' => $path, 'name' => $appinfo['name'], 'link' => $appinfo['link']);
}
}
}
# 图片
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;
}
}
}
# 音视频
if (strstr($data['content'], 'data-file')) {
preg_match_all('/
/', $content, $matches);
if (!isset($matches[1][0])) {
preg_match_all('/
/', $content, $matches);
$temp = array();
if (isset($matches[2][0])) {
$temp = $matches;
$matches[1] = $temp[2];
unset($temp);
}
}
if (isset($matches[1])) {
foreach ($matches[1] as $k => $v) {
if (isset($matches[3][$k])) {
$content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
$file = $matches[3][$k];
$temp = explode('||', $file);
$file = $temp[0];
if (isset($temp[1])) {
$name = $temp[1];
} else {
$name = '';
}
$cover = $v;
if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
$replace[] = array('type' => 'video', 'content' => $file, 'cover' => $cover, 'name' => $name);
} else {
$replace[] = array('type' => 'audio', 'content' => $file, 'cover' => $cover, 'name' => $name);
}
}
}
}
}
# 视频+直播
if (strstr($data['content'], 'data-id')) {
preg_match_all('/
/', $content, $matches);
if (!isset($matches[2][0])) {
preg_match_all('/
/', $content, $matches);
$temp = array();
if (isset($matches[2][0]) && isset($matches[3][0])) {
$temp = $matches;
$matches[2] = $temp[3];
$matches[3] = $temp[2];
unset($temp);
}
}
if (isset($matches[2][0]) && isset($matches[3][0])) {
foreach ($matches[2] as $k => $v) {
$content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
if ($matches[3][$k] == 'video/lib/core.vod') {
$method = 'video/lib/vod';
$type = 'video';
} else {
$type = 'live';
$method = 'video/lib/live';
}
$info = Dever::load($method)->get($v);
if (isset($info['content'])) {
unset($info['content']);
}
if ($type == 3) {
# 查看是否有预约
if ($uid > 0) {
$info['user_act']['note'] = Dever::load('act/lib/note')->get($uid, $v, $type);
} else {
$info['user_act']['note'] = 2;
}
}
$replace[] = array('id' => $v, 'type' => $type, 'content' => $info);
}
}
}
//$data['content'] = preg_replace('/