From e708c0363e858e89e704301450a7939cad2b83ad Mon Sep 17 00:00:00 2001 From: gplane Date: Sat, 22 Apr 2017 09:17:39 +0800 Subject: [PATCH 01/39] Add default value when renaming closet item --- resources/assets/src/scripts/user.js | 3 ++- resources/views/vendor/closet-items.tpl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/assets/src/scripts/user.js b/resources/assets/src/scripts/user.js index b3138b1d..9ed9685e 100644 --- a/resources/assets/src/scripts/user.js +++ b/resources/assets/src/scripts/user.js @@ -81,10 +81,11 @@ function showPlayerTexturePreview(pid) { }); } -function renameClosetItem(tid) { +function renameClosetItem(tid, oldName) { swal({ title: trans('user.renameClosetItem'), input: 'text', + inputValue: oldName, showCancelButton: true, inputValidator: function(value) { return new Promise(function(resolve, reject) { diff --git a/resources/views/vendor/closet-items.tpl b/resources/views/vendor/closet-items.tpl index 1bbb9dac..6f0f4bf4 100644 --- a/resources/views/vendor/closet-items.tpl +++ b/resources/views/vendor/closet-items.tpl @@ -12,7 +12,7 @@ From 4ae8ed2d828904d11b53252900a968b254cfe8be Mon Sep 17 00:00:00 2001 From: gplane Date: Sat, 22 Apr 2017 18:36:22 +0800 Subject: [PATCH 02/39] Use CSR for DataTables --- app/Http/Controllers/AdminController.php | 18 +- app/Http/Controllers/PluginController.php | 4 +- resources/assets/src/scripts/admin.js | 270 +++++++++++++++++- resources/lang/en/admin.yml | 8 - resources/lang/en/locale.js | 42 ++- resources/lang/zh_CN/admin.yml | 8 - resources/lang/zh_CN/locale.js | 42 ++- resources/views/admin/players.tpl | 21 -- resources/views/admin/plugins.tpl | 29 -- resources/views/admin/users.tpl | 23 -- .../admin-operations/players/operations.tpl | 11 - .../admin-operations/players/preference.tpl | 4 - .../admin-operations/players/previews.tpl | 23 -- .../admin-operations/plugins/operations.tpl | 13 - .../admin-operations/users/operations.tpl | 50 ---- .../vendor/admin-operations/users/score.tpl | 1 - 16 files changed, 325 insertions(+), 242 deletions(-) delete mode 100644 resources/views/vendor/admin-operations/players/operations.tpl delete mode 100644 resources/views/vendor/admin-operations/players/preference.tpl delete mode 100644 resources/views/vendor/admin-operations/players/previews.tpl delete mode 100644 resources/views/vendor/admin-operations/plugins/operations.tpl delete mode 100644 resources/views/vendor/admin-operations/users/operations.tpl delete mode 100644 resources/views/vendor/admin-operations/users/score.tpl diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 8ded24b4..7970bf91 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -169,21 +169,11 @@ class AdminController extends Controller { $users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'register_at']); - $permissionTextMap = [ - User::BANNED => trans('admin.users.status.banned'), - User::NORMAL => trans('admin.users.status.normal'), - User::ADMIN => trans('admin.users.status.admin'), - User::SUPER_ADMIN => trans('admin.users.status.super-admin') - ]; - return Datatables::of($users)->editColumn('email', function ($user) { return $user->email ?: 'EMPTY'; - })->editColumn('permission', function ($user) use ($permissionTextMap) { - return array_get($permissionTextMap, $user->permission); }) ->setRowId('uid') - ->editColumn('score', 'vendor.admin-operations.users.score') - ->addColumn('operations', 'vendor.admin-operations.users.operations') + ->addColumn('operations', app('user.current')->getPermission()) ->make(true); } @@ -202,11 +192,7 @@ class AdminController extends Controller { $players = Player::select(['pid', 'uid', 'player_name', 'preference', 'tid_steve', 'tid_alex', 'tid_cape', 'last_modified']); - return Datatables::of($players)->editColumn('preference', 'vendor.admin-operations.players.preference') - ->setRowId('pid') - ->addColumn('previews', 'vendor.admin-operations.players.previews') - ->addColumn('operations', 'vendor.admin-operations.players.operations') - ->make(true); + return Datatables::of($players)->setRowId('pid')->make(true); } /** diff --git a/app/Http/Controllers/PluginController.php b/app/Http/Controllers/PluginController.php index ce96c470..21545ea0 100644 --- a/app/Http/Controllers/PluginController.php +++ b/app/Http/Controllers/PluginController.php @@ -75,13 +75,13 @@ class PluginController extends Controller return trans($plugin->description); }) ->editColumn('author', function ($plugin) { - return "".trans($plugin->author).""; + return ['author' => trans($plugin->author), 'url' => $plugin->url]; }) ->addColumn('status', function ($plugin) { return trans('admin.plugins.status.'.($plugin->isEnabled() ? 'enabled' : 'disabled')); }) ->addColumn('operations', function ($plugin) { - return view('vendor.admin-operations.plugins.operations', compact('plugin')); + return ['enabled' => $plugin->isEnabled(), 'hasConfigView' => $plugin->hasConfigView()]; }) ->make(true); } diff --git a/resources/assets/src/scripts/admin.js b/resources/assets/src/scripts/admin.js index 3a9ce350..f31ae36b 100644 --- a/resources/assets/src/scripts/admin.js +++ b/resources/assets/src/scripts/admin.js @@ -11,6 +11,23 @@ $(document).ready(function() { $('input').iCheck({ checkboxClass: 'icheckbox_square-blue' }); + + $.extend(true, $.fn.dataTable.defaults, { + language: trans('vendor.datatables'), + scrollX: true, + pageLength: 25, + autoWidth: false, + processing: true, + serverSide: true + }); + + if (window.location.pathname.includes('admin/users')) { + initUsersTable(); + } else if (window.location.pathname.includes('admin/players')) { + initPlayersTable(); + } else if (window.location.pathname.includes('admin/plugins/manage')) { + initPluginsTable(); + } }); $('#layout-skins-list [data-skin]').click(function(e) { @@ -191,7 +208,7 @@ $('body').on('keypress', '.score', function(event){ } }); -$('body').on('change', '#preference', function() { +function changePreference() { $.ajax({ type: "POST", url: "./players?action=preference", @@ -206,9 +223,9 @@ $('body').on('change', '#preference', function() { }, error: showAjaxError }); -}); +} -function changeTexture(pid) { +function changeTexture(pid, playerName) { let dom = `
@@ -223,8 +240,6 @@ function changeTexture(pid) {
`; - let playerName = $('#'+pid).find('#player-name').text(); - showModal(dom, trans('admin.changePlayerTexture', {'player': playerName}), 'default', { callback: `ajaxChangeTexture(${pid})` }); @@ -453,3 +468,248 @@ function downloadUpdates() { .fail(showAjaxError); } + +function initUsersTable() { + const rootPath = /(^https?:.*)\/admin\/users/.exec(window.location.href)[1]; + $('#user-table').DataTable({ + ajax: `${rootPath}/admin/user-data`, + scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7, + columnDefs: [ + { + targets: 0, + data: 'uid', + width: '1%' + }, + { + targets: 1, + data: 'email' + }, + { + targets: 2, + data: 'nickname' + }, + { + targets: 3, + data: 'score', + render: data => { + return ``; + } + }, + { + targets: 4, + data: 'permission', + render: data => { + switch (data) { + case -1: + return trans('admin.banned'); + case 0: + return trans('admin.normal'); + case 1: + return trans('admin.admin'); + case 2: + return trans('admin.superAdmin'); + } + } + }, + { + targets: 5, + data: 'register_at' + }, + { + targets: 6, + data: 'operations', + searchable: false, + orderable: false, + render: (data, type, row) => { + let operationsHtml, adminOption = '', bannedOption = '', deleteUserButton; + if (row.permission !== 2) { + if (data === 2) { + if (row.permission === 1) { + adminOption = `
  • +
  • ${trans('admin.unsetAdmin')}
  • `; + } else { + adminOption = `
  • +
  • ${trans('admin.setAdmin')}
  • `; + } + } + if (row.permission === -1) { + bannedOption = `
  • +
  • ${trans('admin.ban')}
  • `; + } else { + bannedOption = `
  • +
  • ${trans('admin.unban')}
  • `; + } + } + + if (data === 2) { + if (row.permission === 2) { + deleteUserButton = ` + ${trans('admin.deleteUser')}`; + } else { + deleteUserButton = ` + ${trans('admin.deleteUser')}`; + } + } else { + if (row.permission === 1 || row.permission === 2) { + deleteUserButton = ` + ${trans('admin.deleteUser')}`; + } else { + deleteUserButton = ` + ${trans('admin.deleteUser')}`; + } + } + + return ` +
    + + +
    + ${deleteUserButton}`; + } + } + ] + }); +} + +function initPlayersTable() { + const rootPath = /(^https?:.*)\/admin\/players/.exec(window.location.href)[1]; + $('#player-table').DataTable({ + ajax: `${rootPath}/admin/player-data`, + scrollY: ($('.content-wrapper').height() - $('.content-header').outerHeight()) * 0.7, + columnDefs: [ + { + targets: 0, + data: 'pid', + width: '1%' + }, + { + targets: 1, + data: 'uid' + }, + { + targets: 2, + data: 'player_name' + }, + { + targets: 3, + data: 'preference', + render: data => { + return ` + `; + } + }, + { + targets: 4, + searchable: false, + orderable: false, + render: (data, type, row) => { + let html = { steve: '', alex: '', cape: '' }; + ['steve', 'alex', 'cape'].forEach(textureType => { + if (row['tid_' + textureType] === 0) { + html[textureType] = ``; + } else { + html[textureType] = ` + + + `; + } + }); + return html.steve + html.alex + html.cape; + } + }, + { + targets: 5, + data: 'last_modified' + }, + { + targets: 6, + searchable: false, + orderable: false, + render: (data, type, row) => { + return ` +
    + + +
    + ${trans('admin.deletePlayer')}`; + } + } + ] + }); +} + +function initPluginsTable() { + const rootPath = /(^https?:.*)\/admin\/plugins\/manage/.exec(window.location.href)[1]; + $('#plugin-table').DataTable({ + ajax: `${rootPath}/admin/plugins/data`, + columnDefs: [ + { + targets: 0, + data: 'title' + }, + { + targets: 1, + data: 'description', + width: '35%' + }, + { + targets: 2, + data: 'author', + render: data => { + if (data.url === '' || data.url === null) { + return data.author; + } else { + return `${data.author}`; + } + } + }, + { + targets: 3, + data: 'version' + }, + { + targets: 4, + data: 'status' + }, + { + targets: 5, + data: 'operations', + searchable: false, + orderable: false, + render: (data, type, row) => { + let switchEnableButton, configViewButton, deletePluginButton; + if (data.enabled) { + switchEnableButton = ` + ${trans('admin.disablePlugin')}`; + } else { + switchEnableButton = ` + ${trans('admin.enablePlugin')}`; + } + if (data.enabled && data.hasConfigView) { + configViewButton = ` + ${trans('admin.configurePlugin')}`; + } else { + configViewButton = ` + ${trans('admin.configurePlugin')}`; + } + deletePluginButton = ` + ${trans('admin.deletePlugin')}`; + return switchEnableButton + configViewButton + deletePluginButton; + } + } + ] + }); +} diff --git a/resources/lang/en/admin.yml b/resources/lang/en/admin.yml index 36b101f2..88286d49 100644 --- a/resources/lang/en/admin.yml +++ b/resources/lang/en/admin.yml @@ -12,8 +12,6 @@ users: banned: Banned admin: Admin super-admin: Super Admin - score: - tip: Press enter to submit new score operations: title: Operations non-existent: No such user. @@ -100,12 +98,6 @@ plugins: operations: title: Operations - disable: Disable - enable: Enable - configure: Configure - no-config-notice: The plugin has been disabled or no configuration is provided. - delete: Delete - enabled: :plugin has been enabled. disabled: :plugin has been disabled. deleted: The plugin was deleted successfully. diff --git a/resources/lang/en/locale.js b/resources/lang/en/locale.js index 1a337a90..b1f0b7ca 100644 --- a/resources/lang/en/locale.js +++ b/resources/lang/en/locale.js @@ -95,38 +95,52 @@ emptyDeletePassword: 'Please enter the current password:' }, admin: { - // Change User Profile - newUserEmail: 'Please enter the new email:', - newUserNickname: 'Please enter the new nickname:', - newUserPassword: 'Please enter the new password:', - deleteUserNotice: 'Are you sure to delete this user? It\' permanent.', - changePlayerOwner: 'Please enter the id of user which this player should be transferred to:', - deletePlayerNotice: 'Are you sure to delete this player? It\' permanent.', + operationsTitle: 'Operations', - // Status - banned: 'Banned', - normal: 'Normal', - admin: 'Admin', - - // Operations + // Users ban: 'Ban', unban: 'Unban', setAdmin: 'Set as admin', unsetAdmin: 'Remove admin', + deleteUser: 'Delete User', + cannotDeleteAdmin: 'You can\'t delete admins.', + cannotDeleteSuperAdmin: 'You can\'t delete super admin in this way', + changeEmail: 'Edit Email', + changeNickName: 'Edit Nickname', + changePassword: 'Edit Password', + newUserEmail: 'Please enter the new email:', + newUserNickname: 'Please enter the new nickname:', + newUserPassword: 'Please enter the new password:', + deleteUserNotice: 'Are you sure to delete this user? It\' permanent.', + scoreTip: 'Press ENTER to submit new score', - // Change Player Texture + // Status + banned: 'Banned', + normal: 'Normal', + admin: 'Admin', + superAdmin: 'Super Admin', + + // Players textureType: 'Texture Type', skin: 'Skin (:model Model)', cape: 'Cape', pid: 'Texture ID', pidNotice: 'Please enter the tid of texture', changePlayerTexture: 'Change textures of :player', + changeTexture: 'Change Textures', + changeOwner: 'Change Owner', + deletePlayer: 'Delete', + changePlayerOwner: 'Please enter the id of user which this player should be transferred to:', + deletePlayerNotice: 'Are you sure to delete this player? It\' permanent.', // Index textureUploads: 'Texture Uploads', userRegistration: 'User Registration', // Plugins + configurePlugin: 'Configure', + noPluginConfigNotice: 'The plugin has been disabled or no configuration is provided.', + deletePlugin: 'Delete', statusEnabled: 'Enabled', statusDisabled: 'Disabled', enablePlugin: 'Enable', diff --git a/resources/lang/zh_CN/admin.yml b/resources/lang/zh_CN/admin.yml index 1f4e4372..63e4ab0c 100644 --- a/resources/lang/zh_CN/admin.yml +++ b/resources/lang/zh_CN/admin.yml @@ -12,8 +12,6 @@ users: banned: 封禁 admin: 管理员 super-admin: 超级管理员 - score: - tip: 输入修改后的积分,回车提交 operations: title: 更多操作 non-existent: 用户不存在 @@ -100,12 +98,6 @@ plugins: operations: title: 操作 - disable: 禁用插件 - enable: 启用插件 - configure: 插件配置 - no-config-notice: 插件已被禁用或无配置页 - delete: 删除插件 - enabled: :plugin 已启用 disabled: :plugin 已禁用 deleted: 插件已被成功删除 diff --git a/resources/lang/zh_CN/locale.js b/resources/lang/zh_CN/locale.js index 334d212d..832b554b 100644 --- a/resources/lang/zh_CN/locale.js +++ b/resources/lang/zh_CN/locale.js @@ -95,38 +95,52 @@ emptyDeletePassword: '请先输入当前用户密码' }, admin: { - // Change User Profile - newUserEmail: '请输入新邮箱:', - newUserNickname: '请输入新昵称:', - newUserPassword: '请输入新密码:', - deleteUserNotice: '真的要删除此用户吗?此操作不可恢复', - changePlayerOwner: '请输入此角色要让渡至的用户 UID:', - deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复', + operationsTitle: '更多操作', - // Status - banned: '封禁', - normal: '正常', - admin: '管理员', - - // Operations + // Users ban: '封禁', unban: '解封', setAdmin: '设为管理员', unsetAdmin: '解除管理员', + deleteUser: '删除用户', + cannotDeleteAdmin: '你不能删除管理员账号哦', + cannotDeleteSuperAdmin: '超级管理员账号不能被这样删除的啦', + changeEmail: '修改邮箱', + changeNickName: '修改昵称', + changePassword: '更改密码', + newUserEmail: '请输入新邮箱:', + newUserNickname: '请输入新昵称:', + newUserPassword: '请输入新密码:', + deleteUserNotice: '真的要删除此用户吗?此操作不可恢复', + scoreTip: '输入修改后的积分,回车提交', - // Change Player Texture + // Status + banned: '封禁', + normal: '普通用户', + admin: '管理员', + superAdmin: '超级管理员', + + // Players textureType: '材质类型', skin: '皮肤(:model 模型)', cape: '披风', pid: '材质 ID', pidNotice: '输入要更换的材质的 TID', changePlayerTexture: '更换角色 :player 的材质', + changeTexture: '更换材质', + changeOwner: '更换角色拥有者', + deletePlayer: '删除角色', + changePlayerOwner: '请输入此角色要让渡至的用户 UID:', + deletePlayerNotice: '真的要删除此角色吗?此操作不可恢复', // Index textureUploads: '材质上传', userRegistration: '用户注册', // Plugins + configurePlugin: '插件配置', + noPluginConfigNotice: '插件已被禁用或无配置页', + deletePlugin: '删除插件', statusEnabled: '已启用', statusDisabled: '已禁用', enablePlugin: '启用插件', diff --git a/resources/views/admin/players.tpl b/resources/views/admin/players.tpl index c5820b7b..d9c62853 100644 --- a/resources/views/admin/players.tpl +++ b/resources/views/admin/players.tpl @@ -43,26 +43,5 @@ $(document).ready(function() { $('.box-body').css('min-height', $('.content-wrapper').height() - $('.content-header').outerHeight() - 120); }); - -$('#player-table').DataTable({ - language: trans('vendor.datatables'), - scrollX: true, - autoWidth: false, - processing: true, - serverSide: true, - ajax: '{{ url("admin/player-data") }}', - createdRow: function (row, data, index) { - $('td', row).eq(2).attr('id', 'player-name'); - }, - columns: [ - {data: 'pid', 'width': '1%'}, - {data: 'uid'}, - {data: 'player_name'}, - {data: 'preference'}, - {data: 'previews', searchable: false, orderable: false}, - {data: 'last_modified'}, - {data: 'operations', searchable: false, orderable: false} - ] -}); @endsection diff --git a/resources/views/admin/plugins.tpl b/resources/views/admin/plugins.tpl index 1c4a5bd7..8b5e4304 100644 --- a/resources/views/admin/plugins.tpl +++ b/resources/views/admin/plugins.tpl @@ -47,32 +47,3 @@ @endsection - -@section('script') - -@endsection diff --git a/resources/views/admin/users.tpl b/resources/views/admin/users.tpl index 64b23e22..d9006d0e 100644 --- a/resources/views/admin/users.tpl +++ b/resources/views/admin/users.tpl @@ -42,28 +42,5 @@ $(document).ready(function() { $('.box-body').css('min-height', $('.content-wrapper').height() - $('.content-header').outerHeight() - 120); }); - -$('#user-table').DataTable({ - language: trans('vendor.datatables'), - scrollX: true, - autoWidth: false, - processing: true, - serverSide: true, - ajax: '{{ url("admin/user-data") }}', - createdRow: function (row, data, index) { - $('td', row).eq(1).attr('id', 'email'); - $('td', row).eq(2).attr('id', 'nickname'); - $('td', row).eq(4).attr('id', 'permission'); - }, - columns: [ - {data: 'uid', 'width': '1%'}, - {data: 'email'}, - {data: 'nickname'}, - {data: 'score'}, - {data: 'permission'}, - {data: 'register_at'}, - {data: 'operations', searchable: false, orderable: false} - ] -}); @endsection diff --git a/resources/views/vendor/admin-operations/players/operations.tpl b/resources/views/vendor/admin-operations/players/operations.tpl deleted file mode 100644 index 8dbf4e60..00000000 --- a/resources/views/vendor/admin-operations/players/operations.tpl +++ /dev/null @@ -1,11 +0,0 @@ -
    - - -
    - -{{ trans('admin.players.delete.delete') }} diff --git a/resources/views/vendor/admin-operations/players/preference.tpl b/resources/views/vendor/admin-operations/players/preference.tpl deleted file mode 100644 index a5330e12..00000000 --- a/resources/views/vendor/admin-operations/players/preference.tpl +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/resources/views/vendor/admin-operations/players/previews.tpl b/resources/views/vendor/admin-operations/players/previews.tpl deleted file mode 100644 index e975ef46..00000000 --- a/resources/views/vendor/admin-operations/players/previews.tpl +++ /dev/null @@ -1,23 +0,0 @@ -@if ($tid_steve == '0') - -@else - - - -@endif - -@if ($tid_alex == '0') - -@else - - - -@endif - -@if ($tid_cape == '0') - -@else - - - -@endif diff --git a/resources/views/vendor/admin-operations/plugins/operations.tpl b/resources/views/vendor/admin-operations/plugins/operations.tpl deleted file mode 100644 index 6dba4c18..00000000 --- a/resources/views/vendor/admin-operations/plugins/operations.tpl +++ /dev/null @@ -1,13 +0,0 @@ -@if ($plugin->isEnabled()) -{{ trans('admin.plugins.operations.disable') }} -@else -{{ trans('admin.plugins.operations.enable') }} -@endif - -@if ($plugin->isEnabled() && $plugin->hasConfigView()) -{{ trans('admin.plugins.operations.configure') }} -@else -{{ trans('admin.plugins.operations.configure') }} -@endif - -{{ trans('admin.plugins.operations.delete') }} diff --git a/resources/views/vendor/admin-operations/users/operations.tpl b/resources/views/vendor/admin-operations/users/operations.tpl deleted file mode 100644 index 29e714e3..00000000 --- a/resources/views/vendor/admin-operations/users/operations.tpl +++ /dev/null @@ -1,50 +0,0 @@ - -
    - - -
    - -{{-- If current user is super admin --}} -@if (app('user.current')->getPermission() == User::SUPER_ADMIN) - - @if ($permission == "2") - {{ trans('admin.users.operations.delete.delete') }} - @else - {{ trans('admin.users.operations.delete.delete') }} - @endif - -@else - @if ($permission == "1" || $permission == "2") - {{ trans('admin.users.operations.delete.delete') }} - @else - {{ trans('admin.users.operations.delete.delete') }} - @endif - -@endif diff --git a/resources/views/vendor/admin-operations/users/score.tpl b/resources/views/vendor/admin-operations/users/score.tpl deleted file mode 100644 index 312643da..00000000 --- a/resources/views/vendor/admin-operations/users/score.tpl +++ /dev/null @@ -1 +0,0 @@ - From 5b15b6922c4f31791bb0a5141d64154c9bbe441c Mon Sep 17 00:00:00 2001 From: gplane Date: Sat, 22 Apr 2017 18:40:44 +0800 Subject: [PATCH 03/39] Fix link of cleaning filter --- resources/views/skinlib/master.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/skinlib/master.tpl b/resources/views/skinlib/master.tpl index 13c2f828..30ce267c 100644 --- a/resources/views/skinlib/master.tpl +++ b/resources/views/skinlib/master.tpl @@ -49,7 +49,7 @@
  • {{ trans('skinlib.general.my-upload') }}
  • @endif
  • -
  • {{ trans('skinlib.filter.clean-filter') }}
  • +
  • {{ trans('skinlib.filter.clean-filter') }}
  • From b6dfc1c2a4a3c25484878b20f90c6e879d992747 Mon Sep 17 00:00:00 2001 From: gplane Date: Sat, 22 Apr 2017 23:02:48 +0800 Subject: [PATCH 04/39] Fix text about returning score --- resources/lang/en/locale.js | 2 +- resources/lang/en/user.yml | 5 +++-- resources/lang/zh_CN/locale.js | 2 +- resources/lang/zh_CN/user.yml | 4 +++- resources/views/user/index.tpl | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/resources/lang/en/locale.js b/resources/lang/en/locale.js index b1f0b7ca..ae4d7f62 100644 --- a/resources/lang/en/locale.js +++ b/resources/lang/en/locale.js @@ -62,7 +62,7 @@ setAsPublic: 'Set as Public', setPublicNotice: 'Sure to set this as public texture?', - deleteNotice: 'Are you sure to delete this texture? Scores will be returned.' + deleteNotice: 'Are you sure to delete this texture?' }, user: { signInRemainingTime: 'Available after :time hours', diff --git a/resources/lang/en/user.yml b/resources/lang/en/user.yml index f49dc4b6..a9b019df 100644 --- a/resources/lang/en/user.yml +++ b/resources/lang/en/user.yml @@ -16,10 +16,11 @@ score-intro: title: What is score? introduction: | We use score system to prevent the behaviors like uplaoding huge amount of textures and registering players casually. - Both adding players and uplaoding textures will consume your score. The score will be returned if you deleted them. - Adding textures from skin library to your closet will not decline your score. + Both adding players and uplaoding textures will consume your score. :return-score The inital score of user on this site is :initial_score, you can acquire :score-from ~ :score-to scores by signing in. + will-return-score: The score will be returned if you deleted them. + no-return-score: But the score will NOT be returned if you deleted them. rates: storage: :score scores = 1 KB storage player: :score scores = 1 player diff --git a/resources/lang/zh_CN/locale.js b/resources/lang/zh_CN/locale.js index 832b554b..d68cb06b 100644 --- a/resources/lang/zh_CN/locale.js +++ b/resources/lang/zh_CN/locale.js @@ -62,7 +62,7 @@ setAsPublic: '设为公开', setPublicNotice: '要将此材质设置为公开吗?', - deleteNotice: '真的要删除此材质吗?积分将会被返还' + deleteNotice: '真的要删除此材质吗?' }, user: { signInRemainingTime: ':time 小时后可签到', diff --git a/resources/lang/zh_CN/user.yml b/resources/lang/zh_CN/user.yml index f6205a16..ad7b9861 100644 --- a/resources/lang/zh_CN/user.yml +++ b/resources/lang/zh_CN/user.yml @@ -22,10 +22,12 @@ score-intro: 「贯彻爱与真实的。。呸!」上面只是卖下萌~ 为了不出现用户一个劲上传材质导致存储空间爆满,我们决定启用积分系统。 - 添加角色以及上传材质都会消耗积分,而删除已经添加的角色和已上传的材质时积分将会被返还。 + 添加角色以及上传材质都会消耗积分,:return-score。 本站用户初始积分为 :initial_score,每日签到可以随机获得 :score-from ~ :score-to 积分 添加皮肤库里的材质到衣柜不消耗积分。 + will-return-score: 而删除已经添加的角色和已上传的材质时积分将会被返还 + no-return-score: 但删除已经添加的角色和已上传的材质时积分不会被返还 rates: storage: :score 积分 = 1 KB 存储空间 player: :score 积分 = 1 个角色 diff --git a/resources/views/user/index.tpl b/resources/views/user/index.tpl index 22d3bdb4..aaa7aeb9 100644 --- a/resources/views/user/index.tpl +++ b/resources/views/user/index.tpl @@ -110,7 +110,8 @@ {!! nl2br(trans('user.score-intro.introduction', [ 'initial_score' => option('user_initial_score'), 'score-from' => $from, - 'score-to' => $to + 'score-to' => $to, + 'return-score' => option('return_score') ? trans('user.score-intro.will-return-score') : trans('user.score-intro.no-return-score') ])) !!}
    From 8056216d3f1d88d0abcffa30fd63f3e329196360 Mon Sep 17 00:00:00 2001 From: gplane Date: Sat, 22 Apr 2017 23:35:25 +0800 Subject: [PATCH 05/39] Fix score calculation --- app/Http/Controllers/SkinlibController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/SkinlibController.php b/app/Http/Controllers/SkinlibController.php index 7e7a4bba..4cb56c02 100644 --- a/app/Http/Controllers/SkinlibController.php +++ b/app/Http/Controllers/SkinlibController.php @@ -153,6 +153,7 @@ class SkinlibController extends Controller $t->upload_at = Utils::getTimeFormatted(); $cost = $t->size * (($t->public == "1") ? Option::get('score_per_storage') : Option::get('private_score_per_storage')); + $cost += option('score_per_closet_item'); if ($this->user->getScore() < $cost) return json(trans('skinlib.upload.lack-score'), 7); @@ -197,8 +198,15 @@ class SkinlibController extends Controller Storage::delete($result['hash']); if (option('return_score')) { - if ($result->public == 1) + if ($result->public == 1) { $this->user->setScore($result->size * Option::get('score_per_storage'), 'plus'); + foreach (Closet::all() as $closet) { + if ($closet->has($result->tid)) { + $closet->remove($result->tid); + User::find($closet->uid)->setScore(option('score_per_closet_item'), 'plus'); + } + } + } else $this->user->setScore($result->size * Option::get('private_score_per_storage'), 'plus'); } From 80f82b4b8753f6d1a02d02b42a87ea98b4fed184 Mon Sep 17 00:00:00 2001 From: gplane Date: Sat, 22 Apr 2017 23:38:59 +0800 Subject: [PATCH 06/39] Fix text about banning user --- resources/assets/src/scripts/admin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/src/scripts/admin.js b/resources/assets/src/scripts/admin.js index f31ae36b..9abba6a0 100644 --- a/resources/assets/src/scripts/admin.js +++ b/resources/assets/src/scripts/admin.js @@ -534,10 +534,10 @@ function initUsersTable() { } if (row.permission === -1) { bannedOption = `
  • -
  • ${trans('admin.ban')}
  • `; +
  • ${trans('admin.unban')}
  • `; } else { bannedOption = `
  • -
  • ${trans('admin.unban')}
  • `; +
  • ${trans('admin.ban')}
  • `; } } From 7607beebaf6915dd3d01fa16016c2d9b434d202f Mon Sep 17 00:00:00 2001 From: gplane Date: Sun, 23 Apr 2017 11:46:51 +0800 Subject: [PATCH 07/39] Use sweetalert2 instead of built-in function --- resources/assets/src/scripts/admin.js | 228 ++++++++++++++------------ 1 file changed, 124 insertions(+), 104 deletions(-) diff --git a/resources/assets/src/scripts/admin.js b/resources/assets/src/scripts/admin.js index 9abba6a0..8767b43c 100644 --- a/resources/assets/src/scripts/admin.js +++ b/resources/assets/src/scripts/admin.js @@ -54,67 +54,75 @@ $('#color-submit').click(function() { }); function changeUserEmail(uid) { - var email = prompt(trans('admin.newUserEmail')); - - if (!email) return; - - $.ajax({ - type: "POST", - url: "./users?action=email", - dataType: "json", - data: { 'uid': uid, 'email': email }, - success: function(json) { - if (json.errno == 0) { - $($('tr#'+uid+' > td')[1]).html(email); - toastr.success(json.msg); - } else { - toastr.warning(json.msg); - } - }, - error: showAjaxError + let dom = $(`tr#${uid} > td:nth-child(2)`); + swal({ + text: trans('admin.newUserEmail'), + showCancelButton: true, + input: 'text', + inputValue: dom.text() + }).then(email => { + $.ajax({ + type: "POST", + url: "./users?action=email", + dataType: "json", + data: { 'uid': uid, 'email': email }, + success: json => { + if (json.errno == 0) { + dom.text(email); + toastr.success(json.msg); + } else { + toastr.warning(json.msg); + } + }, + error: showAjaxError + }); }); } function changeUserNickName(uid) { - var nickname = prompt(trans('admin.newUserNickname')); - - if (!nickname) return; - - $.ajax({ - type: "POST", - url: "./users?action=nickname", - dataType: "json", - data: { 'uid': uid, 'nickname': nickname }, - success: function(json) { - if (json.errno == 0) { - $($('tr#'+uid+' > td')[2]).html(nickname); - toastr.success(json.msg); - } else { - toastr.warning(json.msg); - } - }, - error: showAjaxError + let dom = $(`tr#${uid} > td:nth-child(3)`); + swal({ + text: trans('admin.newUserNickname'), + showCancelButton: true, + input: 'text', + inputValue: dom.text() + }).then(nickname => { + $.ajax({ + type: "POST", + url: "./users?action=nickname", + dataType: "json", + data: { 'uid': uid, 'nickname': nickname }, + success: json => { + if (json.errno == 0) { + dom.text(nickname); + toastr.success(json.msg); + } else { + toastr.warning(json.msg); + } + }, + error: showAjaxError + }); }); } function changeUserPwd(uid) { - var password = prompt(trans('admin.newUserPassword')); - - if (!password) return; - - $.ajax({ - type: "POST", - url: "./users?action=password", - dataType: "json", - data: { 'uid': uid, 'password': password }, - success: function(json) { - if (json.errno == 0) - toastr.success(json.msg); - else - toastr.warning(json.msg); - }, - error: showAjaxError - }); + swal({ + text: trans('admin.newUserPassword'), + showCancelButton: true, + input: 'password', + }).then(password => { + return Promise.resolve($.ajax({ + type: "POST", + url: "./users?action=password", + dataType: "json", + data: { 'uid': uid, 'password': password } + })); + }).then(json => { + if (json.errno == 0) + toastr.success(json.msg); + else + toastr.warning(json.msg); + }).catch(error => showAjaxError); } function changeUserScore(uid, score) { @@ -182,23 +190,25 @@ function changeAdminStatus(uid) { } function deleteUserAccount(uid) { - if (!window.confirm(trans('admin.deleteUserNotice'))) return; - - $.ajax({ - type: "POST", - url: "./users?action=delete", - dataType: "json", - data: { 'uid': uid }, - success: function(json) { - if (json.errno == 0) { - $('tr#'+uid).remove(); - toastr.success(json.msg); - } else { - toastr.warning(json.msg); - } - }, - error: showAjaxError - }); + swal({ + text: trans('admin.deleteUserNotice'), + type: 'warning', + showCancelButton: true + }).then(() => { + return Promise.resolve($.ajax({ + type: "POST", + url: "./users?action=delete", + dataType: "json", + data: { 'uid': uid } + })) + }).then(json => { + if (json.errno == 0) { + $('tr#' + uid).remove(); + toastr.success(json.msg); + } else { + toastr.warning(json.msg); + } + }).catch(error => showAjaxError); } $('body').on('keypress', '.score', function(event){ @@ -275,45 +285,55 @@ function ajaxChangeTexture(pid) { } function changeOwner(pid) { - var uid = prompt(trans('admin.changePlayerOwner')); - - if (!uid) return; - - $.ajax({ - type: "POST", - url: "./players?action=owner", - dataType: "json", - data: { 'pid': pid, 'uid': uid }, - success: function(json) { - if (json.errno == 0) { - $($('#'+pid).children()[1]).text(uid); - toastr.success(json.msg); - } else { - toastr.warning(json.msg); - } - }, - error: showAjaxError + let dom = $(`#${pid} > td:nth-child(2)`); + swal({ + text: trans('admin.changePlayerOwner'), + input: 'number', + inputValue: dom.text(), + showCancelButton: true + }).then(uid => { + $.ajax({ + type: "POST", + url: "./players?action=owner", + dataType: "json", + data: { 'pid': pid, 'uid': uid }, + success: function (json) { + if (json.errno == 0) { + $($('#' + pid).children()[1]).text(uid); + toastr.success(json.msg); + } else { + toastr.warning(json.msg); + } + }, + error: showAjaxError + }); }); } function deletePlayer(pid) { - if (!window.confirm(trans('admin.deletePlayerNotice'))) return; + swal({ + text: trans('admin.deletePlayerNotice'), + type: 'warning', + showCancelButton: true + }).then(() => { + return Promise.resolve($.ajax({ + type: "POST", + url: "./players?action=delete", + dataType: "json", + data: { 'pid': pid }, + success: function (json) { - $.ajax({ - type: "POST", - url: "./players?action=delete", - dataType: "json", - data: { 'pid': pid }, - success: function(json) { - if (json.errno == 0) { - $('tr#'+pid).remove(); - toastr.success(json.msg); - } else { - toastr.warning(json.msg); - } - }, - error: showAjaxError - }); + }, + error: showAjaxError + })) + }).then(json => { + if (json.errno == 0) { + $('tr#' + pid).remove(); + toastr.success(json.msg); + } else { + toastr.warning(json.msg); + } + }).catch(error => showAjaxError); } function enablePlugin(name) { From f53bb7acb6bf5a81553bbf4e33006a476db0ddc4 Mon Sep 17 00:00:00 2001 From: gplane Date: Sun, 23 Apr 2017 23:58:22 +0800 Subject: [PATCH 08/39] Optimize closet 1. Use jqPaginator 2. Use CSR for closet 3. Use AJAX for closet 4. Just type to search instead of pressing ENTER key 5. Link to skin library is according to current category when closet is empty 6. Texture indicator shows category of texture --- app/Http/Controllers/ClosetController.php | 41 ++++--- app/Http/Routes/web.php | 1 + bower.json | 7 +- gulpfile.js | 2 + resources/assets/src/scripts/user.js | 130 ++++++++++++++++++++-- resources/lang/en/locale.js | 11 +- resources/lang/en/user.yml | 4 +- resources/lang/zh_CN/locale.js | 11 +- resources/lang/zh_CN/user.yml | 4 +- resources/views/user/closet.tpl | 43 ++----- resources/views/vendor/closet-items.tpl | 30 ----- 11 files changed, 180 insertions(+), 104 deletions(-) delete mode 100644 resources/views/vendor/closet-items.tpl diff --git a/app/Http/Controllers/ClosetController.php b/app/Http/Controllers/ClosetController.php index 5f07b80b..7e35742c 100644 --- a/app/Http/Controllers/ClosetController.php +++ b/app/Http/Controllers/ClosetController.php @@ -25,43 +25,40 @@ class ClosetController extends Controller $this->closet = new Closet(session('uid')); } - public function index(Request $request) + public function index() + { + return view('user.closet')->with('user', app('user.current')); + } + + public function getClosetData(Request $request) { $category = $request->input('category', 'skin'); - $page = $request->input('page', 1); - $page = $page <= 0 ? 1 : $page; + $page = abs($request->input('page', 1)); $q = $request->input('q', null); $items = []; if ($q) { - foreach (['skin', 'cape'] as $category) { - // do search - foreach ($this->closet->getItems($category) as $item) { - if (strstr($item->name, $q)) { - $items[$category][] = $item; - } + // do search + foreach ($this->closet->getItems($category) as $item) { + if (stristr($item->name, $q)) { + $items[] = $item; } } } else { - $items['skin'] = $this->closet->getItems('skin'); - $items['cape'] = $this->closet->getItems('cape'); + $items = $this->closet->getItems($category); } // pagination - $total_pages = []; + $total_pages = ceil(count($items) / 6); - foreach ($items as $key => $value) { - $total_pages[] = ceil(count($items[$key]) / 6); - $items[$key] = array_slice($value, ($page-1)*6, 6); - } + $items = array_slice($items, ($page - 1) * 6, 6); - return view('user.closet')->with('items', $items) - ->with('page', $page) - ->with('q', $q) - ->with('category', $category) - ->with('total_pages', $total_pages ? max($total_pages) : 0) - ->with('user', app('user.current')); + return response()->json([ + 'category' => $category, + 'items' => $items, + 'total_pages' => $total_pages + ]); } public function info() diff --git a/app/Http/Routes/web.php b/app/Http/Routes/web.php index b512ae65..d2b2dad1 100644 --- a/app/Http/Routes/web.php +++ b/app/Http/Routes/web.php @@ -65,6 +65,7 @@ Route::group(['middleware' => 'auth', 'prefix' => 'user'], function () // Closet Route::get ('/closet', 'ClosetController@index'); + Route::get ('/closet-data', 'ClosetController@getClosetData'); Route::post('/closet/add', 'ClosetController@add'); Route::post('/closet/remove', 'ClosetController@remove'); Route::post('/closet/rename', 'ClosetController@rename'); diff --git a/bower.json b/bower.json index 867479f8..c4771d4e 100644 --- a/bower.json +++ b/bower.json @@ -24,6 +24,11 @@ "font-awesome": "Font-Awesome#^4.6.3", "bootstrap-fileinput": "^4.3.3", "bootstrap": "^3.3.6", - "sweetalert2": "^4.1.6" + "sweetalert2": "^4.1.6", + "jqPaginator": "^1.2.0", + "lodash": "^4.17.4" + }, + "resolutions": { + "jquery": "1.9.1 - 3" } } diff --git a/gulpfile.js b/gulpfile.js index d1a8c8af..836178e9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,6 +25,7 @@ var srcPath = 'resources/assets/src/'; var distPath = 'resources/assets/dist/'; var vendorScripts = [ + 'lodash/dist/lodash.min.js', 'jquery/dist/jquery.min.js', 'bootstrap/dist/js/bootstrap.min.js', 'AdminLTE/dist/js/app.min.js', @@ -35,6 +36,7 @@ var vendorScripts = [ 'toastr/toastr.min.js', 'es6-promise/es6-promise.auto.min.js', 'sweetalert2/dist/sweetalert2.min.js', + 'jqPaginator/dist/jqPaginator.min.js', 'resources/assets/dist/scripts/general.js', ]; diff --git a/resources/assets/src/scripts/user.js b/resources/assets/src/scripts/user.js index 9ed9685e..545873d2 100644 --- a/resources/assets/src/scripts/user.js +++ b/resources/assets/src/scripts/user.js @@ -18,13 +18,13 @@ $('body').on('click', '#preview-switch', () => { TexturePreview.previewType == '3D' ? TexturePreview.show2dPreview() : TexturePreview.show3dPreview(); }); -var selected = []; +let skinSelected = false, capeSelected = false; $('body').on('click', '.item-body', function () { $('.item-selected').parent().removeClass('item-selected'); $(this).parent().addClass('item-selected'); - let tid = $(this).parent().attr('tid'); + const tid = $(this).parent().attr('tid'); $.ajax({ type: "POST", @@ -33,24 +33,95 @@ $('body').on('click', '.item-body', function () { success: (json) => { if (json.type == "cape") { MSP.changeCape('../textures/' + json.hash); - selected['cape'] = tid; + capeSelected = true; } else { MSP.changeSkin('../textures/' + json.hash); - selected['skin'] = tid; + skinSelected = true; } - selected.length = 0; - - ['skin', 'cape'].forEach((key) => { - if (selected[key] !== undefined) selected.length++; - - $('#textures-indicator').html(selected.length); - }); + if (skinSelected && capeSelected) + $('#textures-indicator').text(`${trans('general.skin')} & ${trans('general.cape')}`); + else if (skinSelected) + $('#textures-indicator').text(trans('general.skin')); + else if (capeSelected) + $('#textures-indicator').text(trans('general.cape')); }, error: showAjaxError }); }); +$('body').on('click', '.category-switch', () => { + const category = $('a[href="#skin-category"]').parent().hasClass('active') ? 'cape' : 'skin'; + const page = parseInt($('#closet-paginator').attr(`last-${category}-page`)); + const search = $('input[name=q]').val(); + reloadCloset(category, page, search); +}); + +function renderClosetItemComponent(item, rootPath) { + return ` +
    +
    + +
    + +
    `; +} + +function renderCloset(items, category) { + const rootPath = /(^https?.*)\/user\/closet/.exec(window.location.href)[1]; + const search = $('input[name=q]').val(); + let container = $(`#${category}-category`); + container.html(''); + if (items.length === 0) { + $('#closet-paginator').hide(); + if (search === '') { + container.html(`
    + ${trans('user.emptyClosetMsg', { url: rootPath + '/skinlib?filter=' + category })}
    `); + } else { + container.html(`
    ${trans('general.noResult')}
    `); + } + } else { + $('#closet-paginator').show(); + for (const item of items) { + container.append(renderClosetItemComponent(item, rootPath)); + } + } +} + +function reloadCloset(category, page, search) { + Promise.resolve($.ajax({ + type: 'GET', + url: /(^https?.*)\/user\/closet/.exec(window.location.href)[1] + '/user/closet-data', + dataType: 'json', + data: { + category: category, + page: page, + q: search + } + })).then(result => { + renderCloset(result.items, result.category); + let paginator = $('#closet-paginator'); + paginator.attr(`last-${result.category}-page`, page); + paginator.jqPaginator('option', { + currentPage: page, + totalPages: result.total_pages + }); + }).catch(error => showAjaxError); +} + function showPlayerTexturePreview(pid) { $.ajax({ type: "POST", @@ -179,6 +250,43 @@ $(document).ready(function() { confirmButtonText: trans('general.confirm'), cancelButtonText: trans('general.cancel') }); + + if (window.location.pathname.includes('/user/closet')) { + Promise.resolve($.ajax({ + type: 'GET', + url: /(^https?.*)\/user\/closet/.exec(window.location.href)[1] + '/user/closet-data', + dataType: 'json' + })).then(result => { + renderCloset(result.items, result.category); + $('#closet-paginator').jqPaginator({ + totalPages: result.total_pages, + visiblePages: 5, + currentPage: 1, + first: '
  • «
  • ', + prev: '
  • ', + next: '
  • ', + last: '
  • »
  • ', + page: '
  • {{page}}
  • ', + wrapper: '
      ', + onPageChange: page => { + reloadCloset( + $('#skin-category').hasClass('active') ? 'skin' : 'cape', + page, + $('input[name=q]').val() + ); + } + }); + }).catch(error => showAjaxError); + + $('input[name=q]').on('input', _.debounce(() => { + const category = $('#skin-category').hasClass('active') ? 'skin' : 'cape'; + reloadCloset( + category, + 1, + $('input[name=q]').val() + ); + }, 350)); + } }); function setTexture() { diff --git a/resources/lang/en/locale.js b/resources/lang/en/locale.js index ae4d7f62..80fe4ac5 100644 --- a/resources/lang/en/locale.js +++ b/resources/lang/en/locale.js @@ -68,6 +68,11 @@ signInRemainingTime: 'Available after :time hours', // Closet + emptyClosetMsg: '

      Nothing in your closet...

      Why not explore the Skin Library for a while?

      ', + renameItem: 'Rename item', + removeItem: 'Remove from closet', + setAsAvatar: 'Set as avatar', + viewInSkinlib: 'View in skin library', switch2dPreview: 'Switch to 2D Preview', switch3dPreview: 'Switch to 3D Preview', removeFromClosetNotice: 'Sure to remove this texture from your closet?', @@ -153,10 +158,14 @@ extracting: 'Extracting update package..' }, general: { + skin: 'Skin', + cape: 'Cape', fatalError: 'Fatal Error (Please contact the author)', confirmLogout: 'Sure to log out?', confirm: 'OK', - cancel: 'Cancel' + cancel: 'Cancel', + more: 'More', + noResult: 'No result.' } }; })(window.jQuery); diff --git a/resources/lang/en/user.yml b/resources/lang/en/user.yml index a9b019df..761d28e6 100644 --- a/resources/lang/en/user.yml +++ b/resources/lang/en/user.yml @@ -28,13 +28,11 @@ score-intro: closet: upload: Upload Texture search: Search Texture + type-to-search: Type to search switch-category: Switch Category view: View in skin library more: More set-avatar: Set as avatar - empty-msg: | -

      Nothing in your closet...

      -

      Why not explore the Skin Library for a while?

      use-as: button: Apply... diff --git a/resources/lang/zh_CN/locale.js b/resources/lang/zh_CN/locale.js index d68cb06b..4a9fa546 100644 --- a/resources/lang/zh_CN/locale.js +++ b/resources/lang/zh_CN/locale.js @@ -68,6 +68,11 @@ signInRemainingTime: ':time 小时后可签到', // Closet + emptyClosetMsg: '

      衣柜里啥都没有哦~

      皮肤库看看吧~

      ', + renameItem: '重命名物品', + removeItem: '从衣柜中移除', + setAsAvatar: '设为头像', + viewInSkinlib: '在皮肤库中查看', switch2dPreview: '切换 2D 预览', switch3dPreview: '切换 3D 预览', removeFromClosetNotice: '确定要从衣柜中移除此材质吗?', @@ -153,10 +158,14 @@ extracting: '正在解压更新包' }, general: { + skin: '皮肤', + cape: '披风', fatalError: '严重错误(请联系作者)', confirmLogout: '确定要登出吗?', confirm: '确定', - cancel: '取消' + cancel: '取消', + more: '更多', + noResult: '无结果' }, vendor: { datatables: { diff --git a/resources/lang/zh_CN/user.yml b/resources/lang/zh_CN/user.yml index ad7b9861..19e8ffc7 100644 --- a/resources/lang/zh_CN/user.yml +++ b/resources/lang/zh_CN/user.yml @@ -35,13 +35,11 @@ score-intro: closet: upload: 上传材质 search: 搜索材质 + type-to-search: 输入即搜索 switch-category: 切换分类 view: 在皮肤库中查看 more: 更多 set-avatar: 设为头像 - empty-msg: | -

      衣柜里啥都没有哦~

      -

      皮肤库看看吧~

      use-as: button: 使用... diff --git a/resources/views/user/closet.tpl b/resources/views/user/closet.tpl index 219e1426..993fbaa6 100644 --- a/resources/views/user/closet.tpl +++ b/resources/views/user/closet.tpl @@ -26,51 +26,30 @@ - +
      diff --git a/resources/views/vendor/closet-items.tpl b/resources/views/vendor/closet-items.tpl deleted file mode 100644 index 6f0f4bf4..00000000 --- a/resources/views/vendor/closet-items.tpl +++ /dev/null @@ -1,30 +0,0 @@ -@forelse ($items as $item) -
      -
      - -
      - -
      -@empty -
      - @if($q) - {{ trans('skinlib.general.no-result') }} - @else - {!! trans('user.closet.empty-msg', ['url' => url('skinlib')]) !!} - @endif -
      - -@endforelse From 874f4bd6811e84d5b8d946aaa45b91f30ca14ea1 Mon Sep 17 00:00:00 2001 From: gplane Date: Mon, 24 Apr 2017 11:35:55 +0800 Subject: [PATCH 09/39] Remove file suffix when uploading --- resources/assets/src/scripts/skinlib.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/assets/src/scripts/skinlib.js b/resources/assets/src/scripts/skinlib.js index 631df5f2..9634475d 100644 --- a/resources/assets/src/scripts/skinlib.js +++ b/resources/assets/src/scripts/skinlib.js @@ -158,8 +158,9 @@ function handleFiles(files, type) { (type == "skin") ? MSP.changeSkin(img.src) : MSP.changeCape(img.src); let domTextureName = $('#name'); if (domTextureName.val() === '' || domTextureName.val() === domTextureName.attr('data-last-file-name')) { - domTextureName.attr('data-last-file-name', file.name); - domTextureName.val(file.name); + const fileName = file.name.replace(/\.[Pp][Nn][Gg]$/, ''); + domTextureName.attr('data-last-file-name', fileName); + domTextureName.val(fileName); } }; img.onerror = () => toastr.warning(trans('skinlib.fileExtError')); From 5c7b8bf6b29445ba3bb572e7f2b25e99042badfd Mon Sep 17 00:00:00 2001 From: gplane Date: Mon, 24 Apr 2017 17:02:29 +0800 Subject: [PATCH 10/39] Optimize filter of skin library --- app/Http/Controllers/SkinlibController.php | 33 +++++++++++----------- resources/views/skinlib/master.tpl | 10 +++---- resources/views/skinlib/show.tpl | 2 +- resources/views/vendor/breadcrumb.tpl | 9 +++--- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/SkinlibController.php b/app/Http/Controllers/SkinlibController.php index 4cb56c02..9a18d659 100644 --- a/app/Http/Controllers/SkinlibController.php +++ b/app/Http/Controllers/SkinlibController.php @@ -32,41 +32,41 @@ class SkinlibController extends Controller { $filter = $request->input('filter', 'skin'); $sort = $request->input('sort', 'time'); - $uid = $request->input('uid', session('uid')); - $page = $request->input('page', 1); - $page = $page <= 0 ? 1 : $page; + $uid = intval($request->input('uid', 0)); + $page = $request->input('page', 1) <= 0 ? 1 : $request->input('page', 1); $sort_by = ($sort == "time") ? "upload_at" : $sort; if ($filter == "skin") { - $textures = Texture::where(function($query) { - $query->where('type', '=', 'steve') - ->orWhere('type', '=', 'alex'); - })->orderBy($sort_by, 'desc'); - - } elseif ($filter == "user") { - $textures = Texture::where('uploader', $uid)->orderBy($sort_by, 'desc'); - + $textures = Texture::where('type', 'steve')->orWhere('type', 'alex'); } else { - $textures = Texture::where('type', $filter)->orderBy($sort_by, 'desc'); + $textures = Texture::where('type', $filter); + } + + $textures = $textures->orderBy($sort_by, 'desc')->get(); + + if ($uid != 0) { + $textures = $textures->where('uploader', $uid); } if (!is_null($this->user)) { // show private textures when show uploaded textures of current user - if (!$this->user->isAdmin()) - $textures = $textures->where('public', '1') - ->orWhere('uploader', $this->user->uid); + if ($uid != $this->user->uid && !$this->user->isAdmin()) { + $textures = $textures->where('public', 1) + ->merge($textures->where('uploader', $this->user->uid)); + } } else { $textures = $textures->where('public', '1'); } $total_pages = ceil($textures->count() / 20); - $textures = $textures->skip(($page - 1) * 20)->take(20)->get(); + $textures = $textures->slice(($page - 1) * 20); return view('skinlib.index')->with('user', $this->user) ->with('sort', $sort) ->with('filter', $filter) + ->with('uploader', $uid) ->with('textures', $textures) ->with('page', $page) ->with('total_pages', $total_pages); @@ -96,6 +96,7 @@ class SkinlibController extends Controller return view('skinlib.search')->with('user', $this->user) ->with('sort', $sort) ->with('filter', $filter) + ->with('uploader', 0) ->with('q', $q) ->with('textures', $textures); } diff --git a/resources/views/skinlib/master.tpl b/resources/views/skinlib/master.tpl index 30ce267c..1f8534fc 100644 --- a/resources/views/skinlib/master.tpl +++ b/resources/views/skinlib/master.tpl @@ -39,14 +39,14 @@ {{ trans('skinlib.general.filter') }}