123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650 |
- <?php
- namespace Main\Src;
- use Dever;
- use Main\Lib\Core;
- use Dever\Routing\Uri;
- class Content
- {
-
- public function config()
- {
- $data = Dever::db('main/config')->one();
- $data['contact'] = Dever::url('contact');
- return $data;
- }
-
- public function share()
- {
- $title = '';
- $pic = '';
- $content = '';
- $uri = Uri::$value;
- $id = Dever::input('id');
- $config = Dever::load('main/content.config');
- if ($id) {
- if ($uri == 'xnr-detail') {
- $data = Dever::db('content/xuniren')->one($id);
- if (isset($data['ins']) && $data['ins']) {
- $config['ins'] = $data['ins'];
- }
- if (isset($data['ins_link']) && $data['ins_link']) {
- $config['ins_link'] = $data['ins_link'];
- }
- if (isset($data['douyin']) && $data['douyin']) {
- $config['douyin'] = $data['douyin'];
- }
- if (isset($data['bilibili']) && $data['bilibili']) {
- $config['bilibili'] = $data['bilibili'];
- }
-
- } elseif ($uri == 'zwz-detail') {
- $data = Dever::db('content/creater')->one($id);
- $data['pic'] = $data['logo'];
- } else {
- $data = Dever::db('content/news')->one($id);
- }
- if (isset($data['share_title']) && $data['share_title']) {
- $title = $data['share_title'];
- } else {
- $title = $data['name'];
- }
- if (isset($data['share_pic']) && $data['share_pic']) {
- $pic = $data['share_pic'];
- } else {
- $pic = $data['pic'];
- }
- if (isset($data['share_content']) && $data['share_content']) {
- $pic = $data['share_content'];
- } else {
- $pic = $data['info'];
- }
- } else {
- $title = $config['name'];
- $pic = $config['logo'];
- }
-
- $ralateUid = '';
- $appkey = '';
- $url = Dever::url();
-
- $share = 'config.wbshare = {
- title: "'.$title.'",
- url: "'.$url.'",
- pic: "'.$pic.'",
- ralateUid: "'.$ralateUid.'",
- appkey: "'.$appkey.'",
- content: "'.$content.'"
- }';
- $share .= ';config.ins="'.$config['ins'].'"';
- $share .= ';config.ins_link="'.$config['ins_link'].'"';
- $share .= ';config.douyin="'.$config['douyin'].'"';
- $share .= ';config.bili="'.$config['bilibili'].'"';
- return $share;
- }
-
- public function menu()
- {
- $uri = Uri::$value;
- $type = Dever::input('type');
- $menu = array
- (
- 'home' => array
- (
- 'name' => '首 页',
- 'active' => $uri == 'search' ? true : false,
- ),
- 'news' => array
- (
- 'name' => '资 讯',
- 'active' => $type == 1 ? true : false,
-
- ),
- 'xnr' => array
- (
- 'name' => '虚 拟 人',
- 'active' => false,
- 'uri' => array('xnr-detail', 'zwz-detail'),
- ),
- 'feature' => array
- (
- 'name' => '专 题',
- 'active' => $type == 2 ? true : false,
- ),
- 'video' => array
- (
- 'name' => '视 频',
- 'active' => $type == 3 ? true : false,
- ),
- 'activity' => array
- (
- 'name' => '活 动',
- 'active' => $type == 4 ? true : false,
- ),
- 'contact' => array
- (
- 'name' => '关于我们',
- 'active' => false,
- ),
- );
- foreach ($menu as $k => $v) {
- $menu[$k]['link'] = Dever::url($k);
- if ($v['active'] || $uri == $k || (isset($v['uri']) && in_array($uri, $v['uri']))) {
- $menu[$k]['class'] = 'active';
- } else {
- $menu[$k]['class'] = '';
- }
- }
- return $menu;
- }
-
- public function ad()
- {
- $key = Dever::input('key', 'home_ad');
- $name = Dever::input('name', '首页广告');
- return Dever::load('push/lib/data')->get($key, $name, 3, '1,5');
- }
-
-
- public function focus()
- {
- $key = Dever::input('key', 'home_focus');
- $name = Dever::input('name', '首页焦点图');
- $num = Dever::input('num', 0);
- return Dever::load('push/lib/data')->get($key, $name, 5, '1,2,5', '10', false, $num);
- }
-
- public function hot()
- {
- $type = Dever::input('type');
- if ($type == 1) {
- $key = 'news';
- $name = '资讯';
- } elseif ($type == 2) {
- $key = 'feature';
- $name = '专题';
- } elseif ($type == 3) {
- $key = 'video';
- $name = '视频';
- } elseif ($type == 4) {
- $key = 'act';
- $name = '活动';
- }
- $data = Dever::load('push/lib/data')->get($key . '_hot', $name . '详情页热门推荐', 4, '1,3,5', ($type + 2). ',10');
- if (!$data) {
- $data = Dever::load('content/lib/news')->getHome($type, 4);
- }
- return $data;
- }
-
- public function home_news()
- {
-
- $data = false;
- if (!$data) {
- $data = Dever::load('content/lib/news')->getHome(1, 3);
- }
- return $data;
- }
-
- public function home_feature()
- {
- $data = Dever::load('push/lib/data')->get('home_feature', '首页专题', 5, '1,2,3,4,5,6,7');
-
- if (!$data) {
- $data = Dever::load('content/lib/news')->getHome(2, 5);
- }
- return $data;
- }
-
- public function list_feature()
- {
- $data = Dever::load('push/lib/data')->get('list_feature', '专题列表顶部推荐位', 5, '1,2,3,4,5,6,7');
-
- if (!$data) {
- $data = Dever::load('content/lib/news')->getHome(2, 5);
- }
- return $data;
- }
-
- public function home_video_first()
- {
-
- $data = false;
- if (!$data) {
- $data = Dever::load('content/lib/news')->getHome(3, 3);
- }
- if ($data) {
- $data[0]['sname'] = '<a href="'.$data[0]['link'].'">'.$data[0]['sname'].'</a>';
- return $data[0];
- }
- return false;
- }
- public function home_video_other()
- {
-
- $data = false;
- if (!$data) {
- $data = Dever::load('content/lib/news')->getHome(3, 3);
- }
- if ($data) {
- unset($data[0]);
- }
- return $data;
- }
-
- public function home_act()
- {
-
- $data = false;
- if (!$data) {
- $data = Dever::load('content/lib/news')->getHome(4, 4);
- }
- return $data;
- }
-
- public function home_xnr()
- {
-
- $data = false;
- if (!$data) {
- $data = Dever::load('content/lib/xuniren')->getHome(10);
- }
- return $data;
- }
-
- public function news()
- {
- $type = Dever::input('type', 1);
- $name = Dever::input('v');
- $data = Dever::load('content/lib/news')->getAll($type, $name);
- return $data;
- }
-
- public function getNews()
- {
- $data = Dever::load('main/content.news');
- if ($data) {
- return true;
- }
- return false;
- }
-
- public function getNoNews()
- {
- $pg = input('pg');
- $data = Dever::load('main/content.news');
- if ($data || $pg > 1) {
- return false;
- }
- return true;
- }
-
- public function view()
- {
- $type = Dever::input('type', 1);
- $id = Dever::input('id');
- if (!$id) {
- Dever::alert('错误的数据id');
- }
- $data = Dever::load('content/lib/news')->getInfo($type, $id);
- return $data;
- }
-
- public function view_pic()
- {
- $data = Dever::load('main/content.view_video_1');
- if ($data) {
- return false;
- }
- return true;
- }
-
- public function view_video()
- {
- $data = Dever::load('main/content.view');
- $result = array();
- if ($data['video']) {
- return true;
- }
- return false;
- }
-
- public function view_video_1()
- {
- $data = Dever::load('main/content.view');
- $result = array();
- if ($data['type'] == 3 && $data['video']) {
- return true;
- }
- return false;
- }
-
- public function view_video_2()
- {
- $data = Dever::load('main/content.view');
- $result = array();
- if ($data['type'] != 3 && $data['content_video']) {
- return true;
- }
- return false;
- }
-
- public function view_tag()
- {
- $data = Dever::load('main/content.view');
- $result = array();
- if ($data['tag']) {
- $tag = '';
- if (strstr($data['tag'], ',')) {
- $tag = explode(',', $data['tag']);
- } elseif (strstr($data['tag'], ',')) {
- $tag = explode(',', $data['tag']);
- }
- if ($tag && is_array($tag)) {
- foreach($tag as $k => $v) {
- $result[$k]['name'] = $v;
- $result[$k]['link'] = Dever::url('search?type='.$data['type'].'&v=' . $v);
- }
- }
- }
- return $result;
- }
-
- public function getPage()
- {
- $key = Dever::input('key', 1);
- $where['key'] = $key;
- $data = Dever::db('main/page')->one($where);
- return $data;
- }
-
- public function getAbout()
- {
- Dever::setInput('key', 'about');
- return $this->getPage();
- }
-
- public function search()
- {
- $url = Dever::url('search?v=');
- $html = 'location.href=\''.$url.'\'+$(\'#search\').val()';
- return $html;
- }
-
- public function msearch()
- {
- $url = Dever::url('search?v=');
- $html = 'location.href=\''.$url.'\'+$(\'#msearch\').val()';
- return $html;
- }
-
- public function contact_xuqiu()
- {
- return Dever::db('act/contact')->config['xuqiu'];
- }
-
- public function contact_add()
- {
- $username = Dever::input('username');
- $mobile = Dever::input('mobile');
- $email = Dever::input('email');
- $content = Dever::input('content');
- $xuqiu = Dever::input('xuqiu', 3);
- if (!$username) {
- Dever::alert('请填写姓名');
- }
- if (!$mobile) {
- Dever::alert('请填写联系电话');
- }
- if (!$email) {
- Dever::alert('请填写电子信箱');
- }
- Dever::load('act/lib/contact')->add($username, $mobile, $email, $content, $xuqiu);
- return 'ok';
- }
-
- public function ding_add()
- {
- $username = Dever::input('username');
- $email = Dever::input('email');
- $qudao = Dever::input('qudao', 1);
- if (!$username) {
- Dever::alert('请填写用户名');
- }
- if (!$email) {
- Dever::alert('请填写电子信箱');
- }
- Dever::load('act/lib/ding')->add($username, $email, $qudao);
- return 'ok';
- }
-
- public function share_add()
- {
- $name = Dever::input('name');
- $link = Dever::input('link');
- $type = Dever::input('type', 1);
- if (!$name) {
- Dever::alert('请填写内容名称');
- }
- if (!$link) {
- Dever::alert('请填写链接');
- }
- Dever::load('act/lib/share')->add($name, $link, $type);
- return 'ok';
- }
-
- public function getZwzOne()
- {
- $id = Dever::input('id');
- if (!$id) {
- Dever::alert('错误的数据id');
- }
- $data = Dever::load('content/lib/creater')->getInfo($id);
- return $data;
- }
-
- public function getXnrByZwz()
- {
- $id = Dever::input('id');
- if (!$id) {
- Dever::alert('错误的数据id');
- }
- $data = Dever::load('content/lib/xuniren')->getDataByCreater($id);
- return $data;
- }
-
- public function getXnrOne()
- {
- $id = Dever::input('id');
- if (!$id) {
- Dever::alert('错误的数据id');
- }
- $data = Dever::load('content/lib/xuniren')->getInfo($id);
- return $data;
- }
-
- public function getXnrOne_news()
- {
- $data = Dever::load('main/content.getXnrOne');
- if ($data && $data['news']) {
- foreach($data['news'] as $k => $v) {
- $data['news'][$k]['class'] = '';
- }
- $data['news'][] = array
- (
- 'name' => '相关资讯',
- 'link' => '#',
- 'class' => 'tag',
- );
- return $data['news'];
- }
- return array();
- }
-
- public function getXnrOne_pic()
- {
- $data = Dever::load('main/content.getXnrOne');
- if ($data && isset($data['pic_list']) && $data['pic_list']) {
- return $data['pic_list'];
- }
- return array();
- }
-
- public function getXnr()
- {
- $data = Dever::db('content/xuniren')->getAll();
- $html = '';
- foreach ($data as $k => $v) {
- $k = strtoupper($k);
- $html .= '<dl id="'.$k.'"><dt>' . $k . '</dt><dd>';
- foreach ($v as $k1 => $v1) {
- $url = Dever::url('main/xnr-detail?id=' . $v1['id']);
- $html .= '<a href="'.$url.'">'.$v1['name'].'</a>';
- }
- $html .= '</dl>';
- }
- return $html;
- }
-
- public function getZwz()
- {
- $data = Dever::db('content/creater')->getAll();
- $html = '';
- foreach ($data as $k => $v) {
- $k = strtoupper($k);
- $html .= '<dl id="'.$k.'"><dt>' . $k . '</dt><dd>';
- foreach ($v as $k1 => $v1) {
- $url = Dever::url('main/zwz-detail?id=' . $v1['id']);
- $html .= '<a href="'.$url.'">'.$v1['name'].'</a>';
- }
- $html .= '</dl>';
- }
- return $html;
- }
-
- public function video()
- {
- $id = Dever::input('id');
- $data = Dever::db('content/news')->one($id);
- $video = '';
- if ($data && $data['type'] == 3) {
- $video = $data['video'];
- } elseif ($data && $data['type'] != 3) {
- $video = $data['content_video'];
- }
- if ($data && $video) {
- $info['video'] = $video;
- if (strstr($info['video'], '.qq.com')) {
- $info['video'] = Dever::qqvideo($info['video']);
- }
- return $info;
- }
- return array();
- }
- }
|