Manage.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. if (strstr($method, '.')) {
  22. $temp = explode('.', $method);
  23. } elseif (strstr($method, '-')) {
  24. $temp = explode('-', $method);
  25. }
  26. $method = $temp[0];
  27. if ($yes) {
  28. $yes = Dever::db($method)->search(array('ids' => $yes));
  29. }
  30. if (!$keyword) {
  31. $where['limit'] = '0,50';
  32. $data = Dever::db($method)->search($where);
  33. } else {
  34. $where['name'] = $keyword;
  35. $data = Dever::db($method)->search($where);
  36. }
  37. $result = array();
  38. if ($yes) {
  39. foreach ($yes as $k => $v) {
  40. if (isset($data[$k])) {
  41. unset($data[$k]);
  42. }
  43. $yes[$k]['selected'] = 'selected';
  44. }
  45. $data = $yes + $data;
  46. $data = array_merge($data, array());
  47. } else {
  48. $data = array_merge($data, array());
  49. }
  50. if (!$data) {
  51. Dever::alert('暂无数据');
  52. }
  53. return $data;
  54. }
  55. # 查看图片
  56. public function pic($pic)
  57. {
  58. $table = array();
  59. $table[0] = '<img src="'.$pic.'" width=“150”/>';
  60. return Dever::table($table);
  61. }
  62. public function show($id)
  63. {
  64. $table = Dever::load('push/lib/data')->getOne($id, 1);
  65. if (count($table) == 1) {
  66. $table = $table[0];
  67. }
  68. return Dever::table($table);
  69. }
  70. }