From 7372f327d98afa76ddfe47ff2d9dde5671c1a8bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Tue, 26 Oct 2021 09:41:15 +0800 Subject: [PATCH] * code for task #43565. --- api/v1/entries/langs.php | 50 ++++++++++++++++++++++++++++++++++++++++ api/v1/entries/user.php | 9 +++++++- config/routes.php | 2 ++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 api/v1/entries/langs.php diff --git a/api/v1/entries/langs.php b/api/v1/entries/langs.php new file mode 100644 index 0000000000..09e1e66947 --- /dev/null +++ b/api/v1/entries/langs.php @@ -0,0 +1,50 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class langsEntry extends entry +{ + /** + * GET method. + * + * @access public + * @return void + */ + public function get() + { + $modules = $this->param('modules', ''); + $language = $this->param('lang', ''); + + if($language and !isset($this->config->langs[$language])) return $this->sendError(400, 'Error lang parameter'); + if(empty($modules)) return $this->sendError(400, 'Need modules'); + + if($language) $this->app->setClientLang($language); + + $modules = explode(',', $modules); + foreach($modules as $module) + { + if($module == 'all') + { + foreach(glob($this->app->getModuleRoot() . '*') as $modulePath) + { + if(!is_dir($modulePath)) continue; + + $moduleName = basename($modulePath); + $this->app->loadLang($moduleName); + } + break; + } + + $this->app->loadLang($module); + } + + return $this->send(200, array('lang' => $this->lang)); + } +} diff --git a/api/v1/entries/user.php b/api/v1/entries/user.php index c543aac41d..440e9d900f 100644 --- a/api/v1/entries/user.php +++ b/api/v1/entries/user.php @@ -189,8 +189,15 @@ class userEntry extends Entry if($data->status == 'success') { + $stories = array(); + foreach($data->data->stories as $story) + { + $story->status = array('code' => $story->status, 'name' => $this->lang->story->statusList[$story->status]); + $stories[$story->id] = $story; + } + $info->story['total'] = $data->data->pager->recTotal; - $info->story['stories'] = array_values((array)$data->data->stories); + $info->story['stories'] = array_values($stories); } break; diff --git a/config/routes.php b/config/routes.php index 53e4fec658..05abfdf681 100644 --- a/config/routes.php +++ b/config/routes.php @@ -5,6 +5,8 @@ $routes = array(); $routes['/tokens'] = 'tokens'; +$routes['/langs'] = 'langs'; + $routes['/tabs/:module'] = 'tabs'; $routes['/configurations'] = 'configs';