block_album.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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_album.php 25525 2011-11-14 04:39:11Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class block_album extends discuz_block {
  12. var $setting = array();
  13. function block_album() {
  14. $this->setting = array(
  15. 'aids' => array(
  16. 'title' => 'albumlist_aids',
  17. 'type' => 'text',
  18. 'value' => ''
  19. ),
  20. 'uids' => array(
  21. 'title' => 'albumlist_uids',
  22. 'type' => 'text',
  23. 'value' => ''
  24. ),
  25. 'catid' => array(
  26. 'title' => 'albumlist_catid',
  27. 'type' => 'mselect',
  28. ),
  29. 'orderby' => array(
  30. 'title' => 'albumlist_orderby',
  31. 'type' => 'mradio',
  32. 'value' => array(
  33. array('dateline', 'albumlist_orderby_dateline'),
  34. array('updatetime', 'albumlist_orderby_updatetime'),
  35. array('picnum', 'albumlist_orderby_picnum'),
  36. ),
  37. 'default' => 'dateline'
  38. ),
  39. 'titlelength' => array(
  40. 'title' => 'albumlist_titlelength',
  41. 'type' => 'text',
  42. 'default' => 40
  43. ),
  44. 'startrow' => array(
  45. 'title' => 'albumlist_startrow',
  46. 'type' => 'text',
  47. 'default' => 0
  48. ),
  49. );
  50. }
  51. function name() {
  52. return lang('blockclass', 'blockclass_album_script_album');
  53. }
  54. function blockclass() {
  55. return array('album', lang('blockclass', 'blockclass_space_album'));
  56. }
  57. function fields() {
  58. return array(
  59. 'id' => array('name' => lang('blockclass', 'blockclass_field_id'), 'formtype' => 'text', 'datatype' => 'int'),
  60. 'url' => array('name' => lang('blockclass', 'blockclass_album_field_url'), 'formtype' => 'text', 'datatype' => 'string'),
  61. 'title' => array('name' => lang('blockclass', 'blockclass_album_field_title'), 'formtype' => 'title', 'datatype' => 'title'),
  62. 'pic' => array('name' => lang('blockclass', 'blockclass_album_field_pic'), 'formtype' => 'pic', 'datatype' => 'pic'),
  63. 'uid' => array('name' => lang('blockclass', 'blockclass_album_field_uid'), 'formtype' => 'text', 'datatype' => 'int'),
  64. 'username' => array('name' => lang('blockclass', 'blockclass_album_field_username'), 'formtype' => 'text', 'datatype' => 'string'),
  65. 'dateline' => array('name' => lang('blockclass', 'blockclass_album_field_dateline'), 'formtype' => 'date', 'datatype' => 'date'),
  66. 'updatetime' => array('name' => lang('blockclass', 'blockclass_album_field_updatetime'), 'formtype' => 'date', 'datatype' => 'date'),
  67. 'picnum' => array('name' => lang('blockclass', 'blockclass_album_field_picnum'), 'formtype' => 'text', 'datatype' => 'int'),
  68. );
  69. }
  70. function getsetting() {
  71. global $_G;
  72. $settings = $this->setting;
  73. if($settings['catid']) {
  74. $settings['catid']['value'][] = array(0, lang('portalcp', 'block_all_category'));
  75. loadcache('albumcategory');
  76. foreach($_G['cache']['albumcategory'] as $value) {
  77. if($value['level'] == 0) {
  78. $settings['catid']['value'][] = array($value['catid'], $value['catname']);
  79. if($value['children']) {
  80. foreach($value['children'] as $catid2) {
  81. $value2 = $_G['cache']['albumcategory'][$catid2];
  82. $settings['catid']['value'][] = array($value2['catid'], '-- '.$value2['catname']);
  83. if($value2['children']) {
  84. foreach($value2['children'] as $catid3) {
  85. $value3 = $_G['cache']['albumcategory'][$catid3];
  86. $settings['catid']['value'][] = array($value3['catid'], '---- '.$value3['catname']);
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. return $settings;
  95. }
  96. function getdata($style, $parameter) {
  97. global $_G;
  98. $parameter = $this->cookparameter($parameter);
  99. $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
  100. $aids = !empty($parameter['aids']) ? explode(',', $parameter['aids']) : array();
  101. $catid = !empty($parameter['catid']) ? $parameter['catid'] : array();
  102. $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
  103. $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
  104. $titlelength = isset($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
  105. $orderby = isset($parameter['orderby']) && in_array($parameter['orderby'],array('dateline', 'picnum', 'updatetime')) ? $parameter['orderby'] : 'dateline';
  106. $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
  107. $list = array();
  108. $query = C::t('home_album')->fetch_all_by_block($aids, $bannedids, $uids, $catid, $startrow, $items, $orderby);
  109. foreach($query as $data) {
  110. $list[] = array(
  111. 'id' => $data['albumid'],
  112. 'idtype' => 'albumid',
  113. 'title' => cutstr($data['albumname'], $titlelength, ''),
  114. 'url' => "home.php?mod=space&uid=$data[uid]&do=album&id=$data[albumid]",
  115. 'pic' => 'album/'.$data['pic'],
  116. 'picflag' => $data['picflag'],
  117. 'summary' => '',
  118. 'fields' => array(
  119. 'fulltitle' => $data['albumname'],
  120. 'uid'=>$data['uid'],
  121. 'username'=>$data['username'],
  122. 'dateline'=>$data['dateline'],
  123. 'updatetime'=>$data['updatetime'],
  124. 'picnum'=>$data['picnum'],
  125. )
  126. );
  127. }
  128. return array('html' => '', 'data' => $list);
  129. }
  130. }
  131. ?>