notice-show.ctrl.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('article');
  8. load()->model('user');
  9. $dos = array( 'detail', 'list');
  10. $do = in_array($do, $dos) ? $do : 'list';
  11. if($do == 'detail') {
  12. $id = intval($_GPC['id']);
  13. $notice = article_notice_info($id);
  14. if(is_error($notice)) {
  15. itoast('公告不存在或已删除', referer(), 'error');
  16. }
  17. $_W['page']['title'] = $notice['title'] . '-公告列表';
  18. pdo_query('UPDATE ' . tablename('article_notice') . ' SET click = click + 1 WHERE id = :id', array(':id' => $id));
  19. if(!empty($_W['uid'])) {
  20. pdo_update('article_unread_notice', array('is_new' => 0), array('notice_id' => $id, 'uid' => $_W['uid']));
  21. }
  22. $title = $notice['title'];
  23. }
  24. if($do == 'list') {
  25. $_W['page']['title'] = '-新闻列表';
  26. $categroys = article_categorys('notice');
  27. $categroys[0] = array('title' => '所有公告');
  28. $cateid = intval($_GPC['cateid']);
  29. $_W['page']['title'] = $categroys[$cateid]['title'] . '-公告列表';
  30. $pindex = max(1, intval($_GPC['page']));
  31. $psize = 20;
  32. $filter = array('cateid' => $cateid);
  33. $notices = article_notice_all($filter, $pindex, $psize);
  34. $total = intval($notices['total']);
  35. $data = $notices['notice'];
  36. $pager = pagination($total, $pindex, $psize);
  37. }
  38. template('article/notice-show');