block_forumtree.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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: block_forumtree.php 25525 2011-11-14 04:39:11Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('commonblock_html', 'class/block/html');
  12. class block_forumtree extends commonblock_html {
  13. function block_forumtree() {}
  14. function name() {
  15. return lang('blockclass', 'blockclass_html_script_forumtree');
  16. }
  17. function getsetting() {
  18. global $_G;
  19. $settings = array(
  20. 'fids' => array(
  21. 'title' => 'forumtree_fids',
  22. 'type' => 'mselect',
  23. 'value' => array()
  24. ),
  25. );
  26. loadcache('forums');
  27. $settings['fids']['value'][] = array(0, lang('portalcp', 'block_all_forum'));
  28. foreach($_G['cache']['forums'] as $fid => $forum) {
  29. $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')).$forum['name']);
  30. }
  31. return $settings;
  32. }
  33. function getdata($style, $parameter) {
  34. global $_G;
  35. if(!$_G['cache']['forums']) {
  36. loadcache('forums');
  37. }
  38. $forumlist = array();
  39. $parameter['fids'] = (array)$parameter['fids'];
  40. $parameter['fids'] = array_map('intval', $parameter['fids']);
  41. foreach($_G['cache']['forums'] as $forum) {
  42. if(!$forum['status']) {
  43. continue;
  44. }
  45. if(!$parameter['fids'] || in_array(0, $parameter['fids']) || in_array($forum['fid'], $parameter['fids'])) {
  46. $forum['name'] = addslashes($forum['name']);
  47. $forum['type'] != 'group' && $haschild[$forum['fup']] = true;
  48. $forumlist[] = $forum;
  49. }
  50. }
  51. include template('common/block_forumtree');
  52. return array('html' => $return, 'data' => null);
  53. }
  54. }
  55. ?>