123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- // +----------------------------------------------------------------------
- // | Yzncms [ 御宅男工作室 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2018 http://yzncms.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 御宅男 <530765310@qq.com>
- // +----------------------------------------------------------------------
-
- // +----------------------------------------------------------------------
- // | 稿件管理
- // +----------------------------------------------------------------------
- namespace app\admin\controller\cms;
-
- use app\admin\model\cms\Cms as Cms_Model;
- use app\cms\model\CmsContent as CmsContentModel;
- use app\common\controller\Adminbase;
- use think\Db;
-
- class Publish extends Adminbase
- {
- protected function initialize()
- {
- parent::initialize();
- $this->Cms_Model = new Cms_Model;
- }
-
- public function index()
- {
- if ($this->request->isAjax()) {
- $limit = $this->request->param('limit/d', 10);
- $page = $this->request->param('page/d', 10);
-
- $total = CmsContentModel::count();
- $_list = CmsContentModel::page($page, $limit)->order(["id" => "DESC"])->select();
-
- foreach ($_list as $k => $v) {
- $modelid = getCategory($v['catid'], 'modelid');
- $tablename = ucwords(getModel($modelid, 'tablename'));
- $info = Db::name($tablename)->where(["id" => $v['content_id'], "sysadd" => 0])->find();
- if ($info) {
- $_list[$k]['url'] = buildContentUrl($v['catid'], $v['content_id'], $info['url']);
- $_list[$k]['title'] = $info['title'];
- $_list[$k]['catname'] = getCategory($v['catid'], 'catname');
- }
- }
- $result = ["code" => 0, "count" => $total, "data" => $_list];
-
- return json($result);
- }
- return $this->fetch();
- }
-
- //删除
- public function del()
- {
- $ids = $this->request->param('id/a', null);
- if (empty($ids)) {
- $this->error('请指定需要删除的信息!');
- }
- if (!is_array($ids)) {
- $ids = [0 => $ids];
- }
- foreach ($ids as $id) {
- //信息
- $info = CmsContentModel::where('id', $id)->find();
- //取得栏目信息
- $category = getCategory($info['catid']);
- if (!$category) {
- $this->success('栏目不存在!');
- }
- try {
- $this->Cms_Model->deleteModelData($category['modelid'], $info['content_id']);
- } catch (\Exception $ex) {
- $this->error($ex->getMessage());
- }
- }
- $this->success('删除成功!');
- }
-
- //通过审核
- public function pass()
- {
- $ids = $this->request->param('id/a', null);
- if (empty($ids)) {
- $this->error('请指定需要操作的信息!');
- }
- if (!is_array($ids)) {
- $ids = [0 => $ids];
- }
- foreach ($ids as $id) {
- $info = CmsContentModel::get($id);
- $info->status = 1;
- $info->save();
-
- $modelid = getCategory($info['catid'], 'modelid');
- $model_cache = cache("Model");
- $tablename = ucwords($model_cache[$modelid]['tablename']);
- Db::name($tablename)->where('id', $info['content_id'])->setField('status', 1);
- }
- $this->success('操作成功!');
-
- }
-
- //退稿
- public function reject()
- {
- $ids = $this->request->param('id/a', null);
- if (empty($ids)) {
- $this->error('请指定需要操作的信息!');
- }
- if (!is_array($ids)) {
- $ids = [0 => $ids];
- }
- foreach ($ids as $id) {
- $info = CmsContentModel::get($id);
- $info->status = -1;
- $info->save();
-
- $modelid = getCategory($info['catid'], 'modelid');
- $model_cache = cache("Model");
- $tablename = ucwords($model_cache[$modelid]['tablename']);
- Db::name($tablename)->where('id', $info['content_id'])->setField('status', 0);
- }
- $this->success('操作成功!');
-
- }
-
- }
|