Manage.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Content\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. private function search($table = 'content/news')
  7. {
  8. $keyword = Dever::input('keyword');
  9. $yes = Dever::input('yes');
  10. $where = array();
  11. $cate = Dever::input('cate');
  12. if ($cate) {
  13. $where['cate_id'] = $cate;
  14. }
  15. if ($yes) {
  16. $yes = Dever::db($table)->search(array('ids' => $yes));
  17. }
  18. if (!$keyword) {
  19. $where['limit'] = '0,50';
  20. $data = Dever::db($table)->search($where);
  21. } else {
  22. $where['name'] = $keyword;
  23. $data = Dever::db($table)->search($where);
  24. }
  25. $result = array();
  26. if ($yes) {
  27. foreach ($yes as $k => $v) {
  28. if (isset($data[$k])) {
  29. unset($data[$k]);
  30. }
  31. $yes[$k]['selected'] = 'selected';
  32. }
  33. $data = $yes + $data;
  34. $data = array_merge($data, array());
  35. } else {
  36. $data = array_merge($data, array());
  37. }
  38. if (!$data) {
  39. Dever::alert('暂无数据');
  40. }
  41. return $data;
  42. }
  43. # 搜索文章
  44. public function search_news_api()
  45. {
  46. return $this->search('content/news');
  47. }
  48. # 查看图片
  49. public function pic($pic)
  50. {
  51. if ($pic) {
  52. $pic = Dever::pic($pic);
  53. $pic = Dever::load('upload/view')->get($pic, 't', 1);
  54. $table = array();
  55. $table[0] = '<img src="'.$pic.'" width="150"/>';
  56. return Dever::table($table);
  57. } else {
  58. return '';
  59. }
  60. }
  61. public function picGrid($text)
  62. {
  63. $table = array();
  64. $text = Dever::array_decode($text);
  65. $table[0] = '';
  66. foreach ($text as $k => $v) {
  67. if ($v['pic']) {
  68. $table[0] .= '<img src="'.$v['pic'].'" width="150"/>&nbsp;&nbsp;';
  69. }
  70. }
  71. return Dever::table($table);
  72. }
  73. }