adv_articlelist.php 2.1 KB

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