| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 | 
							- <?php
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Created by Yunbao
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Author: https://gitee.com/yunbaokeji
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Date: 2022-02-17
 
- // +—————————————————————————————————————————————————————————————————————
 
- namespace app\admin\controller;
 
- use cmf\controller\AdminBaseController;
 
- use app\admin\model\LinkModel;
 
- class LinkController extends AdminBaseController
 
- {
 
-     protected $targets = ["_blank" => "新标签页打开", "_self" => "本窗口打开"];
 
-     /**
 
-      * 友情链接管理
 
-      * @adminMenu(
 
-      *     'name'   => '友情链接',
 
-      *     'parent' => 'admin/Setting/default',
 
-      *     'display'=> true,
 
-      *     'hasView'=> true,
 
-      *     'order'  => 50,
 
-      *     'icon'   => '',
 
-      *     'remark' => '友情链接管理',
 
-      *     'param'  => ''
 
-      * )
 
-      * @return mixed
 
-      * @throws \think\db\exception\DataNotFoundException
 
-      * @throws \think\db\exception\ModelNotFoundException
 
-      * @throws \think\exception\DbException
 
-      */
 
-     public function index()
 
-     {
 
-         $content = hook_one('admin_link_index_view');
 
-         if (!empty($content)) {
 
-             return $content;
 
-         }
 
-         $linkModel = new LinkModel();
 
-         $links     = $linkModel->select();
 
-         $this->assign('links', $links);
 
-         return $this->fetch();
 
-     }
 
-     /**
 
-      * 添加友情链接
 
-      * @adminMenu(
 
-      *     'name'   => '添加友情链接',
 
-      *     'parent' => 'index',
 
-      *     'display'=> false,
 
-      *     'hasView'=> true,
 
-      *     'order'  => 10000,
 
-      *     'icon'   => '',
 
-      *     'remark' => '添加友情链接',
 
-      *     'param'  => ''
 
-      * )
 
-      */
 
-     public function add()
 
-     {
 
-         $this->assign('targets', $this->targets);
 
-         return $this->fetch();
 
-     }
 
-     /**
 
-      * 添加友情链接提交保存
 
-      * @adminMenu(
 
-      *     'name'   => '添加友情链接提交保存',
 
-      *     'parent' => 'index',
 
-      *     'display'=> false,
 
-      *     'hasView'=> false,
 
-      *     'order'  => 10000,
 
-      *     'icon'   => '',
 
-      *     'remark' => '添加友情链接提交保存',
 
-      *     'param'  => ''
 
-      * )
 
-      */
 
-     public function addPost()
 
-     {
 
-         $data      = $this->request->param();
 
-         $linkModel = new LinkModel();
 
-         $result    = $this->validate($data, 'Link');
 
-         if ($result !== true) {
 
-             $this->error($result);
 
-         }
 
-         $linkModel->allowField(true)->save($data);
 
-         $this->success("添加成功!", url("Link/index"));
 
-     }
 
-     /**
 
-      * 编辑友情链接
 
-      * @adminMenu(
 
-      *     'name'   => '编辑友情链接',
 
-      *     'parent' => 'index',
 
-      *     'display'=> false,
 
-      *     'hasView'=> true,
 
-      *     'order'  => 10000,
 
-      *     'icon'   => '',
 
-      *     'remark' => '编辑友情链接',
 
-      *     'param'  => ''
 
-      * )
 
-      * @return mixed
 
-      * @throws \think\Exception\DbException
 
-      */
 
-     public function edit()
 
-     {
 
-         $id        = $this->request->param('id', 0, 'intval');
 
-         $linkModel = new LinkModel();
 
-         $link      = $linkModel->get($id);
 
-         $this->assign('targets', $this->targets);
 
-         $this->assign('link', $link);
 
-         return $this->fetch();
 
-     }
 
-     /**
 
-      * 编辑友情链接提交保存
 
-      * @adminMenu(
 
-      *     'name'   => '编辑友情链接提交保存',
 
-      *     'parent' => 'index',
 
-      *     'display'=> false,
 
-      *     'hasView'=> false,
 
-      *     'order'  => 10000,
 
-      *     'icon'   => '',
 
-      *     'remark' => '编辑友情链接提交保存',
 
-      *     'param'  => ''
 
-      * )
 
-      */
 
-     public function editPost()
 
-     {
 
-         $data      = $this->request->param();
 
-         $linkModel = new LinkModel();
 
-         $result    = $this->validate($data, 'Link');
 
-         if ($result !== true) {
 
-             $this->error($result);
 
-         }
 
-         $linkModel->allowField(true)->isUpdate(true)->save($data);
 
-         $this->success("保存成功!", url("Link/index"));
 
-     }
 
-     /**
 
-      * 删除友情链接
 
-      * @adminMenu(
 
-      *     'name'   => '删除友情链接',
 
-      *     'parent' => 'index',
 
-      *     'display'=> false,
 
-      *     'hasView'=> false,
 
-      *     'order'  => 10000,
 
-      *     'icon'   => '',
 
-      *     'remark' => '删除友情链接',
 
-      *     'param'  => ''
 
-      * )
 
-      */
 
-     public function delete()
 
-     {
 
-         $id = $this->request->param('id', 0, 'intval');
 
-         LinkModel::destroy($id);
 
-         $this->success("删除成功!", url("link/index"));
 
-     }
 
-     /**
 
-      * 友情链接排序
 
-      * @adminMenu(
 
-      *     'name'   => '友情链接排序',
 
-      *     'parent' => 'index',
 
-      *     'display'=> false,
 
-      *     'hasView'=> false,
 
-      *     'order'  => 10000,
 
-      *     'icon'   => '',
 
-      *     'remark' => '友情链接排序',
 
-      *     'param'  => ''
 
-      * )
 
-      */
 
-     public function listOrder()
 
-     {
 
-         $linkModel = new  LinkModel();
 
-         parent::listOrders($linkModel);
 
-         $this->success("排序更新成功!");
 
-     }
 
-     /**
 
-      * 友情链接显示隐藏
 
-      * @adminMenu(
 
-      *     'name'   => '友情链接显示隐藏',
 
-      *     'parent' => 'index',
 
-      *     'display'=> false,
 
-      *     'hasView'=> false,
 
-      *     'order'  => 10000,
 
-      *     'icon'   => '',
 
-      *     'remark' => '友情链接显示隐藏',
 
-      *     'param'  => ''
 
-      * )
 
-      */
 
-     public function toggle()
 
-     {
 
-         $data      = $this->request->param();
 
-         $linkModel = new LinkModel();
 
-         if (isset($data['ids']) && !empty($data["display"])) {
 
-             $ids = $this->request->param('ids/a');
 
-             $linkModel->where('id', 'in', $ids)->update(['status' => 1]);
 
-             $this->success("更新成功!");
 
-         }
 
-         if (isset($data['ids']) && !empty($data["hide"])) {
 
-             $ids = $this->request->param('ids/a');
 
-             $linkModel->where('id', 'in', $ids)->update(['status' => 0]);
 
-             $this->success("更新成功!");
 
-         }
 
-     }
 
- }
 
 
  |