Manage.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. $data = Dever::db('push/data')->one($id);
  61. $info = array();
  62. if ($data['type'] > 0) {
  63. $func = Dever::db('push/info')->config['func'];
  64. $func = $func();
  65. $method = false;
  66. if ($func) {
  67. foreach ($func as $k => $v) {
  68. if ($v['id'] == $data['type']) {
  69. $method = $v['api'];
  70. break;
  71. }
  72. }
  73. }
  74. if ($method) {
  75. }
  76. }
  77. $table = array();
  78. $text = $data['data'];
  79. $text = Dever::array_decode($text);
  80. foreach ($text as $k => $v) {
  81. $table[$k] = array();
  82. foreach ($v as $k1 => $v1) {
  83. if (strstr($k1, 'col_')) {
  84. $id = str_replace('col_', '', $k1);
  85. $col = Dever::db('push/col')->one($id);
  86. $table[$k][$col['name']] = $v1;
  87. }
  88. }
  89. }
  90. if (count($table) == 1) {
  91. $table = $table[0];
  92. }
  93. return Dever::table($table);
  94. }
  95. }