function_portal.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: function_portal.php 33047 2013-04-12 08:46:56Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function category_remake($catid) {
  12. global $_G;
  13. $cat = $_G['cache']['portalcategory'][$catid];
  14. if(empty($cat)) return array();
  15. foreach ($_G['cache']['portalcategory'] as $value) {
  16. if($value['catid'] == $cat['upid']) {
  17. $cat['ups'][$value['catid']] = $value;
  18. $upid = $value['catid'];
  19. while(!empty($upid)) {
  20. if(!empty($_G['cache']['portalcategory'][$upid]['upid'])) {
  21. $upid = $_G['cache']['portalcategory'][$upid]['upid'];
  22. $cat['ups'][$upid] = $_G['cache']['portalcategory'][$upid];
  23. } else {
  24. $upid = 0;
  25. }
  26. }
  27. } elseif($value['upid'] == $cat['catid']) {
  28. $cat['subs'][$value['catid']] = $value;
  29. } elseif($value['upid'] == $cat['upid']) {
  30. $cat['others'][$value['catid']] = $value;
  31. }
  32. }
  33. if(!empty($cat['ups'])) $cat['ups'] = array_reverse($cat['ups'], TRUE);
  34. return $cat;
  35. }
  36. function getportalcategoryurl($catid) {
  37. if(empty($catid)) return '';
  38. loadcache('portalcategory');
  39. $portalcategory = getglobal('cache/portalcategory');
  40. if($portalcategory[$catid]) {
  41. return $portalcategory[$catid]['caturl'];
  42. } else {
  43. return '';
  44. }
  45. }
  46. function fetch_article_url($article) {
  47. global $_G;
  48. if(!empty($_G['setting']['makehtml']['flag']) && $article && $article['htmlmade']) {
  49. if(empty($_G['cache']['portalcategory'])) {
  50. loadcache('portalcategory');
  51. }
  52. $caturl = '';
  53. if(!empty($_G['cache']['portalcategory'][$article['catid']])) {
  54. $topid = $_G['cache']['portalcategory'][$article['catid']]['topid'];
  55. $caturl = $_G['cache']['portalcategory'][$topid]['domain'] ? $_G['cache']['portalcategory'][$topid]['caturl'] : '';
  56. }
  57. return $caturl.$article['htmldir'].$article['htmlname'].'.'.$_G['setting']['makehtml']['extendname'];
  58. } else {
  59. return 'portal.php?mod=view&aid='.$article['aid'];
  60. }
  61. }
  62. function fetch_topic_url($topic) {
  63. global $_G;
  64. if(!empty($_G['setting']['makehtml']['flag']) && $topic && $topic['htmlmade']) {
  65. return $_G['setting']['makehtml']['topichtmldir'].'/'.$topic['name'].'.'.$_G['setting']['makehtml']['extendname'];
  66. } else {
  67. return 'portal.php?mod=topic&topicid='.$topic['topicid'];
  68. }
  69. }
  70. ?>