Manage.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Content\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. private function search($table = 'content/news', $type = false)
  7. {
  8. $keyword = Dever::input('keyword');
  9. $yes = Dever::input('yes');
  10. $where = array();
  11. if ($type) {
  12. $where['type'] = $type;
  13. }
  14. if ($yes) {
  15. $yes = Dever::db($table)->search(array('ids' => $yes));
  16. }
  17. if (!$keyword) {
  18. $where['limit'] = '0,50';
  19. $data = Dever::db($table)->search($where);
  20. } else {
  21. $where['name'] = $keyword;
  22. $data = Dever::db($table)->search($where);
  23. }
  24. $result = array();
  25. if ($yes) {
  26. foreach ($yes as $k => $v) {
  27. if (isset($data[$k])) {
  28. unset($data[$k]);
  29. }
  30. $yes[$k]['selected'] = 'selected';
  31. }
  32. $data = $yes + $data;
  33. $data = array_merge($data, array());
  34. } else {
  35. $data = array_merge($data, array());
  36. }
  37. if (!$data) {
  38. Dever::alert('暂无数据');
  39. }
  40. return $data;
  41. }
  42. # 搜索文章
  43. public function search_news_api()
  44. {
  45. return $this->search('content/news', 1);
  46. }
  47. # 搜索专题
  48. public function search_feature_api()
  49. {
  50. return $this->search('content/news', 2);
  51. }
  52. # 搜索视频
  53. public function search_video_api()
  54. {
  55. return $this->search('content/news', 3);
  56. }
  57. # 搜索活动
  58. public function search_act_api()
  59. {
  60. return $this->search('content/news', 4);
  61. }
  62. # 搜索造物主
  63. public function search_creater_api()
  64. {
  65. return $this->search('content/creater');
  66. }
  67. # 搜索虚拟人
  68. public function search_xuniren_api()
  69. {
  70. return $this->search('content/xuniren');
  71. }
  72. }