diff --git a/db/update18.2.sql b/db/update18.2.sql deleted file mode 100644 index 8191f3d34d..0000000000 --- a/db/update18.2.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `zt_lang` ADD `systemMode` varchar(10) COLLATE 'utf8_general_ci' NOT NULL DEFAULT 'ALM'; diff --git a/framework/router.class.php b/framework/router.class.php index 71e76c2776..6696361244 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -111,7 +111,7 @@ class router extends baseRouter /* Replace main nav lang. */ if($moduleName == 'common' and $this->dbh and !empty($this->config->db->name)) { - $customMenus = $this->dbh->query('SELECT * FROM' . TABLE_LANG . "WHERE `module`='common' AND `section`='mainNav' AND `lang`='{$this->clientLang}' AND `vision`='{$this->config->vision}' AND `systemMode`='{$this->config->systemMode}'")->fetchAll(); + $customMenus = $this->dbh->query('SELECT * FROM' . TABLE_LANG . "WHERE `module`='common' AND `section`='mainNav' AND `lang`='{$this->clientLang}' AND `vision`='{$this->config->vision}'")->fetchAll(); foreach($customMenus as $menu) { $menuKey = $menu->key; @@ -297,7 +297,7 @@ class router extends baseRouter } /* Replace common lang. */ - $customMenus = $this->dbh->query('SELECT * FROM' . TABLE_LANG . "WHERE `module`='common' AND `lang`='{$this->clientLang}' AND `section`='' AND `vision`='{$config->vision}' AND `systemMode`='{$config->systemMode}'")->fetchAll(); + $customMenus = $this->dbh->query('SELECT * FROM' . TABLE_LANG . "WHERE `module`='common' AND `lang`='{$this->clientLang}' AND `section`='' AND `vision`='{$config->vision}'")->fetchAll(); foreach($customMenus as $menu) if(isset($lang->{$menu->key})) $lang->{$menu->key} = $menu->value; } } diff --git a/module/custom/model.php b/module/custom/model.php index 0f45ad973d..0930adf920 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -23,7 +23,7 @@ class customModel extends model try { - $sql = $this->dao->select('*')->from(TABLE_LANG)->where('`lang`')->in("$currentLang,all")->andWhere('vision')->eq($this->config->vision)->andWhere('systemMode')->eq($this->config->systemMode)->orderBy('lang,id')->get(); + $sql = $this->dao->select('*')->from(TABLE_LANG)->where('`lang`')->in("$currentLang,all")->andWhere('vision')->eq($this->config->vision)->orderBy('lang,id')->get(); $stmt = $this->dbh->query($sql); $allCustomLang = array(); diff --git a/module/dev/control.php b/module/dev/control.php index 6f302b651c..960de30b3e 100644 --- a/module/dev/control.php +++ b/module/dev/control.php @@ -89,12 +89,41 @@ class dev extends control * @access public * @return void */ - public function langItem($type = 'common', $module = 'my', $method = 'browse') + public function langItem($type = 'common', $module = '', $method = '', $language = 'zh_cn') { - $this->dev->loadLang(); - $this->view->title = $this->lang->langItem; - $this->view->type = $type; - $this->view->featureBar = $this->lang->dev->featureBar['langItem']; + $language = str_replace('_', '-', $language); + $moduleName = $module; + if($type == 'common') $moduleName = 'common'; + if($type == 'second') $moduleName = $module . 'Menu'; + if($type == 'third') $moduleName = $module . 'subMenu'; + + if($_POST) + { + $section = ''; + if($type == 'common') $section = '§ion='; + if($type == 'first') $section = '§ion=mainNav'; + $this->loadModel('custom')->deleteItems("lang={$language}&module={$moduleName}&vision={$this->config->vision}{$section}"); + + $data = fixer::input('post')->get(); + foreach($data as $langKey => $customedLang) + { + if(strpos($langKey, "{$moduleName}_") !== 0) continue; + if(empty($customedLang)) continue; + + $this->custom->setItem("{$language}." . str_replace('_', '.', $langKey), $customedLang); + } + return $this->send(array('result' => 'success', 'locate' => 'reload', 'message' => $this->lang->saveSuccess)); + } + + $this->dev->loadDefaultLang(); + + $this->view->title = $this->lang->langItem; + $this->view->type = $type; + $this->view->featureBar = $this->lang->dev->featureBar['langItem']; + $this->view->originalLangs = $this->dev->getOriginalLang($type, $module, str_replace('_', '-', $language)); + $this->view->customedLangs = $this->dev->getCustomedLang($type, $module, str_replace('_', '-', $language)); + $this->view->moduleName = $moduleName; + $this->view->language = $language; $this->display(); } } diff --git a/module/dev/lang/zh-cn.php b/module/dev/lang/zh-cn.php index a194e1843b..a277760592 100644 --- a/module/dev/lang/zh-cn.php +++ b/module/dev/lang/zh-cn.php @@ -19,6 +19,9 @@ $lang->dev->paramMailto = "填写帐号,多个账号用','分隔。"; $lang->dev->noteEditor = "编辑器功能因为安全原因被禁用。使用该功能,请到官网下载安装 扩展编辑器 插件。"; $lang->dev->noteTranslate = "翻译功能因为安全原因被禁用。使用该功能,请到官网下载安装 翻译 插件。"; +$lang->dev->UR = '用户需求'; +$lang->dev->SR = '研发需求'; + $lang->dev->fields = array(); $lang->dev->fields['id'] = '序号'; $lang->dev->fields['name'] = '字段'; diff --git a/module/dev/model.php b/module/dev/model.php index d370e620d4..42d5657139 100644 --- a/module/dev/model.php +++ b/module/dev/model.php @@ -284,6 +284,38 @@ class devModel extends model return $extPaths; } + public function getOriginalLang($type, $module = '', $language = 'zh-cn') + { + $originalLangs = array(); + if($type == 'common') + { + $projectKey = (int)$this->loadModel('setting')->getItem('owner=system&key=sprintConcept'); + $clientLang = $this->app->getClientLang(); + $originalLangs['productCommon'] = $this->config->productCommonList[$clientLang][PRODUCT_KEY]; + $originalLangs['projectCommon'] = $this->config->projectCommonList[$clientLang][PROJECT_KEY]; + $originalLangs['executionCommon'] = $this->config->executionCommonList[$clientLang][$projectKey]; + $originalLangs['URCommon'] = $this->lang->dev->UR; + $originalLangs['SRCommon'] = $this->lang->dev->SR; + } + + return $originalLangs; + } + + public function getCustomedLang($type, $module = '', $language = 'zh-cn') + { + $customedLangs = array(); + $clientLang = $this->app->getClientLang(); + if($type == 'common') + { + $customeds = $this->loadModel('custom')->getItems("lang={$clientLang}&module=common§ion=&vision={$this->config->vision}&systemMode={$this->config->systemMode}"); + foreach($customeds as $customed) $customedLangs[$customed->key] = $customed->value; + $customedLangs['URCommon'] = $this->lang->dev->UR == $this->lang->URCommon ? '' : $this->lang->URCommon; + $customedLangs['SRCommon'] = $this->lang->dev->SR == $this->lang->SRCommon ? '' : $this->lang->SRCommon; + } + + return $customedLangs; + } + /** * Trim asterisks and whitespace from the beginning and whitespace from the end of lines. * @@ -302,9 +334,12 @@ class devModel extends model * @access public * @return object */ - public function loadDefaultLang() + public function loadDefaultLang($language = 'zh-cn') { + $clientLang = $this->app->clientLang; + if($language != $clientLang) $this->app->clientLang = $language; $langFilesToLoad = $this->app->getMainAndExtFiles('common'); + if($language != $clientLang) $this->app->clientLang = $clientLang; if(empty($langFilesToLoad)) return false; $lang = new language(); diff --git a/module/dev/view/header.html.php b/module/dev/view/header.html.php index 9efce6496b..bca5b7c33b 100644 --- a/module/dev/view/header.html.php +++ b/module/dev/view/header.html.php @@ -2,4 +2,6 @@