Manage.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. namespace Journal\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. private function search($table = 'content/article')
  7. {
  8. $keyword = Dever::input('keyword');
  9. $yes = Dever::input('yes');
  10. $where = array();
  11. if ($yes) {
  12. $yes = Dever::db($table)->search(array('ids' => $yes));
  13. }
  14. if (!$keyword) {
  15. $where['limit'] = '0,50';
  16. $data = Dever::db($table)->search($where);
  17. } else {
  18. $where['name'] = $keyword;
  19. $data = Dever::db($table)->search($where);
  20. }
  21. $result = array();
  22. if ($yes) {
  23. foreach ($yes as $k => $v) {
  24. if (isset($data[$k])) {
  25. unset($data[$k]);
  26. }
  27. $yes[$k]['selected'] = 'selected';
  28. }
  29. $data = $yes + $data;
  30. $data = array_merge($data, array());
  31. }
  32. if (!$data) {
  33. Dever::alert('暂无数据');
  34. }
  35. return $data;
  36. }
  37. # 搜索文章
  38. public function search_article_api()
  39. {
  40. return $this->search('content/article');
  41. }
  42. # 搜索视频
  43. public function search_vod_api()
  44. {
  45. return $this->search('video/vod');
  46. }
  47. # 搜索直播
  48. public function search_live_api()
  49. {
  50. return $this->search('video/live');
  51. }
  52. # 搜索小刊
  53. public function search_journal_api()
  54. {
  55. return $this->search('journal/info');
  56. }
  57. # 显示杂志内页
  58. public function journalContent()
  59. {
  60. $where['info_id'] = Dever::input('search_option_info_id');
  61. $where['state'] = Dever::input('search_option_state');
  62. $data = Dever::db('journal/content')->all($where);
  63. $database = Dever::load('manage/database');
  64. $type = Dever::db('journal/content')->config['gettype'];
  65. if ($data) {
  66. foreach ($data as $k => $v) {
  67. $data[$k]['height'] = 'height: 154px;';
  68. $data[$k]['info_height'] = 'height: auto;';
  69. if ($v['type'] > 2) {
  70. $data[$k]['height'] = 'height: 104px;';
  71. $data[$k]['info_height'] = 'height: 47px;';
  72. }
  73. if ($v['type'] <= 2) {
  74. $data[$k]['name'] = '';
  75. } elseif ($v['type'] == 3) {
  76. $data[$k]['pic'] = $v['focus'];
  77. }
  78. if ($v['type'] == 11) {
  79. # 图文
  80. $info = Dever::load('content/lib/article')->get($v['article_id']);
  81. if ($info) {
  82. $data[$k]['pic'] = $info['pic_cover'];
  83. $data[$k]['name'] = $info['name'];
  84. }
  85. } elseif ($v['type'] == 12) {
  86. # 视频
  87. $info = Dever::load('video/lib/vod')->get($v['vod_id']);
  88. if ($info) {
  89. $data[$k]['pic'] = $info['pic_cover'];
  90. $data[$k]['name'] = $info['name'];
  91. }
  92. } elseif ($v['type'] == 13) {
  93. # 直播
  94. $info = Dever::load('video/lib/live')->get($v['live_id']);
  95. if ($info) {
  96. $data[$k]['pic'] = $info['pic_cover'];
  97. $data[$k]['name'] = $info['name'];
  98. }
  99. }
  100. $data[$k]['typename'] = $type[$v['type']];
  101. /*
  102. if ($v['type'] == 1) {
  103. $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
  104. } else {
  105. $data[$k]['text'] = '';
  106. }
  107. */
  108. $data[$k]['text'] = '';
  109. $link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
  110. $data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑内页', '', 1)";
  111. $data[$k]['editurl'] = $link;
  112. $data[$k]['delete'] = $database->url('delete', $v['id']);
  113. }
  114. }
  115. return $data;
  116. }
  117. private function text_name($link, $content_id, $info_id, $location, $name)
  118. {
  119. $where['info_id'] = $info_id;
  120. $where['content_id'] = $content_id;
  121. $where['location'] = $location;
  122. $info = Dever::db('journal/content_text')->one($where);
  123. $link .= '&search_option_info_id=' . $info_id. '&search_option_content_id=' . $content_id.'&table=content_text&search_option_location='.$location;
  124. if ($info) {
  125. $link .= '&where_id=' . $info['id'];
  126. }
  127. $html = '<a style="cursor:pointer;" href="javascript:;" onclick="fastEdit($(this), \''.$link.'\', \'编辑'.$name.'文字\', \'\')">'.$name.'</a>';
  128. return $html;
  129. }
  130. public function text($database, $content_id, $info_id)
  131. {
  132. $link = $database->url('edit');
  133. $location = Dever::db('journal/content_text')->config['location'];
  134. $html = '<table class="layui-table"><tbody><tr>';
  135. $i = 0;
  136. foreach ($location as $k => $v) {
  137. $name = $this->text_name($link, $content_id, $info_id, $k, $v);
  138. $html .= '<td>'.$name.'</td>';
  139. if ($i == 2 || $i == 5) {
  140. $html .= '</tr><tr>';
  141. }
  142. $i++;
  143. }
  144. $html .= '</tr></tbody></table>';
  145. return $html;
  146. }
  147. public function updateJournalContent_api()
  148. {
  149. $data = Dever::input('data');
  150. if ($data) {
  151. $data = explode(',', str_replace('data-', '', $data));
  152. foreach ($data as $k => $v) {
  153. $k = $k + 1;
  154. $where['where_id'] = $v;
  155. $where['reorder'] = $k;
  156. Dever::db('journal/content')->update($where);
  157. }
  158. }
  159. return $data;
  160. }
  161. }