adv_article.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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: adv_article.php 13141 2010-07-22 00:56:42Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class adv_article {
  12. var $version = '1.0';
  13. var $name = 'article_name';
  14. var $description = 'article_desc';
  15. var $copyright = '<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>';
  16. var $targets = array('portal');
  17. var $imagesizes = array('250x60', '250x250', '250x300', '658x40', '658x60');
  18. var $categoryvalue = array();
  19. function getsetting() {
  20. global $_G;
  21. $settings = array(
  22. 'position' => array(
  23. 'title' => 'article_position',
  24. 'type' => 'mradio',
  25. 'value' => array(
  26. array(1, 'article_position_float'),
  27. array(2, 'article_position_up'),
  28. array(3, 'article_position_down'),
  29. ),
  30. 'default' => 1,
  31. ),
  32. 'category' => array(
  33. 'title' => 'article_category',
  34. 'type' => 'mselect',
  35. 'value' => array(),
  36. ),
  37. );
  38. loadcache('portalcategory');
  39. $this->getcategory(0);
  40. $settings['category']['value'] = $this->categoryvalue;
  41. return $settings;
  42. }
  43. function getcategory($upid) {
  44. global $_G;
  45. foreach($_G['cache']['portalcategory'] as $category) {
  46. if($category['upid'] == $upid) {
  47. $this->categoryvalue[] = array($category['catid'], str_repeat('&nbsp;', $category['level'] * 4).$category['catname']);
  48. $this->getcategory($category['catid']);
  49. }
  50. }
  51. }
  52. function setsetting(&$advnew, &$parameters) {
  53. global $_G;
  54. if(is_array($advnew['targets'])) {
  55. $advnew['targets'] = implode("\t", $advnew['targets']);
  56. }
  57. if(is_array($parameters['extra']['category']) && in_array(0, $parameters['extra']['category'])) {
  58. $parameters['extra']['category'] = array();
  59. }
  60. }
  61. function evalcode() {
  62. return array(
  63. 'check' => '
  64. $checked = $params[2] == $parameter[\'position\'] && (!$parameter[\'category\'] || $parameter[\'category\'] && in_array($_G[\'catid\'], $parameter[\'category\']));
  65. ',
  66. 'create' => '$adcode = $codes[$adids[array_rand($adids)]];',
  67. );
  68. }
  69. }
  70. ?>