Manage.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace Push\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function search_api()
  7. {
  8. $keyword = Dever::input('keyword');
  9. $yes = Dever::input('yes');
  10. $where = array();
  11. $type = Dever::input('type');
  12. $func = Dever::db('push/info')->config['func'];
  13. $func = $func();
  14. $method = false;
  15. if ($func && $type && isset($func[$type])) {
  16. $method = $func[$type]['api'];
  17. }
  18. if (!$method) {
  19. Dever::alert('暂无数据');
  20. }
  21. $temp = explode('.', $method);
  22. $method = $temp[0];
  23. if ($yes) {
  24. $yes = Dever::db($method)->search(array('ids' => $yes));
  25. }
  26. if (!$keyword) {
  27. $where['limit'] = '0,50';
  28. $data = Dever::db($method)->search($where);
  29. } else {
  30. $where['name'] = $keyword;
  31. $data = Dever::db($method)->search($where);
  32. }
  33. $result = array();
  34. if ($yes) {
  35. foreach ($yes as $k => $v) {
  36. if (isset($data[$k])) {
  37. unset($data[$k]);
  38. }
  39. $yes[$k]['selected'] = 'selected';
  40. }
  41. $data = $yes + $data;
  42. $data = array_merge($data, array());
  43. } else {
  44. $data = array_merge($data, array());
  45. }
  46. if (!$data) {
  47. Dever::alert('暂无数据');
  48. }
  49. return $data;
  50. }
  51. # 查看图片
  52. public function pic($pic)
  53. {
  54. $table = array();
  55. $table[0] = '<img src="'.$pic.'" width=“150”/>';
  56. return Dever::table($table);
  57. }
  58. public function show($id)
  59. {
  60. $table = Dever::load('push/lib/data')->getOne($id, 1);
  61. if (count($table) == 1) {
  62. $table = $table[0];
  63. }
  64. return Dever::table($table);
  65. }
  66. }