processor.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. class NewsModuleProcessor extends WeModuleProcessor {
  8. public function respond() {
  9. global $_W;
  10. $rid = $this->rule;
  11. $commends = table('news_reply')
  12. ->where(array(
  13. 'rid' => $rid,
  14. 'parent_id' => -1
  15. ))
  16. ->orderby(array(
  17. 'displayorder' => 'DESC',
  18. 'id' => 'ASC'
  19. ))
  20. ->limit(8)
  21. ->getall();
  22. if (empty($commends)) {
  23. $main = table('news_reply')
  24. ->where(array(
  25. 'rid' => $rid,
  26. 'parent_id' => 0
  27. ))
  28. ->orderby('RAND()')
  29. ->get();
  30. if (empty($main['id'])) {
  31. return false;
  32. }
  33. $commends = table('news_reply')
  34. ->where(array('id' => $main['id']))
  35. ->whereor(array('parent_id' => $main['id']))
  36. ->orderby(array(
  37. 'parent_id' => 'ASC',
  38. 'displayorder' => 'DESC',
  39. 'id' => 'ASC'
  40. ))
  41. ->getall();
  42. }
  43. if (empty($commends)) {
  44. return false;
  45. }
  46. $news = array();
  47. foreach ($commends as $c) {
  48. $row = array();
  49. $row['title'] = $c['title'];
  50. $row['description'] = $c['description'];
  51. !empty($c['thumb']) && $row['picurl'] = tomedia($c['thumb']);
  52. $row['url'] = empty($c['url']) ? $this->createMobileUrl('detail', array('id' => $c['id'])) : $c['url'];
  53. $news[] = $row;
  54. }
  55. return $this->respNews($news);
  56. }
  57. }