diff --git a/application/admin/command/Menu.php b/application/admin/command/Menu.php index ad18b89c..e65c4123 100755 --- a/application/admin/command/Menu.php +++ b/application/admin/command/Menu.php @@ -27,7 +27,7 @@ class Menu extends Command ->addOption('force', 'f', Option::VALUE_OPTIONAL, 'force delete menu,without tips', null) ->addOption('equal', 'e', Option::VALUE_OPTIONAL, 'the controller must be equal', null) ->setDescription('Build auth menu from controller'); - //要执行的controller必须一样,不适用模糊查询 + //要执行的controller必须一样,不适用模糊查询 } protected function execute(Input $input, Output $output) @@ -44,7 +44,7 @@ class Menu extends Command //是否为删除模式 $delete = $input->getOption('delete'); //是否控制器完全匹配 - $equal= $input->getOption('equal'); + $equal = $input->getOption('equal'); if ($delete) { @@ -54,10 +54,10 @@ class Menu extends Command $ids = []; $list = $this->model->where(function ($query) use ($controller, $equal) { foreach ($controller as $index => $item) { - if($equal) + if ($equal) $query->whereOr('name', 'eq', $item); else - $query->whereOr('name', 'like', strtolower($item) . "%"); + $query->whereOr('name', 'like', strtolower($item) . "%"); } })->select(); foreach ($list as $k => $v) { @@ -156,6 +156,7 @@ class Menu extends Command protected function importRule($controller) { + $controller = str_replace('\\', '/', $controller); $controllerArr = explode('/', $controller); end($controllerArr); $key = key($controllerArr); diff --git a/application/admin/controller/Addon.php b/application/admin/controller/Addon.php index 4e3dd473..560f5138 100644 --- a/application/admin/controller/Addon.php +++ b/application/admin/controller/Addon.php @@ -82,7 +82,9 @@ class Addon extends Backend $this->error(__('Parameter %s can not be empty', '')); } $this->view->assign("addon", ['info' => $info, 'config' => $config]); - return $this->view->fetch(); + $configFile = ADDON_PATH . $name . DS . 'config.html'; + $viewFile = is_file($configFile) ? $configFile : ''; + return $this->view->fetch($viewFile); } /** diff --git a/application/admin/controller/general/Attachment.php b/application/admin/controller/general/Attachment.php index d2ca90a6..80414dfc 100644 --- a/application/admin/controller/general/Attachment.php +++ b/application/admin/controller/general/Attachment.php @@ -31,22 +31,35 @@ class Attachment extends Backend { //设置过滤方法 $this->request->filter(['strip_tags']); - if ($this->request->isAjax()) - { + if ($this->request->isAjax()) { + $mimetypeQuery = []; + $filter = $this->request->request('filter'); + $filterArr = (array)json_decode($filter, TRUE); + if (isset($filterArr['mimetype']) && stripos($filterArr['mimetype'], ',') !== false) { + $this->request->get(['filter' => json_encode(array_merge($filterArr, ['mimetype' => '']))]); + $mimetypeQuery = function ($query) use ($filterArr) { + $mimetypeArr = explode(',', $filterArr['mimetype']); + foreach ($mimetypeArr as $index => $item) { + $query->whereOr('mimetype', 'like', '%' . $item . '%'); + } + }; + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $total = $this->model - ->where($where) - ->order($sort, $order) - ->count(); + ->where($mimetypeQuery) + ->where($where) + ->order($sort, $order) + ->count(); $list = $this->model - ->where($where) - ->order($sort, $order) - ->limit($offset, $limit) - ->select(); + ->where($mimetypeQuery) + ->where($where) + ->order($sort, $order) + ->limit($offset, $limit) + ->select(); $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root()); - foreach ($list as $k => &$v) - { + foreach ($list as $k => &$v) { $v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url']; } unset($v); @@ -62,8 +75,7 @@ class Attachment extends Backend */ public function select() { - if ($this->request->isAjax()) - { + if ($this->request->isAjax()) { return $this->index(); } return $this->view->fetch(); @@ -74,8 +86,7 @@ class Attachment extends Backend */ public function add() { - if ($this->request->isAjax()) - { + if ($this->request->isAjax()) { $this->error(); } return $this->view->fetch(); @@ -87,18 +98,15 @@ class Attachment extends Backend */ public function del($ids = "") { - if ($ids) - { - \think\Hook::add('upload_delete', function($params) { + if ($ids) { + \think\Hook::add('upload_delete', function ($params) { $attachmentFile = ROOT_PATH . '/public' . $params['url']; - if (is_file($attachmentFile)) - { + if (is_file($attachmentFile)) { @unlink($attachmentFile); } }); $attachmentlist = $this->model->where('id', 'in', $ids)->select(); - foreach ($attachmentlist as $attachment) - { + foreach ($attachmentlist as $attachment) { \think\Hook::listen("upload_delete", $attachment); $attachment->delete(); } diff --git a/application/admin/lang/zh-cn/general/attachment.php b/application/admin/lang/zh-cn/general/attachment.php index b713a4d0..96ea7af7 100644 --- a/application/admin/lang/zh-cn/general/attachment.php +++ b/application/admin/lang/zh-cn/general/attachment.php @@ -2,6 +2,8 @@ return [ 'Id' => 'ID', + 'Admin_id' => '管理员ID', + 'User_id' => '会员ID', 'Url' => '物理路径', 'Imagewidth' => '宽度', 'Imageheight' => '高度', diff --git a/application/admin/model/UserRule.php b/application/admin/model/UserRule.php index 07b64244..641d65b0 100644 --- a/application/admin/model/UserRule.php +++ b/application/admin/model/UserRule.php @@ -41,10 +41,9 @@ class UserRule extends Model public static function getTreeList($selected = []) { - $ruleList = collection(self::where('status', 'normal')->select())->toArray(); + $ruleList = collection(self::where('status', 'normal')->order('weigh desc,id desc')->select())->toArray(); $nodeList = []; - foreach ($ruleList as $k => $v) - { + foreach ($ruleList as $k => $v) { $state = array('selected' => $v['ismenu'] ? false : in_array($v['id'], $selected)); $nodeList[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state); } diff --git a/application/admin/view/addon/config.html b/application/admin/view/addon/config.html index ef050c15..327d83c8 100644 --- a/application/admin/view/addon/config.html +++ b/application/admin/view/addon/config.html @@ -15,10 +15,10 @@