/Quản lý website tin tức PHP/discuznews/source/include/collection/collection_view.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien · PHP · 129 lines · 99 code · 24 blank · 6 comment · 22 complexity · bf7767b0ace1192fadabf188fc2c9271 MD5 · raw file

  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: collection_view.php 29503 2012-04-17 03:11:41Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $oplist = array('comment', 'followers', 'related');
  12. if(!in_array($op, $oplist)) {
  13. $op = '';
  14. }
  15. $fromoplist = array('my', 'all');
  16. $fromop = (!in_array($_GET['fromop'], $fromoplist)) ? '' : $_GET['fromop'];
  17. $fromtid = dintval($_GET['fromtid']);
  18. $tids = $fids = array();
  19. if(!$_G['collection']['ctid']) {
  20. showmessage('collection_permission_deny');
  21. }
  22. $navtitle = $_G['collection']['name'].' - '.lang('core', 'title_collection');
  23. $permission = checkcollectionperm($_G['collection'], $_G['uid']);
  24. $avgrate = number_format($_G['collection']['rate'], 1);
  25. require_once libfile('function/discuzcode');
  26. $_G['collection']['desc'] = discuzcode($_G['collection']['desc']);
  27. $start = ($page-1)*$tpp;
  28. $collectionfollowdata = C::t('forum_collectionfollow')->fetch_by_ctid_uid($ctid, $_G['uid']);
  29. $collectionteamworker = C::t('forum_collectionteamworker')->fetch_all_by_ctid($_G['collection']['ctid']);
  30. $_G['collection']['arraykeyword'] = parse_keyword($_G['collection']['keyword'], false, false);
  31. if($_G['collection']['arraykeyword']) {
  32. foreach ($_G['collection']['arraykeyword'] as $kid=>$s_keyword) {
  33. $metakeywords .= ($metakeywords ? ',' : '').$s_keyword;
  34. $_G['collection']['urlkeyword'][$kid] = rawurlencode($s_keyword);
  35. }
  36. }
  37. $metadescription = $_G['collection']['name'];
  38. if($_G['collection']['ratenum']) {
  39. $star = imgdisplayrate($avgrate);
  40. }
  41. if(!$op || $op == 'related') {
  42. $isteamworkers = in_array($_G['uid'], array_keys($collectionteamworker));
  43. $cloud_apps = (array)unserialize($_G['setting']['cloud_apps']);
  44. $search_status = $cloud_apps['search']['status'] == 'normal' ? TRUE : FALSE;
  45. if(!$op && $op != 'related') {
  46. if($_G['collection']['uid'] == $_G['uid']) {
  47. $lastvisit = $_G['collection']['lastvisit'];
  48. if($_G['collection']['lastupdate'] >= $lastvisit) {
  49. C::t('forum_collection')->update($ctid, array('lastvisit' => TIMESTAMP), true, true);
  50. }
  51. } elseif($isteamworkers) {
  52. $lastvisit = $collectionteamworker[$_G['uid']]['lastvisit'];
  53. if($_G['collection']['lastupdate'] >= $lastvisit) {
  54. C::t('forum_collectionteamworker')->update($ctid, $_G['uid'], array('lastvisit' => TIMESTAMP), true, true);
  55. }
  56. } elseif($collectionfollowdata['ctid']) {
  57. $lastvisit = $collectionfollowdata['lastvisit'];
  58. if($_G['collection']['lastupdate'] >= $lastvisit) {
  59. C::t('forum_collectionfollow')->update($ctid, $_G['uid'], array('lastvisit' => TIMESTAMP), true, true);
  60. }
  61. } else {
  62. $lastvisit = null;
  63. }
  64. $collectiontids = C::t('forum_collectionthread')->fetch_all_by_ctid($_G['collection']['ctid'], $start, $tpp);
  65. $tids = array_keys($collectiontids);
  66. $threadlist = C::t('forum_thread')->fetch_all_by_tid($tids);
  67. collectionThread($threadlist, false, $lastvisit, $collectiontids);
  68. $multipage = multi($_G['collection']['threadnum'], $tpp, $page, "forum.php?mod=collection&action=view&ctid={$_G['collection']['ctid']}");
  69. }
  70. if($_G['collection']['commentnum'] > 0) {
  71. require_once libfile('function/discuzcode');
  72. $commentlist = C::t('forum_collectioncomment')->fetch_all_by_ctid($_G['collection']['ctid'], 0, 5);
  73. foreach($commentlist as &$curvalue) {
  74. $curvalue['dateline'] = dgmdate($curvalue['dateline'], 'u', '9999', getglobal('setting/dateformat'));
  75. $curvalue['message'] = cutstr(strip_tags(discuzcode($curvalue['message'])), 50);
  76. $curvalue['rateimg'] = imgdisplayrate($curvalue['rate']);
  77. }
  78. $memberrate = C::t('forum_collectioncomment')->fetch_rate_by_ctid_uid($_G['collection']['ctid'], $_G['uid']);
  79. }
  80. $followers = C::t('forum_collectionfollow')->fetch_all($ctid, true, 0, 6);
  81. include template('forum/collection_view');
  82. } elseif($op == 'comment') {
  83. $navtitle = lang('core', 'title_collection_comment_list').' - '.$navtitle;
  84. if($_G['collection']['commentnum'] > 0) {
  85. require_once libfile('function/discuzcode');
  86. $start = ($page-1)*$_G['setting']['postperpage'];
  87. $commentlist = C::t('forum_collectioncomment')->fetch_all_by_ctid($_G['collection']['ctid'], $start, $_G['setting']['postperpage']);
  88. foreach($commentlist as &$curvalue) {
  89. $curvalue['dateline'] = dgmdate($curvalue['dateline'], 'u', '9999', getglobal('setting/dateformat'));
  90. $curvalue['message'] = discuzcode($curvalue['message']);
  91. $curvalue['rateimg'] = imgdisplayrate($curvalue['rate']);
  92. }
  93. $multipage = multi($_G['collection']['commentnum'], $_G['setting']['postperpage'], $page, "forum.php?mod=collection&action=view&op=comment&ctid={$_G['collection']['ctid']}");
  94. $memberrate = C::t('forum_collectioncomment')->fetch_rate_by_ctid_uid($_G['collection']['ctid'], $_G['uid']);
  95. }
  96. include template('forum/collection_comment');
  97. } elseif($op == 'followers') {
  98. $navtitle = lang('core', 'title_collection_followers_list').' - '.$navtitle;
  99. $cmemberperpage = 28;
  100. $start = ($page-1)*$cmemberperpage;
  101. $followers = C::t('forum_collectionfollow')->fetch_all($ctid, true, $start, $cmemberperpage);
  102. $multipage = multi($_G['collection']['follownum'], $cmemberperpage, $page, "forum.php?mod=collection&action=view&op=followers&ctid={$_G['collection']['ctid']}");
  103. include template('forum/collection_followers');
  104. }
  105. ?>