Manage.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace Page\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function search_api()
  7. {
  8. $type = Dever::input('type');
  9. $func = Dever::db('page/module')->config['func'];
  10. $func = $func();
  11. $method = false;
  12. if ($func && $type && isset($func[$type]['search'])) {
  13. $method = $func[$type]['search'];
  14. }
  15. if (!$method) {
  16. Dever::alert('暂无数据');
  17. }
  18. return Dever::search($method);
  19. }
  20. public function showType_api()
  21. {
  22. $value = Dever::input('value');
  23. $data = array();
  24. $config['type_id'] = Dever::db('page/data')->config['struct']['type_id'];
  25. $config['type_id']['name'] = '关联数据';
  26. if ($value == -1) {
  27. $config['type_id']['update'] = 'hidden';
  28. } else {
  29. $config['type_id']['update'] = 'select';
  30. $config['type_id']['update_search'] = 'page/lib/manage.search?type=' . $value;
  31. $id = Dever::input('id');
  32. if ($id) {
  33. $info = Dever::db('page/data')->find($id);
  34. if ($info && $info['type_id']) {
  35. $config['type_id']['update_search_value'] = $info['type_id'];
  36. }
  37. }
  38. }
  39. $data = Dever::load('manage/database')->update_struct(array('struct' => $config), false, $data, -1, '', false, false);
  40. return $data;
  41. }
  42. # 查看图片
  43. public function pic($pic)
  44. {
  45. $table = array();
  46. return '<img src="'.$pic.'" width=“150”/>';
  47. return Dever::table($table);
  48. }
  49. public function show($id)
  50. {
  51. $table = Dever::load('page/lib/data')->getOne($id, 1);
  52. if (count($table) == 1) {
  53. $table = $table[0];
  54. }
  55. return Dever::table($table);
  56. }
  57. # 查看模板
  58. public function template()
  59. {
  60. $data = Dever::db('page/template')->state();
  61. foreach ($data as $k => $v) {
  62. if (!$v['pic']) {
  63. $v['pic'] = '';
  64. }
  65. $data[$k]['name'] = '<img src="'.$v['pic'].'" style="margin-bottom: 34px;width:300px" alt="'.$v['name'].'"/>';
  66. }
  67. return $data;
  68. }
  69. public function getData($col, $id)
  70. {
  71. $data = Dever::db('page/data')->find($id);
  72. if ($data['type'] > 0 && $data['type_id'] > 0) {
  73. $func = Dever::db('page/func')->find($data['type']);
  74. if ($func['col']) {
  75. $info = Dever::load($func['api'], $data['type_id']);
  76. if ($info) {
  77. $func['col'] = Dever::json_decode($func['col']);
  78. foreach ($func['col'] as $k => $v) {
  79. if ($v['col_id'] == $col) {
  80. return $info[$v['name']];
  81. }
  82. }
  83. }
  84. }
  85. }
  86. return $data['col_' . $col];
  87. }
  88. }