block_otherfriendlink.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_otherfriendlink.php 25525 2011-11-14 04:39:11Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class block_otherfriendlink extends discuz_block {
  12. var $setting = array();
  13. function block_otherfriendlink() {
  14. $this->setting = array(
  15. 'type' => array(
  16. 'title' => 'friendlink_type',
  17. 'type' => 'mcheckbox',
  18. 'value' => array(
  19. array('1', 'friendlink_type_group1'),
  20. array('2', 'friendlink_type_group2'),
  21. array('3', 'friendlink_type_group3'),
  22. array('4', 'friendlink_type_group4'),
  23. ),
  24. 'default' => array('1','2','3','4')
  25. ),
  26. 'titlelength' => array(
  27. 'title' => 'friendlink_titlelength',
  28. 'type' => 'text',
  29. 'default' => 40
  30. ),
  31. 'summarylength' => array(
  32. 'title' => 'friendlink_summarylength',
  33. 'type' => 'text',
  34. 'default' => 80
  35. ),
  36. );
  37. }
  38. function name() {
  39. return lang('blockclass', 'blockclass_other_script_friendlink');
  40. }
  41. function blockclass() {
  42. return array('otherfriendlink', lang('blockclass', 'blockclass_other_friendlink'));
  43. }
  44. function fields() {
  45. return array(
  46. 'url' => array('name' => lang('blockclass', 'blockclass_other_friendlink_field_url'), 'formtype' => 'text', 'datatype' => 'string'),
  47. 'title' => array('name' => lang('blockclass', 'blockclass_other_friendlink_field_title'), 'formtype' => 'title', 'datatype' => 'title'),
  48. 'pic' => array('name' => lang('blockclass', 'blockclass_other_friendlink_field_pic'), 'formtype' => 'pic', 'datatype' => 'pic'),
  49. 'summary' => array('name' => lang('blockclass', 'blockclass_other_friendlink_field_summary'), 'formtype' => 'summary', 'datatype' => 'summary'),
  50. );
  51. }
  52. function getsetting() {
  53. return $this->setting;
  54. }
  55. function getdata($style, $parameter) {
  56. $parameter = $this->cookparameter($parameter);
  57. $titlelength = isset($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
  58. $summarylength = isset($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
  59. $type = !empty($parameter['type']) && is_array($parameter['type']) ? $parameter['type'] : array();
  60. $b = '0000';
  61. for($i=1;$i<=4;$i++) {
  62. if(in_array($i, $type)) {
  63. $b[$i-1] = '1';
  64. }
  65. }
  66. $type = intval($b, '2');
  67. $list = array();
  68. $query = C::t('common_friendlink')->fetch_all_by_displayorder($type);
  69. foreach ($query as $data) {
  70. $list[] = array(
  71. 'id' => $data['id'],
  72. 'idtype' => 'flid',
  73. 'title' => cutstr($data['name'], $titlelength),
  74. 'url' => $data['url'],
  75. 'pic' => $data['logo'] ? $data['logo'] : $_G['style']['imgdir'].'/nophoto.gif',
  76. 'picflag' => '0',
  77. 'summary' => $data['description'],
  78. 'fields' => array(
  79. 'fulltitle' => $data['name'],
  80. )
  81. );
  82. }
  83. return array('html' => '', 'data' => $list);
  84. }
  85. }
  86. ?>