|
@@ -18,20 +18,221 @@ class Content
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- print_r($data);die;
|
|
|
+ return $data;
|
|
|
}
|
|
|
|
|
|
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']));
|
|
|
|
|
|
- $data['data'] = Dever::db($table)->one(array('content_id' => $data['id'], 'info_id' => $data['info_id']));
|
|
|
+ $data['data']['num_view'] = 1;
|
|
|
+
|
|
|
+ $data['data']['date'] = '';
|
|
|
+ if (isset($data['data']['cdate'])) {
|
|
|
+ $data['data']['date'] = date('Y-m-d H:i:s', $data['data']['cdate']);
|
|
|
+ }
|
|
|
|
|
|
if (isset($data['data']['text'])) {
|
|
|
$data['data']['text'] = Dever::array_decode($data['data']['text']);
|
|
|
+
|
|
|
+ foreach ($data['data']['text'] as $k => $v) {
|
|
|
+ if (isset($v['content']) && $v['content']) {
|
|
|
+ $data['data']['text'][$k]['content_array'] = $this->getContent($v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($data['data']['author_id']) && $data['data']['author_id'] > 0) {
|
|
|
+ $data['data']['author'] = Dever::db('store/author')->one($data['data']['author_id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($data['data']['content']) && $data['data']['content']) {
|
|
|
+ $data['data'] = $this->getContent($data['data']);
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ public function getContent($data, $uid = false)
|
|
|
+ {
|
|
|
+
|
|
|
+ $data['content_array'] = array();
|
|
|
+
|
|
|
+ $data['content'] = Dever::filter($data['content']);
|
|
|
+
|
|
|
+ $content = $data['content'];
|
|
|
+ $replace = array();
|
|
|
+
|
|
|
+
|
|
|
+ if (strstr($data['content'], 'data-applet')) {
|
|
|
+ preg_match_all('/<img(.*?)data-applet="(.*?)" \/>/', $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'], '<img')) {
|
|
|
+ preg_match_all('/<img(.*?)src="(.*?)" (.*?)\/>/', $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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (strstr($data['content'], 'data-file')) {
|
|
|
+ preg_match_all('/<img src="(.*?)" style="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
|
|
|
+
|
|
|
+ if (!isset($matches[1][0])) {
|
|
|
+ preg_match_all('/<img style="(.*?)" src="(.*?)" data-file="(.*?)" \/>/', $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('/<img(.*?)data-id="(.*?)" data-key="(.*?)" \/>/', $content, $matches);
|
|
|
+
|
|
|
+
|
|
|
+ if (!isset($matches[2][0])) {
|
|
|
+ preg_match_all('/<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>/', $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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $content = explode('{replace}', $content);
|
|
|
+ $data['content_array'] = array();
|
|
|
+
|
|
|
+ foreach ($content as $k => $v) {
|
|
|
+ $v = trim($v);
|
|
|
+ if (is_numeric($v) && $v >= 0 && isset($replace[$v])) {
|
|
|
+ $data['content_array'][] = $replace[$v];
|
|
|
+ } elseif ($v) {
|
|
|
+ $data['content_array'][] = array
|
|
|
+ (
|
|
|
+ 'type' => 'html',
|
|
|
+ 'content' => $v,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$data['content_array']) {
|
|
|
+ $data['content_array'][] = array
|
|
|
+ (
|
|
|
+ 'type' => 'html',
|
|
|
+ 'content' => $data['content'],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ unset($data['content']);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
}
|