diff --git a/application/admin/command/Crud/stubs/controllerindex.stub b/application/admin/command/Crud/stubs/controllerindex.stub index a3cfa542..e04ca129 100755 --- a/application/admin/command/Crud/stubs/controllerindex.stub +++ b/application/admin/command/Crud/stubs/controllerindex.stub @@ -19,8 +19,7 @@ {%relationWithList%} ->where($where) ->order($sort, $order) - ->limit($offset, $limit) - ->paginate(); + ->paginate($limit); foreach ($list as $row) { {%visibleFieldList%} diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 773f3ccb..ae3aebbf 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -110,7 +110,7 @@ class Index extends Backend } /** - * 注销登录 + * 退出登录 */ public function logout() { diff --git a/application/admin/controller/auth/Admin.php b/application/admin/controller/auth/Admin.php index 0d0eb6e4..bd7f3b2f 100644 --- a/application/admin/controller/auth/Admin.php +++ b/application/admin/controller/auth/Admin.php @@ -67,6 +67,8 @@ class Admin extends Backend */ public function index() { + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { @@ -90,26 +92,21 @@ class Admin extends Backend $adminGroupName[$this->auth->id][$n['id']] = $n['name']; } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); - $total = $this->model - ->where($where) - ->where('id', 'in', $this->childrenAdminIds) - ->order($sort, $order) - ->count(); $list = $this->model ->where($where) ->where('id', 'in', $this->childrenAdminIds) ->field(['password', 'salt', 'token'], true) ->order($sort, $order) - ->limit($offset, $limit) - ->select(); + ->paginate($limit); + foreach ($list as $k => &$v) { $groups = isset($adminGroupName[$v['id']]) ? $adminGroupName[$v['id']] : []; $v['groups'] = implode(',', array_keys($groups)); $v['groups_text'] = implode(',', array_values($groups)); } unset($v); - $result = array("total" => $total, "rows" => $list); + $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } diff --git a/application/admin/controller/auth/Adminlog.php b/application/admin/controller/auth/Adminlog.php index 1db61a25..998fdc8a 100644 --- a/application/admin/controller/auth/Adminlog.php +++ b/application/admin/controller/auth/Adminlog.php @@ -40,21 +40,17 @@ class Adminlog extends Backend */ public function index() { + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { list($where, $sort, $order, $offset, $limit) = $this->buildparams(); - $total = $this->model - ->where($where) - ->where('admin_id', 'in', $this->childrenAdminIds) - ->order($sort, $order) - ->count(); - $list = $this->model ->where($where) ->where('admin_id', 'in', $this->childrenAdminIds) ->order($sort, $order) - ->limit($offset, $limit) - ->select(); - $result = array("total" => $total, "rows" => $list); + ->paginate($limit); + + $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } diff --git a/application/admin/controller/general/Attachment.php b/application/admin/controller/general/Attachment.php index 352f489e..d73c25ce 100644 --- a/application/admin/controller/general/Attachment.php +++ b/application/admin/controller/general/Attachment.php @@ -31,7 +31,7 @@ class Attachment extends Backend public function index() { //设置过滤方法 - $this->request->filter(['strip_tags']); + $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { $mimetypeQuery = []; $filter = $this->request->request('filter'); @@ -51,24 +51,19 @@ class Attachment extends Backend } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); - $total = $this->model - ->where($mimetypeQuery) - ->where($where) - ->order($sort, $order) - ->count(); $list = $this->model ->where($mimetypeQuery) ->where($where) ->order($sort, $order) - ->limit($offset, $limit) - ->select(); + ->paginate($limit); + $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root()); foreach ($list as $k => &$v) { $v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url']; } unset($v); - $result = array("total" => $total, "rows" => $list); + $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } diff --git a/application/admin/controller/general/Profile.php b/application/admin/controller/general/Profile.php index 3cf3ff06..9cc6c538 100644 --- a/application/admin/controller/general/Profile.php +++ b/application/admin/controller/general/Profile.php @@ -22,25 +22,18 @@ class Profile extends Backend public function index() { //设置过滤方法 - $this->request->filter(['strip_tags']); + $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { $model = model('AdminLog'); list($where, $sort, $order, $offset, $limit) = $this->buildparams(); - $total = $model - ->where($where) - ->where('admin_id', $this->auth->id) - ->order($sort, $order) - ->count(); - $list = $model ->where($where) ->where('admin_id', $this->auth->id) ->order($sort, $order) - ->limit($offset, $limit) - ->select(); + ->paginate($limit); - $result = array("total" => $total, "rows" => $list); + $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } diff --git a/application/admin/controller/user/User.php b/application/admin/controller/user/User.php index 47636bdf..ba373e56 100644 --- a/application/admin/controller/user/User.php +++ b/application/admin/controller/user/User.php @@ -33,29 +33,23 @@ class User extends Backend public function index() { //设置过滤方法 - $this->request->filter(['strip_tags']); + $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); - $total = $this->model - ->with('group') - ->where($where) - ->order($sort, $order) - ->count(); $list = $this->model ->with('group') ->where($where) ->order($sort, $order) - ->limit($offset, $limit) - ->select(); + ->paginate($limit); foreach ($list as $k => $v) { $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname); $v->hidden(['password', 'salt']); } - $result = array("total" => $total, "rows" => $list); + $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index ca7802bb..fec04dcd 100755 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -7,7 +7,7 @@ return [ 'Password' => '密码', 'Sign up' => '注 册', 'Sign in' => '登 录', - 'Sign out' => '注 销', + 'Sign out' => '退 出', 'Keep login' => '保持会话', 'Guest' => '游客', 'Welcome' => '%s,你好!', @@ -69,7 +69,7 @@ return [ 'Home' => '主页', 'Online' => '在线', 'Login' => '登录', - 'Logout' => '注销', + 'Logout' => '退出', 'Profile' => '个人资料', 'Index' => '首页', 'Hot' => '热门', diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php index 26122b3c..0616a6f9 100644 --- a/application/admin/library/Auth.php +++ b/application/admin/library/Auth.php @@ -68,7 +68,7 @@ class Auth extends \fast\Auth } /** - * 注销登录 + * 退出登录 */ public function logout() { diff --git a/application/admin/library/traits/Backend.php b/application/admin/library/traits/Backend.php index 3192c9f8..538a1d29 100755 --- a/application/admin/library/traits/Backend.php +++ b/application/admin/library/traits/Backend.php @@ -43,7 +43,7 @@ trait Backend public function index() { //设置过滤方法 - $this->request->filter(['strip_tags']); + $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { @@ -54,8 +54,7 @@ trait Backend $list = $this->model ->where($where) ->order($sort, $order) - ->limit($offset, $limit) - ->paginate(); + ->paginate($limit); $result = array("total" => $list->total(), "rows" => $list->items()); diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 5d4e2b35..5ff63766 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -128,7 +128,7 @@ class User extends Api } /** - * 注销登录 + * 退出登录 */ public function logout() { diff --git a/application/api/lang/zh-cn.php b/application/api/lang/zh-cn.php index 1c85749f..c28bfd3c 100644 --- a/application/api/lang/zh-cn.php +++ b/application/api/lang/zh-cn.php @@ -8,7 +8,7 @@ return [ 'Password' => '密码', 'Sign up' => '注 册', 'Sign in' => '登 录', - 'Sign out' => '注 销', + 'Sign out' => '退 出', 'Guest' => '游客', 'Welcome' => '%s,你好!', 'Add' => '添加', @@ -42,7 +42,7 @@ return [ 'None' => '无', 'Home' => '主页', 'Online' => '在线', - 'Logout' => '注销', + 'Logout' => '退出', 'Profile' => '个人资料', 'Index' => '首页', 'Hot' => '热门', diff --git a/application/api/lang/zh-cn/user.php b/application/api/lang/zh-cn/user.php index 5bb6345d..680695d3 100644 --- a/application/api/lang/zh-cn/user.php +++ b/application/api/lang/zh-cn/user.php @@ -29,7 +29,7 @@ return [ 'Change password' => '修改密码', 'Captcha is incorrect' => '验证码不正确', 'Logged in successful' => '登录成功', - 'Logout successful' => '注销成功', + 'Logout successful' => '退出成功', 'Operation failed' => '操作失败', 'Invalid parameters' => '参数不正确', 'Change password failure' => '修改密码失败', diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 88f1e0f6..bb381a0c 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -261,8 +261,14 @@ class Backend extends Controller $op = $this->request->get("op", '', 'trim'); $sort = $this->request->get("sort", !empty($this->model) && $this->model->getPk() ? $this->model->getPk() : 'id'); $order = $this->request->get("order", "DESC"); - $offset = $this->request->get("offset", 0); - $limit = $this->request->get("limit", 0); + $offset = $this->request->get("offset/d", 0); + $limit = $this->request->get("limit/d", 10); + //新增自动计算页码 + $page = $limit ? intval($offset / $limit) + 1 : 1; + if ($this->request->has("page")) { + $page = $this->request->get("page/d", 1); + } + $this->request->get([config('paginate.var_page') => $page]); $filter = (array)json_decode($filter, true); $op = (array)json_decode($op, true); $filter = $filter ? $filter : []; @@ -404,7 +410,7 @@ class Backend extends Controller } } }; - return [$where, $sort, $order, $offset, $limit]; + return [$where, $sort, $order, $offset, $limit, $page]; } /** diff --git a/application/common/lang/zh-cn/addon.php b/application/common/lang/zh-cn/addon.php index 0491e576..9ca0bb17 100755 --- a/application/common/lang/zh-cn/addon.php +++ b/application/common/lang/zh-cn/addon.php @@ -14,7 +14,7 @@ return [ 'Password' => '密码', 'Sign up' => '注 册', 'Sign in' => '登 录', - 'Sign out' => '注 销', + 'Sign out' => '退 出', 'Guest' => '游客', 'Welcome' => '%s,你好!', 'Add' => '添加', @@ -47,7 +47,7 @@ return [ 'Last' => '末页', 'None' => '无', 'Online' => '在线', - 'Logout' => '注销', + 'Logout' => '退出', 'Profile' => '个人资料', 'Index' => '首页', 'Hot' => '热门', diff --git a/application/common/library/Auth.php b/application/common/library/Auth.php index 89818705..caca32e8 100644 --- a/application/common/library/Auth.php +++ b/application/common/library/Auth.php @@ -225,7 +225,7 @@ class Auth } /** - * 注销 + * 退出 * * @return boolean */ @@ -239,7 +239,7 @@ class Auth $this->_logined = false; //删除Token Token::delete($this->_token); - //注销成功的事件 + //退出成功的事件 Hook::listen("user_logout_successed", $this->_user); return true; } diff --git a/application/index/controller/User.php b/application/index/controller/User.php index f2e4a3f2..0bfabf84 100644 --- a/application/index/controller/User.php +++ b/application/index/controller/User.php @@ -31,7 +31,7 @@ class User extends Frontend $this->error(__('User center already closed')); } - //监听注册登录注销的事件 + //监听注册登录退出的事件 Hook::add('user_login_successed', function ($user) use ($auth) { $expire = input('post.keeplogin') ? 30 * 86400 : 0; Cookie::set('uid', $user->id, $expire); @@ -208,11 +208,11 @@ class User extends Frontend } /** - * 注销登录 + * 退出登录 */ public function logout() { - //注销本站 + //退出本站 $this->auth->logout(); $this->success(__('Logout successful'), url('user/index')); } diff --git a/application/index/lang/zh-cn.php b/application/index/lang/zh-cn.php index 3f8a0085..0184cc42 100755 --- a/application/index/lang/zh-cn.php +++ b/application/index/lang/zh-cn.php @@ -9,7 +9,7 @@ return [ 'Password' => '密码', 'Sign up' => '注 册', 'Sign in' => '登 录', - 'Sign out' => '注 销', + 'Sign out' => '退 出', 'Guest' => '游客', 'Welcome' => '%s,你好!', 'Add' => '添加', @@ -44,7 +44,7 @@ return [ 'Last' => '末页', 'None' => '无', 'Online' => '在线', - 'Logout' => '注销', + 'Logout' => '退出', 'Profile' => '个人资料', 'Index' => '首页', 'Hot' => '热门', diff --git a/application/index/lang/zh-cn/user.php b/application/index/lang/zh-cn/user.php index eba327b0..ca8be925 100755 --- a/application/index/lang/zh-cn/user.php +++ b/application/index/lang/zh-cn/user.php @@ -56,7 +56,7 @@ return [ 'Change password successful' => '修改密码成功', 'Captcha is incorrect' => '验证码不正确', 'Logged in successful' => '登录成功', - 'Logout successful' => '注销成功', + 'Logout successful' => '退出成功', 'User center already closed' => '会员中心已经关闭', 'Operation failed' => '操作失败', 'Invalid parameters' => '参数不正确', diff --git a/public/api.html b/public/api.html index 573585f8..3486ce13 100755 --- a/public/api.html +++ b/public/api.html @@ -175,7 +175,7 @@ 会员登录 手机验证码登录 注册会员 - 注销登录 + 退出登录 修改会员个人信息 修改邮箱 修改手机号 @@ -2174,7 +2174,7 @@