block_announcement.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_announcement.php 25525 2011-11-14 04:39:11Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class block_announcement extends discuz_block {
  12. var $setting = array();
  13. function block_announcement(){
  14. $this->setting = array(
  15. 'type' => array(
  16. 'title' => 'announcement_type',
  17. 'type' => 'mcheckbox',
  18. 'value' => array(
  19. array('0', 'announcement_type_text'),
  20. array('1', 'announcement_type_link'),
  21. ),
  22. 'default' => array('0')
  23. ),
  24. 'titlelength' => array(
  25. 'title' => 'announcement_titlelength',
  26. 'type' => 'text',
  27. 'default' => 40
  28. ),
  29. 'summarylength' => array(
  30. 'title' => 'announcement_summarylength',
  31. 'type' => 'text',
  32. 'default' => 80
  33. ),
  34. 'startrow' => array(
  35. 'title' => 'announcement_startrow',
  36. 'type' => 'text',
  37. 'default' => 0
  38. ),
  39. );
  40. }
  41. function name() {
  42. return lang('blockclass', 'blockclass_announcement_script_announcement');
  43. }
  44. function blockclass() {
  45. return array('announcement', lang('blockclass', 'blockclass_html_announcement'));
  46. }
  47. function fields() {
  48. return array(
  49. 'url' => array('name' => lang('blockclass', 'blockclass_announcement_field_url'), 'formtype' => 'text', 'datatype' => 'string'),
  50. 'title' => array('name' => lang('blockclass', 'blockclass_announcement_field_title'), 'formtype' => 'title', 'datatype' => 'title'),
  51. 'summary' => array('name' => lang('blockclass', 'blockclass_announcement_field_summary'), 'formtype' => 'summary', 'datatype' => 'summary'),
  52. 'starttime' => array('name' => lang('blockclass', 'blockclass_announcement_field_starttime'), 'formtype' => 'text', 'datatype' => 'date'),
  53. 'endtime' => array('name' => lang('blockclass', 'blockclass_announcement_field_endtime'), 'formtype' => 'text', 'datatype' => 'date'),
  54. );
  55. }
  56. function getsetting() {
  57. global $_G;
  58. $settings = $this->setting;
  59. return $settings;
  60. }
  61. function getdata($style, $parameter) {
  62. global $_G;
  63. $type = !empty($parameter['type']) && is_array($parameter['type']) ? array_map('intval', $parameter['type']) : array('0');
  64. $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
  65. $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
  66. $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : '0';
  67. $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
  68. $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
  69. $time = TIMESTAMP;
  70. $list = array();
  71. foreach(C::t('forum_announcement')->fetch_all_by_time($time, $type, $bannedids, $startrow, $items) as $data) {
  72. $list[] = array(
  73. 'id' => $data['id'],
  74. 'idtype' => 'announcementid',
  75. 'title' => cutstr(str_replace('\\\'', '&#39;', strip_tags($data['subject'])), $titlelength, ''),
  76. 'url' => $data['type']=='1' ? $data['message'] : 'forum.php?mod=announcement&id='.$data['id'],
  77. 'pic' => '',
  78. 'picflag' => '',
  79. 'summary' => cutstr(str_replace('\\\'', '&#39;', $data['message']), $summarylength, ''),
  80. 'fields' => array(
  81. 'starttime' => $data['starttime'],
  82. 'endtime' => $data['endtime'],
  83. )
  84. );
  85. }
  86. return array('html' => '', 'data' => $list);
  87. }
  88. }
  89. ?>