diff --git a/app/Controllers/ClosetController.php b/app/Controllers/ClosetController.php index 3801a8cb..07848554 100644 --- a/app/Controllers/ClosetController.php +++ b/app/Controllers/ClosetController.php @@ -44,15 +44,14 @@ class ClosetController extends BaseController public function add() { - if (!is_numeric(\Utils::getValue('tid', $_POST))) - throw new E('Invalid parameters.', 1); + \Utils::checkPost(['tid', 'name']); - if ($this->closet->add($_POST['tid'])) { + if ($this->closet->add($_POST['tid'], $_POST['name'])) { $t = Texture::find($_POST['tid']); $t->likes += 1; $t->save(); - View::json('收藏成功~', 0); + View::json('材质 '.$_POST['name'].' 收藏成功~', 0); } } diff --git a/app/Controllers/SkinlibController.php b/app/Controllers/SkinlibController.php index 03e46a24..b95f517c 100644 --- a/app/Controllers/SkinlibController.php +++ b/app/Controllers/SkinlibController.php @@ -130,9 +130,12 @@ class SkinlibController extends BaseController if (!$results->isEmpty()) { foreach ($results as $result) { - if (($result['name'] == $t->name) && ($result['type'] == $t->type)) { - throw new E('The same file with same name has been already '. - 'uploaded by others. Try another filr or change your texture name.', 1); + if ($result->type == $t->type) { + View::json([ + 'errno' => 0, + 'msg' => '已经有人上传过这个材质了,直接添加到衣柜使用吧~', + 'tid' => $result->tid + ]); } } } diff --git a/app/Models/Closet.php b/app/Models/Closet.php index 47ca98fc..3bb55767 100644 --- a/app/Models/Closet.php +++ b/app/Models/Closet.php @@ -49,6 +49,9 @@ class Closet foreach ($this->textures as $texture) { $result = Texture::find($texture['tid']); if ($result) { + // user custom texture name + $result->name = $texture['name']; + if ($result->type == "cape") { $this->textures_cape[] = $result; } else { @@ -83,7 +86,7 @@ class Closet return $this->eloquent_model->amount; } - public function add($tid) + public function add($tid, $name) { foreach ($this->textures as $item) { if ($item['tid'] == $tid) @@ -91,8 +94,9 @@ class Closet } $this->textures[] = array( - 'tid' => $tid, - 'add_at' => Utils::getTimeFormatted() + 'tid' => $tid, + 'name' => $name, + 'add_at' => time() ); $this->eloquent_model->amount += 1; diff --git a/assets/src/js/skinlib.js b/assets/src/js/skinlib.js index 0e464691..e3db3eb7 100644 --- a/assets/src/js/skinlib.js +++ b/assets/src/js/skinlib.js @@ -1,21 +1,38 @@ /* * @Author: prpr * @Date: 2016-07-19 10:46:38 -* @Last Modified by: prpr -* @Last Modified time: 2016-07-21 15:59:34 +* @Last Modified by: printempw +* @Last Modified time: 2016-07-22 10:25:54 */ 'use strict'; function addToCloset(tid) { + var dom = '