Manage.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Article\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. private function search($table = 'article/info')
  7. {
  8. $keyword = Dever::input('keyword');
  9. $yes = Dever::input('yes');
  10. $where = array();
  11. $cate = Dever::input('cate');
  12. if ($cate) {
  13. $where['cate_id'] = $cate;
  14. }
  15. if ($yes) {
  16. $yes = Dever::db($table)->search(array('ids' => $yes));
  17. }
  18. if (!$keyword) {
  19. $where['limit'] = '0,50';
  20. $data = Dever::db($table)->search($where);
  21. } else {
  22. $where['name'] = $keyword;
  23. $data = Dever::db($table)->search($where);
  24. }
  25. $result = array();
  26. if ($yes) {
  27. foreach ($yes as $k => $v) {
  28. if (isset($data[$k])) {
  29. unset($data[$k]);
  30. }
  31. $yes[$k]['selected'] = 'selected';
  32. }
  33. $data = $yes + $data;
  34. $data = array_merge($data, array());
  35. } else {
  36. $data = array_merge($data, array());
  37. }
  38. if (!$data) {
  39. Dever::alert('暂无数据');
  40. }
  41. return $data;
  42. }
  43. # 搜索文章
  44. public function search_article_api()
  45. {
  46. return $this->search('article/info');
  47. }
  48. }