block_myapp.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_myapp.php 28626 2012-03-06 09:10:25Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class block_myapp extends discuz_block{
  12. var $setting = array();
  13. function block_myapp(){
  14. $this->setting = array(
  15. 'titlelength' => array(
  16. 'title' => 'myapp_titlelength',
  17. 'type' => 'text',
  18. 'default' => 40
  19. ),
  20. 'startrow' => array(
  21. 'title' => 'myapp_startrow',
  22. 'type' => 'text',
  23. 'default' => 0
  24. ),
  25. );
  26. }
  27. function name() {
  28. return lang('blockclass', 'blockclass_myapp_script_myapp');
  29. }
  30. function blockclass() {
  31. return array('myapp', lang('blockclass', 'blockclass_html_myapp'));
  32. }
  33. function fields() {
  34. return array(
  35. 'url' => array('name' => lang('blockclass', 'blockclass_myapp_field_url'), 'formtype' => 'text', 'datatype' => 'string'),
  36. 'title' => array('name' => lang('blockclass', 'blockclass_myapp_field_title'), 'formtype' => 'title', 'datatype' => 'title'),
  37. 'icon' => array('name' => lang('blockclass', 'blockclass_myapp_field_icon'), 'formtype' => 'text', 'datatype' => 'string'),
  38. 'icon_small' => array('name' => lang('blockclass', 'blockclass_myapp_field_icon_small'), 'formtype' => 'text', 'datatype' => 'string'),
  39. 'icon_abouts' => array('name' => lang('blockclass', 'blockclass_myapp_field_icon_abouts'), 'formtype' => 'text', 'datatype' => 'string'),
  40. );
  41. }
  42. function getsetting() {
  43. global $_G;
  44. $settings = $this->setting;
  45. return $settings;
  46. }
  47. function getdata($style, $parameter) {
  48. global $_G;
  49. $parameter = $this->cookparameter($parameter);
  50. $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
  51. $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : '0';
  52. $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
  53. $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
  54. $bansql = $bannedids ? ' AND appid NOT IN ('.dimplode($bannedids).')' : '';
  55. $sql = 'SELECT * FROM '.DB::table('common_myapp')." WHERE flag>=0 $bansql ORDER BY flag DESC, displayorder LIMIT $startrow, $items";
  56. $query = DB::query($sql);
  57. while($data = DB::fetch($query)) {
  58. $list[] = array(
  59. 'id' => $data['appid'],
  60. 'idtype' => 'appid',
  61. 'title' => cutstr(str_replace('\\\'', '&#39;', $data['appname']), $titlelength, ''),
  62. 'url' => 'userapp.php?id='.$data['appid'],
  63. 'pic' => '',
  64. 'picflag' => '',
  65. 'summary' => '',
  66. 'fields' => array(
  67. 'icon' => 'http://appicon.manyou.com/logos/'.$data['appid'],
  68. 'icon_small' => 'http://appicon.manyou.com/icons/'.$data['appid'],
  69. 'icon_abouts' => 'http://appicon.manyou.com/abouts/'.$data['appid'],
  70. )
  71. );
  72. }
  73. return array('html' => '', 'data' => $list);
  74. }
  75. }
  76. ?>