block_banner.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_banner.php 28625 2012-03-06 09:09:49Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('commonblock_html', 'class/block/html');
  12. class block_banner extends commonblock_html {
  13. function block_banner() {}
  14. function name() {
  15. return lang('blockclass', 'blockclass_html_script_banner');
  16. }
  17. function getsetting() {
  18. global $_G;
  19. $settings = array(
  20. 'pic' => array(
  21. 'title' => 'banner_pic',
  22. 'type' => 'mfile',
  23. 'default' => 'http://'
  24. ),
  25. 'url' => array(
  26. 'title' => 'banner_url',
  27. 'type' => 'text',
  28. 'default' => ''
  29. ),
  30. 'atarget' => array(
  31. 'title' => 'banner_atarget',
  32. 'type' => 'select',
  33. 'value' => array(
  34. array('_blank', 'banner_atarget_blank'),
  35. array('_self', 'banner_atarget_self'),
  36. array('_top', 'banner_atarget_top'),
  37. ),
  38. 'default' => '_blank'
  39. ),
  40. 'width' => array(
  41. 'title' => 'banner_width',
  42. 'type' => 'text',
  43. 'default' => '100%'
  44. ),
  45. 'height' => array(
  46. 'title' => 'banner_height',
  47. 'type' => 'text',
  48. 'default' => ''
  49. ),
  50. 'text' => array(
  51. 'title' => 'banner_text',
  52. 'type' => 'textarea',
  53. 'default' => ''
  54. ),
  55. );
  56. return $settings;
  57. }
  58. function getdata($style, $parameter) {
  59. $parameter = dhtmlspecialchars($this->cookparameter($parameter));
  60. $return = '<img src="'.$parameter['pic'].'"'
  61. .($parameter['width'] ? ' width="'.$parameter['width'].'"' : '')
  62. .($parameter['height'] ? ' height="'.$parameter['height'].'"' : '')
  63. .($parameter['text'] ? ' alt="'.$parameter['text'].'" title="'.$parameter['text'].'"' : '')
  64. .' />';
  65. if($parameter['url']) {
  66. $target = $parameter['atarget'] ? " target=\"$parameter[atarget]\"" : '';
  67. $return = "<a href=\"$parameter[url]\"$target>$return</a>";
  68. }
  69. return array('html' => $return, 'data' => null);
  70. }
  71. }
  72. ?>