adv_thread.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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: adv_thread.php 23660 2011-08-02 06:59:11Z maruitao $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class adv_thread {
  12. var $version = '1.0';
  13. var $name = 'thread_name';
  14. var $description = 'thread_desc';
  15. var $copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>';
  16. var $targets = array('forum', 'group');
  17. var $imagesizes = array('120x60', '120x240');
  18. function getsetting() {
  19. global $_G;
  20. $settings = array(
  21. 'fids' => array(
  22. 'title' => 'thread_fids',
  23. 'type' => 'mselect',
  24. 'value' => array(),
  25. ),
  26. 'groups' => array(
  27. 'title' => 'thread_groups',
  28. 'type' => 'mselect',
  29. 'value' => array(),
  30. ),
  31. 'position' => array(
  32. 'title' => 'thread_position',
  33. 'type' => 'mradio',
  34. 'value' => array(
  35. array(2, 'thread_position_top'),
  36. array(3, 'thread_position_right'),
  37. array(1, 'thread_position_bottom'),
  38. ),
  39. 'default' => 1,
  40. ),
  41. 'pnumber' => array(
  42. 'title' => 'thread_pnumber',
  43. 'type' => 'mselect',
  44. 'value' => array(
  45. array(0, 'thread_pnumber_all'),
  46. ),
  47. 'default' => array(0),
  48. ),
  49. );
  50. loadcache(array('forums', 'grouptype'));
  51. $settings['fids']['value'][] = $settings['groups']['value'][] = array(0, '&nbsp;');
  52. if(empty($_G['cache']['forums'])) $_G['cache']['forums'] = array();
  53. foreach($_G['cache']['forums'] as $fid => $forum) {
  54. $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')).$forum['name']);
  55. }
  56. foreach($_G['cache']['grouptype']['first'] as $gid => $group) {
  57. $settings['groups']['value'][] = array($gid, $group['name']);
  58. if($group['secondlist']) {
  59. foreach($group['secondlist'] as $sgid) {
  60. $settings['groups']['value'][] = array($sgid, str_repeat('&nbsp;', 4).$_G['cache']['grouptype']['second'][$sgid]['name']);
  61. }
  62. }
  63. }
  64. for($i = 1;$i <= $_G['ppp'];$i++) {
  65. $settings['pnumber']['value'][$i] = array($i, '> #'.$i);
  66. }
  67. return $settings;
  68. }
  69. function setsetting(&$advnew, &$parameters) {
  70. global $_G;
  71. if(is_array($advnew['targets'])) {
  72. $advnew['targets'] = implode("\t", $advnew['targets']);
  73. }
  74. if(is_array($parameters['extra']['fids']) && in_array(0, $parameters['extra']['fids'])) {
  75. $parameters['extra']['fids'] = array();
  76. }
  77. if(is_array($parameters['extra']['groups']) && in_array(0, $parameters['extra']['groups'])) {
  78. $parameters['extra']['groups'] = array();
  79. }
  80. if(is_array($parameters['extra']['pnumber']) && in_array(0, $parameters['extra']['pnumber'])) {
  81. $parameters['extra']['pnumber'] = array();
  82. }
  83. }
  84. function evalcode($adv) {
  85. return array(
  86. 'check' => '
  87. if($params[2] != $parameter[\'position\']
  88. || $parameter[\'pnumber\'] && !in_array($params[3] + 1, (array)$parameter[\'pnumber\'])
  89. || $_G[\'basescript\'] == \'forum\' && $parameter[\'fids\'] && !in_array($_G[\'fid\'], $parameter[\'fids\'])
  90. || $_G[\'basescript\'] == \'group\' && $parameter[\'groups\'] && !in_array($_G[\'grouptypeid\'], $parameter[\'groups\'])
  91. ) {
  92. $checked = false;
  93. }',
  94. 'create' => '
  95. $adid = $adids[array_rand($adids)];
  96. if($parameters[$adid][\'position\'] == 3) {
  97. $_G[\'thread\'][\'contentmr\'] = $parameters[$adid][\'width\'] ? $parameters[$adid][\'width\'].\'px\' : \'auto\';
  98. $extra = \'style="margin-left:10px;width:\'.$_G[\'thread\'][\'contentmr\'].\'"\';
  99. }
  100. $adcode = $codes[$adid];
  101. ',
  102. );
  103. }
  104. }
  105. ?>