portalcp_category.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: portalcp_category.php 30378 2012-05-24 09:52:46Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['setting']['portalstatus']) {
  12. dheader('location:portal.php?mod=portalcp&ac=portalblock');
  13. }
  14. require_once libfile('function/portalcp');
  15. $catid = max(0,intval($_GET['catid']));
  16. $perpagearr = array(20, 30,40, 50, 100);
  17. $_GET['type'] = isset($_GET['type']) && in_array($_GET['type'], array('unrecommend', 'recommended', 'me')) ? $_GET['type'] : 'all';
  18. $perpage = isset($_GET['perpage']) && in_array($_GET['perpage'], $perpagearr) ? $_GET['perpage'] : 20;
  19. $typearr[$_GET['type']] = 'class="a"';
  20. $theurl = "portal.php?mod=portalcp&ac=category&catid=$catid&perpage=$perpage&type=$_GET[type]&formhash=".FORMHASH."&searchkey=".urlencode($_GET['searchkey']);
  21. $allowmanage = checkperm('allowmanagearticle');
  22. $allowpost = checkperm('allowpostarticle');
  23. $catids = $wherearr = array();
  24. $category = $_G['cache']['portalcategory'];
  25. $permission = getallowcategory($_G['uid']);
  26. if($catid) {
  27. if (!$allowmanage && !$allowpost && empty($permission[$catid]['allowmanage']) && empty($permission[$catid]['allowpublish'])) {
  28. showmessage('portal_nopermission');
  29. }
  30. $cate = $category[$catid];
  31. if(empty($cate)) {
  32. showmessage('article_category_empty');
  33. }
  34. $catids = category_get_childids('portal', $catid);
  35. $catids[] = $catid;
  36. } else {
  37. $catids = array_keys($permission);
  38. if (!$allowmanage && !$allowpost && empty($catids)) {
  39. showmessage('portal_nopermission');
  40. }
  41. }
  42. if($_GET['type'] == 'me' || (!$admincp2 && !$allowmanage)) {
  43. $wherearr[] = " uid='$_G[uid]'";
  44. }
  45. if($catids) {
  46. $wherearr[] = " catid IN (".dimplode($catids).")";
  47. }
  48. if($_GET['searchkey']) {
  49. $_GET['searchkey'] = addslashes(stripsearchkey($_GET['searchkey']));
  50. $wherearr[] = "title LIKE '%$_GET[searchkey]%'";
  51. $_GET['searchkey'] = dhtmlspecialchars($_GET['searchkey']);
  52. }
  53. if($_GET['type'] == 'recommended') {
  54. $wherearr[] = "bid != ''";
  55. } elseif($_GET['type'] == 'unrecommend') {
  56. $wherearr[] = "bid = ''";
  57. }
  58. $wheresql = implode(' AND ', $wherearr);
  59. $page = max(1,intval($_GET['page']));
  60. $start = ($page-1)*$perpage;
  61. if($start<0) $start = 0;
  62. $list = array();
  63. $multi = '';
  64. $article_tags = article_tagnames();
  65. $count = C::t('portal_article_title')->fetch_all_by_sql($wheresql, '', 0, 0, 1);
  66. if($count) {
  67. $query = C::t('portal_article_title')->fetch_all_by_sql($wheresql, 'ORDER BY dateline DESC', $start, $perpage);
  68. foreach($query as $value) {
  69. if($value['pic']) $value['pic'] = pic_get($value['pic'], 'portal', $value['thumb'], $value['remote']);
  70. $value['dateline'] = dgmdate($value['dateline']);
  71. $value['allowmanage'] = ($allowmanage || !empty($permission[$value['catid']]['allowmanage'])) ? true : false;
  72. $value['allowpublish'] = ($value['allowmanage'] || $allowpost || !empty($permission[$value['catid']]['allowpublish'])) ? true : false;
  73. $value['taghtml'] = '';
  74. $tags = article_parse_tags($value['tag']);
  75. foreach($tags as $k=>$v) {
  76. if($v) {
  77. $value['taghtml'] .= "[{$article_tags[$k]}] ";
  78. }
  79. }
  80. $style = array();
  81. if($value['highlight']) {
  82. $style = explode('|', $value['highlight']);
  83. $value['highlight'] = ' style="';
  84. $value['highlight'] .= $style[0] ? 'color: '.$style[0].';' : '';
  85. $value['highlight'] .= $style[1] ? 'font-weight: bold;' : '';
  86. $value['highlight'] .= $style[2] ? 'font-style: italic;' : '';
  87. $value['highlight'] .= $style[3] ? 'text-decoration: underline;' : '';
  88. $value['highlight'] .= '"';
  89. }
  90. $list[] = $value;
  91. }
  92. $multi = multi($count, $perpage, $page, $theurl);
  93. $categoryselect = category_showselect('portal', 'catid', false, $catid);
  94. }
  95. include_once template("portal/portalcp_category");
  96. ?>