Content.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <?php
  2. namespace Main\Src;
  3. use Dever;
  4. use Main\Lib\Core;
  5. use Dever\Routing\Uri;
  6. class Content
  7. {
  8. # 基本配置
  9. public function config()
  10. {
  11. $data = Dever::db('main/config')->one();
  12. $data['contact'] = Dever::url('contact');
  13. return $data;
  14. }
  15. # 获取菜单
  16. public function menu()
  17. {
  18. $uri = Uri::$value;
  19. $type = Dever::input('type');
  20. $menu = array
  21. (
  22. 'home' => array
  23. (
  24. 'name' => '首&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;页',
  25. 'active' => $uri == 'search' ? true : false,
  26. ),
  27. 'news' => array
  28. (
  29. 'name' => '资&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;讯',
  30. 'active' => $type == 1 ? true : false,
  31. ),
  32. 'xnr' => array
  33. (
  34. 'name' => '虚&nbsp;拟&nbsp;人',
  35. 'active' => false,
  36. 'uri' => array('xnr-detail', 'zwz-detail'),
  37. ),
  38. 'feature' => array
  39. (
  40. 'name' => '专&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题',
  41. 'active' => $type == 2 ? true : false,
  42. ),
  43. 'video' => array
  44. (
  45. 'name' => '视&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;频',
  46. 'active' => $type == 3 ? true : false,
  47. ),
  48. 'activity' => array
  49. (
  50. 'name' => '活&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;动',
  51. 'active' => $type == 4 ? true : false,
  52. ),
  53. 'contact' => array
  54. (
  55. 'name' => '关于我们',
  56. 'active' => false,
  57. ),
  58. );
  59. foreach ($menu as $k => $v) {
  60. $menu[$k]['link'] = Dever::url($k);
  61. if ($v['active'] || $uri == $k || (isset($v['uri']) && in_array($uri, $v['uri']))) {
  62. $menu[$k]['class'] = 'active';
  63. } else {
  64. $menu[$k]['class'] = '';
  65. }
  66. }
  67. return $menu;
  68. }
  69. # 首页广告
  70. public function ad()
  71. {
  72. $key = Dever::input('key', 'home_ad');
  73. $name = Dever::input('name', '首页广告');
  74. return Dever::load('push/lib/data')->get($key, $name, 3, '1,5');
  75. }
  76. # 焦点图
  77. public function focus()
  78. {
  79. $key = Dever::input('key', 'home_focus');
  80. $name = Dever::input('name', '首页焦点图');
  81. return Dever::load('push/lib/data')->get($key, $name, 5, '1,2,5');
  82. }
  83. # 获取热门推荐
  84. public function hot()
  85. {
  86. $type = Dever::input('type');
  87. if ($type == 1) {
  88. $key = 'news';
  89. $name = '资讯';
  90. } elseif ($type == 2) {
  91. $key = 'feature';
  92. $name = '专题';
  93. } elseif ($type == 3) {
  94. $key = 'video';
  95. $name = '视频';
  96. } elseif ($type == 4) {
  97. $key = 'act';
  98. $name = '活动';
  99. }
  100. $data = Dever::load('push/lib/data')->get($key . '_hot', $name . '详情页热门推荐', 4, '1,3,5', ($type + 2). ',10');
  101. if (!$data) {
  102. $data = Dever::load('content/lib/news')->getHome($type, 4);
  103. }
  104. return $data;
  105. }
  106. # 获取首页资讯
  107. public function home_news()
  108. {
  109. //$data = Dever::load('push/lib/data')->get('home_news', '首页资讯', 3, '1,2,3,4,5,6,7');
  110. $data = false;
  111. if (!$data) {
  112. $data = Dever::load('content/lib/news')->getHome(1, 3);
  113. }
  114. return $data;
  115. }
  116. # 获取首页专题
  117. public function home_feature()
  118. {
  119. //$data = Dever::load('push/lib/data')->get('home_feature', '首页专题', 5, '1,2,3,4,5,6,7');
  120. $data = false;
  121. if (!$data) {
  122. $data = Dever::load('content/lib/news')->getHome(2, 5);
  123. }
  124. return $data;
  125. }
  126. # 获取首页视频
  127. public function home_video_first()
  128. {
  129. //$data = Dever::load('push/lib/data')->get('home_video', '首页视频', 5, '1,2,3,4,5,6,7');
  130. $data = false;
  131. if (!$data) {
  132. $data = Dever::load('content/lib/news')->getHome(3, 5);
  133. }
  134. if ($data) {
  135. return $data[0];
  136. }
  137. return false;
  138. }
  139. public function home_video_other()
  140. {
  141. //$data = Dever::load('push/lib/data')->get('home_video', '首页视频', 5, '1,2,3,4,5,6,7');
  142. $data = false;
  143. if (!$data) {
  144. $data = Dever::load('content/lib/news')->getHome(3, 5);
  145. }
  146. if ($data) {
  147. unset($data[0]);
  148. }
  149. return $data;
  150. }
  151. # 获取首页活动
  152. public function home_act()
  153. {
  154. //$data = Dever::load('push/lib/data')->get('home_act', '首页活动', 4, '1,2,3,4,5,6,7');
  155. $data = false;
  156. if (!$data) {
  157. $data = Dever::load('content/lib/news')->getHome(4, 4);
  158. }
  159. return $data;
  160. }
  161. # 获取首页虚拟人
  162. public function home_xnr()
  163. {
  164. //$data = Dever::load('push/lib/data')->get('home_xnr', '首页虚拟人', 10, '1,2,3,4,5');
  165. $data = false;
  166. if (!$data) {
  167. $data = Dever::load('content/lib/xuniren')->getHome(10);
  168. }
  169. return $data;
  170. }
  171. # 获取资讯
  172. public function news()
  173. {
  174. $type = Dever::input('type', 1);
  175. $name = Dever::input('v');
  176. $data = Dever::load('content/lib/news')->getAll($type, $name);
  177. return $data;
  178. }
  179. # 获取资讯详情
  180. public function view()
  181. {
  182. $type = Dever::input('type', 1);
  183. $id = Dever::input('id');
  184. if (!$id) {
  185. Dever::alert('错误的数据id');
  186. }
  187. $data = Dever::load('content/lib/news')->getInfo($type, $id);
  188. return $data;
  189. }
  190. # 获取单页内容
  191. public function getPage()
  192. {
  193. $key = Dever::input('key', 1);
  194. $where['key'] = $key;
  195. $data = Dever::db('main/page')->one($where);
  196. return $data;
  197. }
  198. # 获取单页内容
  199. public function getAbout()
  200. {
  201. Dever::setInput('key', 'about');
  202. return $this->getPage();
  203. }
  204. # 搜索页面
  205. public function search()
  206. {
  207. $url = Dever::url('search?v=');
  208. $html = 'location.href=\''.$url.'\'+$(\'#search\').val()';
  209. return $html;
  210. }
  211. # 手机搜索页面
  212. public function msearch()
  213. {
  214. $url = Dever::url('search?v=');
  215. $html = 'location.href=\''.$url.'\'+$(\'#msearch\').val()';
  216. return $html;
  217. }
  218. # 获取联系我们的需求分类
  219. public function contact_xuqiu()
  220. {
  221. return Dever::db('act/contact')->config['xuqiu'];
  222. }
  223. # 新增联系我们
  224. public function contact_add()
  225. {
  226. $username = Dever::input('username');
  227. $mobile = Dever::input('mobile');
  228. $email = Dever::input('email');
  229. $content = Dever::input('content');
  230. $xuqiu = Dever::input('xuqiu', 3);
  231. if (!$username) {
  232. Dever::alert('请填写姓名');
  233. }
  234. if (!$mobile) {
  235. Dever::alert('请填写联系电话');
  236. }
  237. if (!$email) {
  238. Dever::alert('请填写电子信箱');
  239. }
  240. Dever::load('act/lib/contact')->add($username, $mobile, $email, $content, $xuqiu);
  241. return 'ok';
  242. }
  243. # 新增订阅
  244. public function ding_add()
  245. {
  246. $username = Dever::input('username');
  247. $email = Dever::input('email');
  248. $qudao = Dever::input('qudao', 1);
  249. if (!$username) {
  250. Dever::alert('请填写用户名');
  251. }
  252. if (!$email) {
  253. Dever::alert('请填写电子信箱');
  254. }
  255. Dever::load('act/lib/ding')->add($username, $email, $qudao);
  256. return 'ok';
  257. }
  258. # 新增分享
  259. public function share_add()
  260. {
  261. $name = Dever::input('name');
  262. $link = Dever::input('link');
  263. $type = Dever::input('type', 1);
  264. if (!$name) {
  265. Dever::alert('请填写内容名称');
  266. }
  267. if (!$link) {
  268. Dever::alert('请填写链接');
  269. }
  270. Dever::load('act/lib/share')->add($name, $link, $type);
  271. return 'ok';
  272. }
  273. }