processor.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. $sql = "SELECT * FROM " . tablename('news_reply') . " WHERE rid = :id AND parent_id = -1 ORDER BY displayorder DESC, id ASC LIMIT 8";
  12. $commends = pdo_fetchall($sql, array(':id' => $rid));
  13. if (empty($commends)) {
  14. $sql = "SELECT * FROM " . tablename('news_reply') . " WHERE rid = :id AND parent_id = 0 ORDER BY RAND()";
  15. $main = pdo_fetch($sql, array(':id' => $rid));
  16. if(empty($main['id'])) {
  17. return false;
  18. }
  19. $sql = "SELECT * FROM " . tablename('news_reply') . " WHERE id = :id OR parent_id = :parent_id ORDER BY parent_id ASC, displayorder DESC, id ASC LIMIT 8";
  20. $commends = pdo_fetchall($sql, array(':id'=>$main['id'], ':parent_id'=>$main['id']));
  21. }
  22. if(empty($commends)) {
  23. return false;
  24. }
  25. $news = array();
  26. foreach($commends as $c) {
  27. $row = array();
  28. $row['title'] = $c['title'];
  29. $row['description'] = $c['description'];
  30. !empty($c['thumb']) && $row['picurl'] = tomedia($c['thumb']);
  31. $row['url'] = empty($c['url']) ? $this->createMobileUrl('detail', array('id' => $c['id'])) : $c['url'];
  32. $news[] = $row;
  33. }
  34. return $this->respNews($news);
  35. }
  36. }