From e6abea3f1dd4b6dc4efae05199a5b52ab7e8a2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Tue, 13 Mar 2018 18:52:49 +0900 Subject: [PATCH] Adding server-side timezones. --- app/Http/Controllers/BoardController.php | 59 +++++++++++++++++++++--- app/Http/Controllers/StoreController.php | 30 ++++++------ config/app.php | 4 +- 3 files changed, 72 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/BoardController.php b/app/Http/Controllers/BoardController.php index 4668584..fba5ba1 100644 --- a/app/Http/Controllers/BoardController.php +++ b/app/Http/Controllers/BoardController.php @@ -44,10 +44,32 @@ class BoardController extends Controller { } public function getForums() { // /api/rpc/board/forum/getforums - return DB::table('for_forums') - ->select('*') + $get = DB::table('for_forums') + ->select('id', 'last_uid', 'cat_id', 'title', 'description', 'threads', 'posts', 'last_date') ->orderBy('order', 'asc') ->get(); + + $res = array(); + $key = 0; + + setlocale(LC_ALL, 'ja_JP.utf8'); + + foreach ($get as $i) { + array_push($res, [ + 'key' => $key, + 'id' => $i->id, + 'last_uid' => $i->last_uid, + 'cat_id' => $i->cat_id, + 'title' => $i->title, + 'description' => $i->description, + 'threads' => $i->threads, + 'posts' => $i->posts, + 'last_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->last_date) + ]); + $key++; + } + + return $res; } public function getForum($id) { // /api/rpc/board/forum/getforum/id @@ -101,10 +123,33 @@ class BoardController extends Controller { } public function getForumsInCategory($cat_id) { // /api/rpc/board/forum/getforumsincategory/cat_id - return DB::table('for_forums') - ->select('*') + $get = DB::table('for_forums') + ->select('id', 'last_uid', 'cat_id', 'title', 'description', 'threads', 'posts', 'last_date') ->where('cat_id', $cat_id) + ->orderBy('order', 'asc') ->get(); + + $res = array(); + $key = 0; + + setlocale(LC_ALL, 'ja_JP.utf8'); + + foreach ($get as $i) { + array_push($res, [ + 'key' => $key, + 'id' => $i->id, + 'last_uid' => $i->last_uid, + 'cat_id' => $i->cat_id, + 'title' => $i->title, + 'description' => $i->description, + 'threads' => $i->threads, + 'posts' => $i->posts, + 'last_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->last_date) + ]); + $key++; + } + + return $res; } public function getTopics($for, $from, $to) { // /api/rpc/board/topic/gettopics/for/from/to @@ -597,16 +642,18 @@ class BoardController extends Controller { //$mess = preg_replace('/\/i', '', $i->message); $mess = $this->packageMessage($i->message); + setlocale(LC_ALL, 'ja_JP.utf8'); + array_push($udat, [ 'key' => $key, 'id' => $i->id, 'tid' => $i->top_id, 'uid' => $i->user_id, - 'post_date' => date('Y/m/d, G:i:s T', $i->post_date), + 'post_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', date($i->post_date)), 'message' => $mess, 'delete' => $i->delete, 'delreason' => $i->delreason, - 'lastedit' => date('Y/m/d, G:i:s T', $i->lastedit), + 'lastedit' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', date($i->lastedit)), 'lasteditUnix' => $i->lastedit, 'ipaddress' => $i->ipaddress, 'nolayout' => $i->nolayout, diff --git a/app/Http/Controllers/StoreController.php b/app/Http/Controllers/StoreController.php index 25094a1..eb39cc8 100644 --- a/app/Http/Controllers/StoreController.php +++ b/app/Http/Controllers/StoreController.php @@ -20,7 +20,6 @@ class StoreController extends Controller { // Game public function getGames() { // /api/rpc/store/game/getgames return DB::table('str_games_loc') - ->join('str_locale', 'str_locale.id', '=', 'str_games_loc.loc_id') ->join('str_games', 'str_games.id', '=', 'str_games_loc.ref_id') ->get(array( 'str_games.id', @@ -31,7 +30,6 @@ class StoreController extends Controller { public function getGame($id) { // /api/rpc/store/game/getgame/id return DB::table('str_games_loc') - ->join('str_locale', 'str_locale.id', '=', 'str_games_loc.loc_id') ->join('str_games', 'str_games.id', '=', 'str_games_loc.ref_id') ->where('str_games.id', $id) ->get(array( @@ -61,7 +59,6 @@ class StoreController extends Controller { // Category public function getCategories() { // /api/rpc/store/category/getcategories return DB::table('str_category_loc') - ->join('str_locale', 'str_locale.id', '=', 'str_category_loc.loc_id') ->join('str_category', 'str_category.id', '=', 'str_category_loc.ref_id') ->get(array( 'str_category.id', @@ -74,7 +71,6 @@ class StoreController extends Controller { public function getCategory($id) { // /api/rpc/store/category/getcategory/id return DB::table('str_category_loc') - ->join('str_locale', 'str_locale.id', '=', 'str_category_loc.loc_id') ->join('str_category', 'str_category.id', '=', 'str_category_loc.ref_id') ->where('str_category.id', $id) ->get(array( @@ -88,7 +84,6 @@ class StoreController extends Controller { public function getCategoriesOfGame($id) { // /api/rpc/store/category/getcategoriesofgame/id return DB::table('str_category_loc') - ->join('str_locale', 'str_locale.id', '=', 'str_category_loc.loc_id') ->join('str_category', 'str_category.id', '=', 'str_category_loc.ref_id') ->join('str_games', 'str_category.game_id', '=', 'str_games.id') ->where('str_games.id', $id) @@ -100,12 +95,14 @@ class StoreController extends Controller { } public function getGameOfCategory($id) { // /api/rpc/store/category/getgameofcategory/id - return DB::table('str_category') - ->join('str_games', 'str_category.game_id', '=', 'str_games.id') + return DB::table('str_games_loc') + ->join('str_games', 'str_games.id', '=', 'str_games_loc.ref_id') + ->join('str_category', 'str_category.game_id', '=', 'str_games.id') ->where('str_category.id', $id) ->get(array( 'str_games.id', - 'str_games.name' + 'str_games.name', + 'str_games_loc.name as altname' )); } @@ -124,17 +121,24 @@ class StoreController extends Controller { } public function getCategoryName($id) { // /api/rpc/store/category/getcategoryname/id - return DB::table('str_category') - ->select('name') - ->where('id', $id) - ->get(); + return DB::table('str_category_loc') + ->join('str_category', 'str_category.id', '=', 'str_category_loc.ref_id') + ->where('str_category.id', $id) + ->get(array( + 'str_category.name', + 'str_category_loc.name as altname' + )); } public function getCategoryNameOfEntry($id) { // /api/rpc/store/category/getcategorynameofentry/id return DB::table('str_file') ->join('str_category', 'str_category.id', '=', 'str_file.cat_id') + ->join('str_category_loc', 'str_category.id', '=', 'str_category_loc.ref_id') ->where('str_file.id', $id) - ->get(array('name')); + ->get(array( + 'str_category.name', + 'str_category_loc.name as altname' + )); } public function newCategory(Request $request) { // /api/rpc/store/category/newcategory diff --git a/config/app.php b/config/app.php index 801a0aa..bfcf870 100644 --- a/config/app.php +++ b/config/app.php @@ -79,7 +79,7 @@ return [ | */ - 'locale' => 'en', + 'locale' => 'ja', /* |-------------------------------------------------------------------------- @@ -92,7 +92,7 @@ return [ | */ - 'fallback_locale' => 'en', + 'fallback_locale' => 'ja', /* |--------------------------------------------------------------------------