space_favorite.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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: space_favorite.php 33832 2013-08-20 03:32:32Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $space = getuserbyuid($_G['uid']);
  12. $page = empty($_GET['page'])?1:intval($_GET['page']);
  13. if($page<1) $page=1;
  14. $id = empty($_GET['id'])?0:intval($_GET['id']);
  15. $perpage = 20;
  16. $_G['disabledwidthauto'] = 0;
  17. $start = ($page-1)*$perpage;
  18. ckstart($start, $perpage);
  19. $idtypes = array('thread'=>'tid', 'forum'=>'fid', 'blog'=>'blogid', 'group'=>'gid', 'album'=>'albumid', 'space'=>'uid', 'article'=>'aid');
  20. $_GET['type'] = isset($idtypes[$_GET['type']]) ? $_GET['type'] : 'all';
  21. $actives[$_GET['type']] = ' class="a"';
  22. $gets = array(
  23. 'mod' => 'space',
  24. 'uid' => $space['uid'],
  25. 'do' => 'favorite',
  26. 'type' => $_GET['type'],
  27. 'from' => $_GET['from']
  28. );
  29. $theurl = 'home.php?'.url_implode($gets);
  30. $wherearr = $list = array();
  31. $favid = empty($_GET['favid'])?0:intval($_GET['favid']);
  32. $idtype = isset($idtypes[$_GET['type']]) ? $idtypes[$_GET['type']] : '';
  33. $count = C::t('home_favorite')->count_by_uid_idtype($_G['uid'], $idtype, $favid);
  34. if($count) {
  35. $icons = array(
  36. 'tid'=>'<img src="static/image/feed/thread.gif" alt="thread" class="t" /> ',
  37. 'fid'=>'<img src="static/image/feed/discuz.gif" alt="forum" class="t" /> ',
  38. 'blogid'=>'<img src="static/image/feed/blog.gif" alt="blog" class="t" /> ',
  39. 'gid'=>'<img src="static/image/feed/group.gif" alt="group" class="t" /> ',
  40. 'uid'=>'<img src="static/image/feed/profile.gif" alt="space" class="t" /> ',
  41. 'albumid'=>'<img src="static/image/feed/album.gif" alt="album" class="t" /> ',
  42. 'aid'=>'<img src="static/image/feed/article.gif" alt="article" class="t" /> ',
  43. );
  44. $articles = array();
  45. foreach(C::t('home_favorite')->fetch_all_by_uid_idtype($_G['uid'], $idtype, $favid, $start,$perpage) as $value) {
  46. $value['icon'] = isset($icons[$value['idtype']]) ? $icons[$value['idtype']] : '';
  47. $value['url'] = makeurl($value['id'], $value['idtype'], $value['spaceuid']);
  48. $value['description'] = !empty($value['description']) ? nl2br($value['description']) : '';
  49. $list[$value['favid']] = $value;
  50. if($value['idtype'] == 'aid') {
  51. $articles[$value['favid']] = $value['id'];
  52. }
  53. }
  54. if(!empty($articles)) {
  55. include_once libfile('function/portal');
  56. $_urls = array();
  57. foreach(C::t('portal_article_title')->fetch_all($articles) as $aid => $article) {
  58. $_urls[$aid] = fetch_article_url($article);
  59. }
  60. foreach ($articles as $favid => $aid) {
  61. $list[$favid]['url'] = $_urls[$aid];
  62. }
  63. }
  64. }
  65. $multi = multi($count, $perpage, $page, $theurl);
  66. dsetcookie('home_diymode', $diymode);
  67. if(!$_GET['type']) {
  68. $_GET['type'] = 'all';
  69. }
  70. if($_GET['type'] == 'group') {
  71. $navtitle = lang('core', 'title_group_favorite', array('gorup' => $_G['setting']['navs'][3]['navname']));
  72. } else {
  73. $navtitle = lang('core', 'title_'.$_GET['type'].'_favorite');
  74. }
  75. include_once template("diy:home/space_favorite");
  76. function makeurl($id, $idtype, $spaceuid=0) {
  77. $url = '';
  78. switch($idtype) {
  79. case 'tid':
  80. $url = 'forum.php?mod=viewthread&tid='.$id;
  81. break;
  82. case 'fid':
  83. $url = 'forum.php?mod=forumdisplay&fid='.$id;
  84. break;
  85. case 'blogid':
  86. $url = 'home.php?mod=space&uid='.$spaceuid.'&do=blog&id='.$id;
  87. break;
  88. case 'gid':
  89. $url = 'forum.php?mod=group&fid='.$id;
  90. break;
  91. case 'uid':
  92. $url = 'home.php?mod=space&uid='.$id;
  93. break;
  94. case 'albumid':
  95. $url = 'home.php?mod=space&uid='.$spaceuid.'&do=album&id='.$id;
  96. break;
  97. case 'aid':
  98. $url = 'portal.php?mod=view&aid='.$id;
  99. break;
  100. }
  101. return $url;
  102. }
  103. ?>