Archives.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <?php
  2. namespace app\admin\controller\cms;
  3. use addons\cms\library\FulltextSearch;
  4. use app\admin\model\cms\Channel;
  5. use app\admin\model\cms\ChannelAdmin;
  6. use app\admin\model\cms\Modelx;
  7. use app\common\controller\Backend;
  8. use app\common\model\User;
  9. use fast\Tree;
  10. use think\Db;
  11. use think\db\Query;
  12. use think\Hook;
  13. /**
  14. * 内容表
  15. *
  16. * @icon fa fa-file-text-o
  17. */
  18. class Archives extends Backend
  19. {
  20. /**
  21. * Archives模型对象
  22. */
  23. protected $model = null;
  24. protected $noNeedRight = ['get_fields_html', 'check_element_available', 'suggestion', 'copy', 'special', 'tags', 'move', 'flag'];
  25. protected $channelIds = [];
  26. protected $isSuperAdmin = false;
  27. protected $searchFields = 'id,title';
  28. public function _initialize()
  29. {
  30. parent::_initialize();
  31. $this->model = new \app\admin\model\cms\Archives;
  32. $config = get_addon_config('cms');
  33. if ($config['archivesdatalimit'] != 'all') {
  34. $this->dataLimit = $config['archivesdatalimit'];
  35. }
  36. //复制/加入专题/修改标签均检测编辑权限
  37. if (in_array($this->request->action(), ['copy', 'special', 'tags', 'move', 'flag']) && !$this->auth->check('cms/archives/edit')) {
  38. Hook::listen('admin_nopermission', $this);
  39. $this->error(__('You have no permission'), '');
  40. }
  41. //是否超级管理员
  42. $this->isSuperAdmin = $this->auth->isSuperAdmin();
  43. $channelList = [];
  44. $disabledIds = [];
  45. $all = collection(Channel::order("weigh desc,id desc")->select())->toArray();
  46. //允许的栏目
  47. $this->channelIds = $this->isSuperAdmin || !$config['channelallocate'] ? Channel::column('id') : ChannelAdmin::getAdminChanneIds();
  48. $parentChannelIds = Channel::where('id', 'in', $this->channelIds)->column('parent_id');
  49. $parentChannelIds = array_unique($parentChannelIds);
  50. $parentChannelList = \think\Db::name('cms_channel')->where('id', 'in', $parentChannelIds)->where('parent_id', '<>', 0)->field('id,parent_id,name')->select();
  51. $tree = Tree::instance()->init($all, 'parent_id');
  52. foreach ($parentChannelList as $index => $channel) {
  53. $parentChannelIds = array_merge($parentChannelIds, $tree->getParentsIds($channel['parent_id'], true));
  54. }
  55. $this->channelIds = array_merge($parentChannelIds, $this->channelIds);
  56. foreach ($all as $k => $v) {
  57. $state = ['opened' => true];
  58. // if ($v['type'] == 'link') {
  59. // $disabledIds[] = $v['id'];
  60. // }
  61. if ($v['type'] == 'link') {
  62. $state['checkbox_disabled'] = true;
  63. }
  64. if (!$this->isSuperAdmin) {
  65. if (!in_array($v['id'], $parentChannelIds) && !in_array($v['id'], $this->channelIds)) {
  66. unset($all[$k]);
  67. continue;
  68. }
  69. }
  70. $channelList[] = [
  71. 'id' => $v['id'],
  72. 'parent' => $v['parent_id'] ? $v['parent_id'] : '#',
  73. 'text' => __($v['name']),
  74. 'type' => $v['type'],
  75. 'state' => $state
  76. ];
  77. }
  78. $tree = Tree::instance()->init($all, 'parent_id');
  79. $channelOptions = $tree->getTree(0, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", '', $disabledIds);
  80. $secondChannelOptions = $tree->getTree(0, "<option model='@model_id' value=@id disabled>@spacer@name</option>", '', $disabledIds);
  81. $this->view->assign('channelOptions', $channelOptions);
  82. $this->view->assign('secondChannelOptions', $secondChannelOptions);
  83. $this->assignconfig('channelList', $channelList);
  84. $this->assignconfig('spiderRecord', intval($config['spiderrecord'] ?? 0));
  85. $this->assignconfig("flagList", $this->model->getFlagList());
  86. $this->view->assign("flagList", $this->model->getFlagList());
  87. $this->view->assign("statusList", $this->model->getStatusList());
  88. $this->view->assign('IshomeList', $this->model->getIshomeList());
  89. $this->assignconfig('cms', ['archiveseditmode' => $config['archiveseditmode']]);
  90. }
  91. /**
  92. * 查看
  93. */
  94. public function index()
  95. {
  96. //设置过滤方法
  97. $this->request->filter(['strip_tags']);
  98. if ($this->request->isAjax()) {
  99. $this->relationSearch = true;
  100. //如果发送的来源是Selectpage,则转发到Selectpage
  101. if ($this->request->request('keyField')) {
  102. return $this->selectpage();
  103. }
  104. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  105. if (!$this->auth->isSuperAdmin()) {
  106. $this->model->where('channel_id', 'in', $this->channelIds);
  107. }
  108. $total = $this->model
  109. ->with('Channel')
  110. ->where($where)
  111. ->order($sort, $order)
  112. ->count();
  113. if (!$this->auth->isSuperAdmin()) {
  114. $this->model->where('channel_id', 'in', $this->channelIds);
  115. }
  116. $list = $this->model
  117. ->with(['Channel'])
  118. ->where($where)
  119. ->order($sort, $order)
  120. ->limit($offset, $limit)
  121. ->select();
  122. addtion($list, [
  123. [
  124. 'field' => 'channel_ids',
  125. 'display' => 'channel_ids',
  126. 'model' => Channel::class,
  127. ],
  128. ]);
  129. \app\admin\model\cms\SpiderLog::render($list, 'archives');
  130. $result = array("total" => $total, "rows" => $list);
  131. return json($result);
  132. }
  133. $modelList = \app\admin\model\cms\Modelx::all();
  134. $specialList = \app\admin\model\cms\Special::where('status', 'normal')->select();
  135. $this->view->assign('modelList', $modelList);
  136. $this->view->assign('specialList', $specialList);
  137. return $this->view->fetch();
  138. }
  139. /**
  140. * 副表内容
  141. */
  142. public function content($model_id = null)
  143. {
  144. $model = \app\admin\model\cms\Modelx::get($model_id);
  145. if (!$model) {
  146. $this->error('未找到对应模型');
  147. }
  148. $fieldsList = \app\admin\model\cms\Fields::where('source', 'model')->where('source_id', $model['id'])->where('type', '<>', 'text')->select();
  149. //设置过滤方法
  150. $this->request->filter(['strip_tags', 'trim']);
  151. if ($this->request->isAjax()) {
  152. //如果发送的来源是Selectpage,则转发到Selectpage
  153. if ($this->request->request('keyField')) {
  154. return $this->selectpage();
  155. }
  156. $fields = [];
  157. foreach ($fieldsList as $index => $item) {
  158. $fields[] = "addon." . $item['name'];
  159. }
  160. $filter = $this->request->request('filter');
  161. $op = $this->request->request('op');
  162. if ($filter && $op) {
  163. $filterArr = json_decode($filter, true);
  164. $opArr = json_decode($op, true);
  165. foreach ($filterArr as $index => $item) {
  166. if (in_array("addon." . $index, $fields)) {
  167. $filterArr["addon." . $index] = $item;
  168. $opArr["addon." . $index] = $opArr[$index];
  169. unset($filterArr[$index], $opArr[$index]);
  170. }
  171. }
  172. $this->request->get(['filter' => json_encode($filterArr), 'op' => json_encode($opArr)]);
  173. }
  174. $this->searchFields = "archives.id,archives.title";
  175. $this->relationSearch = true;
  176. $table = $this->model->getTable();
  177. list($where, $sort, $order, $offset, $limit, $page, $alias) = $this->buildparams();
  178. $sort = 'archives.id';
  179. $isSuperAdmin = $this->isSuperAdmin;
  180. $channelIds = $this->channelIds;
  181. $customWhere = function ($query) use ($isSuperAdmin, $channelIds, $model_id) {
  182. if (!$isSuperAdmin) {
  183. $query->where('archives.channel_id', 'in', $channelIds);
  184. }
  185. if ($model_id) {
  186. $query->where('archives.model_id', $model_id);
  187. }
  188. };
  189. $list = $this->model
  190. ->alias($alias)
  191. ->alias('archives')
  192. ->join('cms_channel channel', 'channel.id=archives.channel_id', 'LEFT')
  193. ->join($model['table'] . ' addon', 'addon.id=archives.id', 'LEFT')
  194. ->field('archives.*,channel.name as channel_name,addon.id as aid' . ($fields ? ',' . implode(',', $fields) : ''))
  195. ->where($customWhere)
  196. ->whereNull('deletetime')
  197. ->where($where)
  198. ->order($sort, $order)
  199. ->paginate($limit);
  200. $result = array("total" => $list->total(), "rows" => $list->items());
  201. return json($result);
  202. }
  203. $fields = [];
  204. foreach ($fieldsList as $index => $item) {
  205. $fields[] = ['field' => $item['name'], 'title' => $item['title'], 'type' => $item['type'], 'content' => $item['content_list']];
  206. }
  207. $this->assignconfig('fields', $fields);
  208. $this->view->assign('fieldsList', $fieldsList);
  209. $this->view->assign('model', $model);
  210. $this->assignconfig('model_id', $model_id);
  211. $modelList = \app\admin\model\cms\Modelx::all();
  212. $this->view->assign('modelList', $modelList);
  213. return $this->view->fetch();
  214. }
  215. /**
  216. * 编辑
  217. *
  218. * @param mixed $ids
  219. * @return string
  220. */
  221. public function edit($ids = null)
  222. {
  223. $row = $this->model->get($ids);
  224. if (!$row) {
  225. $this->error(__('No Results were found'));
  226. }
  227. $adminIds = $this->getDataLimitAdminIds();
  228. if (is_array($adminIds)) {
  229. if (!in_array($row[$this->dataLimitField], $adminIds)) {
  230. $this->error(__('You have no permission'));
  231. }
  232. }
  233. if (!$this->isSuperAdmin && !in_array($row['channel_id'], $this->channelIds)) {
  234. $this->error(__('You have no permission'));
  235. }
  236. if ($this->request->isPost()) {
  237. return parent::edit($ids);
  238. }
  239. $channel = Channel::get($row['channel_id']);
  240. if (!$channel) {
  241. $this->error(__('No specified channel found'));
  242. }
  243. $model = \app\admin\model\cms\Modelx::get($channel['model_id']);
  244. if (!$model) {
  245. $this->error(__('No specified model found'));
  246. }
  247. $addon = db($model['table'])->where('id', $row['id'])->find();
  248. if ($addon) {
  249. $row->setData($addon);
  250. }
  251. $disabledIds = [];
  252. $all = collection(Channel::order("weigh desc,id desc")->select())->toArray();
  253. // foreach ($all as $k => $v) {
  254. // if ($v['type'] == 'link' || $v['model_id'] != $channel['model_id']) {
  255. // $disabledIds[] = $v['id'];
  256. // }
  257. // }
  258. $disabledIds = array_diff($disabledIds, [$row['channel_id']]);
  259. $tree = Tree::instance()->init($all, 'parent_id');
  260. $pChannelOptions = $tree->getTree(0, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", $row['p_channel_id'], $disabledIds);
  261. $channelOptions = $tree->getTree(0, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", $row['channel_id'], $disabledIds);
  262. $secondChannelOptions = $tree->getTree(0, "<option model='@model_id' value=@id @selected @disabled>@spacer@name</option>", explode(',', $row['channel_ids']), $disabledIds);
  263. $this->view->assign('pChannelOptions', $pChannelOptions);
  264. $this->view->assign('channelOptions', $channelOptions);
  265. $this->view->assign('secondChannelOptions', $secondChannelOptions);
  266. $this->view->assign("row", $row);
  267. return $this->view->fetch();
  268. }
  269. /**
  270. * 删除
  271. * @param mixed $ids
  272. */
  273. public function del($ids = "")
  274. {
  275. parent::del($ids);
  276. }
  277. /**
  278. * 销毁
  279. * @param string $ids
  280. */
  281. public function destroy($ids = "")
  282. {
  283. \app\admin\model\cms\Archives::event('after_delete', function ($row) {
  284. //删除副表
  285. $channel = Channel::get($row->channel_id);
  286. if ($channel) {
  287. $model = Modelx::get($channel['model_id']);
  288. if ($model) {
  289. db($model['table'])->where("id", $row['id'])->delete();
  290. }
  291. }
  292. });
  293. parent::destroy($ids);
  294. }
  295. /**
  296. * 还原
  297. * @param mixed $ids
  298. */
  299. public function restore($ids = "")
  300. {
  301. if (!$this->request->isPost()) {
  302. $this->error(__("Invalid parameters"));
  303. }
  304. $pk = $this->model->getPk();
  305. $adminIds = $this->getDataLimitAdminIds();
  306. if (is_array($adminIds)) {
  307. $this->model->where($this->dataLimitField, 'in', $adminIds);
  308. }
  309. if ($ids) {
  310. $this->model->where($pk, 'in', $ids);
  311. }
  312. $config = get_addon_config('cms');
  313. $list = $this->model->onlyTrashed()->select();
  314. if ($list) {
  315. $ids = [];
  316. $refreshIds = [];
  317. foreach ($list as $index => $item) {
  318. if ($item['status'] == 'normal') {
  319. User::score($config['score']['postarchives'], $item['user_id'], '发布文章');
  320. }
  321. $ids[] = $item['id'];
  322. $refreshIds = array_merge([$item['channel_id']], explode(',', $item['channel_ids']));
  323. $refreshIds = array_filter(array_unique($refreshIds));
  324. }
  325. $this->model->where('id', 'in', $ids);
  326. $this->model->restore('1=1');
  327. Channel::refreshItems($refreshIds);
  328. $this->success();
  329. }
  330. $this->error(__('No rows were updated'));
  331. }
  332. /**
  333. * 移动
  334. * @param string $ids
  335. */
  336. public function move($ids = "")
  337. {
  338. if (!$this->request->isPost()) {
  339. $this->error(__("Invalid parameters"));
  340. }
  341. if ($ids) {
  342. if (!$this->request->isPost()) {
  343. $this->error(__("Invalid parameters"));
  344. }
  345. $channel_id = $this->request->post('channel_id');
  346. $pk = $this->model->getPk();
  347. $adminIds = $this->getDataLimitAdminIds();
  348. if (is_array($adminIds)) {
  349. $this->model->where($this->dataLimitField, 'in', $adminIds);
  350. }
  351. $this->model->where($pk, 'in', $ids);
  352. $channel = Channel::get($channel_id);
  353. if ($channel && $channel['type'] === 'list') {
  354. $channelNums = \app\admin\model\cms\Archives::
  355. with('channel')
  356. ->where('archives.' . $pk, 'in', $ids)
  357. ->where('channel_id', '<>', $channel['id'])
  358. ->field('channel_id,COUNT(*) AS nums')
  359. ->group('channel_id')
  360. ->select();
  361. $result = $this->model
  362. ->where('model_id', '=', $channel['model_id'])
  363. ->where('channel_id', '<>', $channel['id'])
  364. ->update(['channel_id' => $channel_id]);
  365. if ($result) {
  366. $this->success();
  367. } else {
  368. $this->error(__('No rows were updated'));
  369. }
  370. } else {
  371. $this->error(__('No rows were updated'));
  372. }
  373. $this->error(__('Parameter %s can not be empty', 'ids'));
  374. }
  375. }
  376. /**
  377. * 复制选择行
  378. * @param string $ids
  379. */
  380. public function copy($ids = "")
  381. {
  382. if (!$this->request->isPost()) {
  383. $this->error(__("Invalid parameters"));
  384. }
  385. if ($ids) {
  386. $pk = $this->model->getPk();
  387. $adminIds = $this->getDataLimitAdminIds();
  388. if (is_array($adminIds)) {
  389. $this->model->where($this->dataLimitField, 'in', $adminIds);
  390. }
  391. $archivesList = $this->model->where('id', 'in', $ids)->select();
  392. foreach ($archivesList as $index => $item) {
  393. try {
  394. $model = Modelx::get($item['model_id']);
  395. $addon = \think\Db::name($model['table'])->find($item['id']);
  396. $data = $item->toArray();
  397. $data = array_merge($data, $addon ?? []);
  398. $data['title'] = $data['title'] . "_copy";
  399. $data['status'] = 'hidden';
  400. unset($data['id']);
  401. \app\admin\model\cms\Archives::create($data, true);
  402. } catch (\Exception $e) {
  403. //
  404. }
  405. }
  406. $this->success();
  407. $this->error(__('Parameter %s can not be empty', 'ids'));
  408. }
  409. }
  410. /**
  411. * 加入专题
  412. * @param string $ids
  413. */
  414. public function special($ids = "")
  415. {
  416. if (!$this->request->isPost()) {
  417. $this->error(__("Invalid parameters"));
  418. }
  419. if ($ids) {
  420. $special_id = $this->request->post('special_id');
  421. $pk = $this->model->getPk();
  422. $adminIds = $this->getDataLimitAdminIds();
  423. if (is_array($adminIds)) {
  424. $this->model->where($this->dataLimitField, 'in', $adminIds);
  425. }
  426. $special = \app\admin\model\cms\Special::get($special_id);
  427. if ($special) {
  428. $archivesList = $this->model->where($pk, 'in', $ids)->select();
  429. foreach ($archivesList as $index => $item) {
  430. $special_ids = explode(',', $item['special_ids']);
  431. if (!in_array($special['id'], $special_ids)) {
  432. $special_ids[] = $special['id'];
  433. $item->save(['special_ids' => implode(',', array_unique(array_filter($special_ids)))]);
  434. }
  435. }
  436. $this->success();
  437. } else {
  438. $this->error(__('No rows were updated'));
  439. }
  440. }
  441. $this->error(__('Please select at least one row'));
  442. }
  443. /**
  444. * 加入标签
  445. * @param string $ids
  446. */
  447. public function tags($ids = "")
  448. {
  449. if (!$this->request->isPost()) {
  450. $this->error(__("Invalid parameters"));
  451. }
  452. if ($ids) {
  453. $tags = $this->request->post('tags');
  454. $newTagsArr = array_filter(explode(',', $tags));
  455. if ($newTagsArr) {
  456. $pk = $this->model->getPk();
  457. $adminIds = $this->getDataLimitAdminIds();
  458. if (is_array($adminIds)) {
  459. $this->model->where($this->dataLimitField, 'in', $adminIds);
  460. }
  461. $archivesList = $this->model->where($pk, 'in', $ids)->select();
  462. foreach ($archivesList as $index => $item) {
  463. $tagsArr = explode(',', $item['tags']);
  464. $tagsArr = array_merge($tagsArr, $newTagsArr);
  465. $item->save(['tags' => implode(',', array_unique(array_filter($tagsArr)))]);
  466. }
  467. $this->success();
  468. } else {
  469. $this->error(__('标签数据不能为空'));
  470. }
  471. }
  472. $this->error(__('Please select at least one row'));
  473. }
  474. /**
  475. * 修改标志
  476. * @param string $ids
  477. */
  478. public function flag($ids = "")
  479. {
  480. if (!$this->request->isPost()) {
  481. $this->error(__("Invalid parameters"));
  482. }
  483. if ($ids) {
  484. $type = $this->request->post('type');
  485. $flag = $this->request->post('flag');
  486. $changeFlagArr = array_filter(explode(',', $flag));
  487. if ($changeFlagArr) {
  488. $pk = $this->model->getPk();
  489. $adminIds = $this->getDataLimitAdminIds();
  490. if (is_array($adminIds)) {
  491. $this->model->where($this->dataLimitField, 'in', $adminIds);
  492. }
  493. $archivesList = $this->model->where($pk, 'in', $ids)->select();
  494. foreach ($archivesList as $index => $item) {
  495. $flagArr = explode(',', $item['flag']);
  496. if ($type == 'add') {
  497. $flagArr = array_merge($flagArr, $changeFlagArr);
  498. } else {
  499. $flagArr = array_diff($flagArr, $changeFlagArr);
  500. }
  501. $item->save(['flag' => implode(',', array_unique(array_filter($flagArr)))]);
  502. }
  503. $this->success();
  504. } else {
  505. $this->error(__('标志数据不能为空'));
  506. }
  507. }
  508. $this->error(__('Please select at least one row'));
  509. }
  510. /**
  511. * 获取栏目列表
  512. * @internal
  513. */
  514. public function get_fields_html()
  515. {
  516. $this->view->engine->layout(false);
  517. $channel_id = $this->request->post('channel_id');
  518. $archives_id = $this->request->post('archives_id');
  519. $channel = Channel::get($channel_id, 'model');
  520. if ($channel) {
  521. $model_id = $channel['model_id'];
  522. $values = [];
  523. if ($archives_id) {
  524. $values = db($channel['model']['table'])->where('id', $archives_id)->find();
  525. //优先从栏目获取模型ID,再从文档获取
  526. $archives = \app\admin\model\cms\Archives::get($archives_id);
  527. $model_id = $archives ? $archives['model_id'] : $model_id;
  528. }
  529. $fields = \addons\cms\library\Service::getCustomFields('model', $model_id, $values);
  530. $model = Modelx::get($model_id);
  531. $setting = $model['setting'];
  532. $publishfields = isset($setting['publishfields']) ? $setting['publishfields'] : [];
  533. $titlelist = isset($setting['titlelist']) ? $setting['titlelist'] : [];
  534. $this->view->assign('channel', $channel);
  535. $this->view->assign('fields', $fields);
  536. $this->view->assign('values', $values);
  537. $this->success('', null, ['html' => $this->view->fetch('cms/common/fields'), 'publishfields' => $publishfields, 'titlelist' => $titlelist]);
  538. } else {
  539. $this->error(__('Please select channel'));
  540. }
  541. $this->error(__('Parameter %s can not be empty', 'ids'));
  542. }
  543. /**
  544. * 检测元素是否可用
  545. * @internal
  546. */
  547. public function check_element_available()
  548. {
  549. $id = $this->request->request('id');
  550. $name = $this->request->request('name');
  551. $value = $this->request->request('value');
  552. $name = substr($name, 4, -1);
  553. if (!$name) {
  554. $this->error(__('Parameter %s can not be empty', 'name'));
  555. }
  556. if ($id) {
  557. $this->model->where('id', '<>', $id);
  558. }
  559. $exist = $this->model->where($name, $value)->find();
  560. if ($exist) {
  561. $this->error(__('The data already exist'));
  562. } else {
  563. $this->success();
  564. }
  565. }
  566. /**
  567. * 搜索建议
  568. * @internal
  569. */
  570. public function suggestion()
  571. {
  572. $config = get_addon_config('cms');
  573. $q = trim($this->request->request("q"));
  574. $id = trim($this->request->request("id/d"));
  575. $list = [];
  576. if ($config['searchtype'] == 'xunsearch') {
  577. $result = FulltextSearch::search($q, 1, 10);
  578. } else {
  579. $result = $this->model->where("title|keywords|description", "like", "%{$q}%")->where('id', '<>', $id)->limit(10)->order("id", "desc")->select();
  580. foreach ($result as $index => $item) {
  581. $item['image'] = $item['image'] ? $item['image'] : '/assets/addons/cms/img/noimage.png';
  582. $list[] = ['id' => $item['id'], 'url' => $item['fullurl'], 'image' => cdnurl($item['image']), 'title' => $item['title'], 'create_date' => datetime($item['createtime']), 'status' => $item['status'], 'status_text' => $item['status_text'], 'deletetime' => $item['deletetime']];
  583. }
  584. }
  585. return json($list);
  586. }
  587. }