block_friendlink.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_friendlink.php 24531 2011-09-23 05:45:11Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('commonblock_html', 'class/block/html');
  12. class block_friendlink extends commonblock_html {
  13. function block_friendlink() {}
  14. function name() {
  15. return lang('blockclass', 'blockclass_html_script_friendlink');
  16. }
  17. function getsetting() {
  18. global $_G;
  19. $settings = array(
  20. 'content' => array(
  21. 'title' => 'friendlink_content',
  22. 'type' => 'mradio',
  23. 'value' => array(
  24. array('both', 'friendlink_content_both'),
  25. array('logo', 'friendlink_content_logo'),
  26. array('text', 'friendlink_content_text')
  27. ),
  28. 'default' => 'both'
  29. ),
  30. 'type' => array(
  31. 'title' => 'friendlink_type',
  32. 'type' => 'mcheckbox',
  33. 'value' => array(
  34. array('1', 'friendlink_type_group1'),
  35. array('2', 'friendlink_type_group2'),
  36. array('3', 'friendlink_type_group3'),
  37. array('4', 'friendlink_type_group4'),
  38. ),
  39. 'default' => array('1','2','3','4')
  40. )
  41. );
  42. return $settings;
  43. }
  44. function getdata($style, $parameter) {
  45. $type = !empty($parameter['type']) && is_array($parameter) ? $parameter['type'] : array();
  46. $b = '0000';
  47. for($i=1;$i<=4;$i++) {
  48. if(in_array($i, $type)) {
  49. $b[$i-1] = '1';
  50. }
  51. }
  52. $type = intval($b, '2');
  53. $query = C::t('common_friendlink')->fetch_all_by_displayorder($type);
  54. $group1 = $group2 = $group3 = array();
  55. foreach ($query as $value) {
  56. if($parameter['content']=='logo') {
  57. $group2[] = $value;
  58. } elseif($parameter['content']=='text') {
  59. $group3[] = $value;
  60. } else {
  61. if($value['description']) {
  62. $group1[] = $value;
  63. } elseif($value['logo']) {
  64. $group2[] = $value;
  65. } else {
  66. $group3[] = $value;
  67. }
  68. }
  69. }
  70. $return = '<div class="bn lk">';
  71. if($group1) {
  72. $return .= '<ul class="m cl">';
  73. foreach($group1 as $value) {
  74. $return .= '<li class="cl">'
  75. . '<div class="forumlogo"><a target="_blank" href="'.$value['url'].'"><img border="0" alt="'.$value['name'].'" src="'.$value['logo'].'"></a></div>'
  76. . '<div class="forumcontent"><h5><a target="_blank" href="'.$value['url'].'">'.$value['name'].'</a></h5><p>'.$value['description'].'</p></div>'
  77. . '</li>';
  78. }
  79. $return .= '</ul>';
  80. }
  81. if($group2) {
  82. $return .= '<div class="cl mbm">';
  83. foreach($group2 as $value) {
  84. $return .= '<a target="_blank" href="'.$value['url'].'"><img border="0" alt="'.$value['name'].'" src="'.$value['logo'].'"></a>';
  85. }
  86. $return .= '</div>';
  87. }
  88. if($group3) {
  89. $return .= '<ul class="x cl">';
  90. foreach($group3 as $value) {
  91. $return .= '<li><a target="_blank" href="'.$value['url'].'">'.$value['name'].'</a></li>';
  92. }
  93. $return .= '</ul>';
  94. }
  95. $return .= '</div>';
  96. return array('html' => $return, 'data' => null);
  97. }
  98. }
  99. ?>