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/base/router.class.php b/framework/base/router.class.php index 5c51cbe7ef..fc837a7ccd 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -2506,29 +2506,9 @@ class baseRouter if($config and (!isset($config->$moduleName) or !is_object($config->$moduleName))) $config->$moduleName = new stdclass(); - /* 初始化数组。Init the variables. */ - $extConfigFiles = array(); - $commonExtConfigFiles = array(); - $siteExtConfigFiles = array(); - - /* 先获得模块的主配置文件。Get the main config file for current module first. */ - $mainConfigFile = $this->getModulePath($appName, $moduleName) . 'config.php'; - - /* 查找扩展配置文件。Get extension config files. */ - if($config->framework->extensionLevel > 0) $extConfigPath = $this->getModuleExtPath($appName, $moduleName, 'config'); - if($config->framework->extensionLevel >= 1) - { - if(!empty($extConfigPath['common'])) $commonExtConfigFiles = helper::ls($extConfigPath['common'], '.php'); - if(!empty($extConfigPath['xuan'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['xuan'], '.php')); - if(!empty($extConfigPath['vision'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['vision'], '.php')); - if(!empty($extConfigPath['saas'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['saas'], '.php')); - if(!empty($extConfigPath['custom'])) $commonExtConfigFiles = array_merge($commonExtConfigFiles, helper::ls($extConfigPath['custom'], '.php')); - } - if($config->framework->extensionLevel == 2 and !empty($extConfigPath['site'])) $siteExtConfigFiles = helper::ls($extConfigPath['site'], '.php'); - $extConfigFiles = array_merge($commonExtConfigFiles, $siteExtConfigFiles); - /* 将主配置文件和扩展配置文件合并在一起。Put the main config file and extension config files together. */ - $configFiles = array_merge(array($mainConfigFile), $extConfigFiles); + $configFiles = $this->getMainAndExtFiles($moduleName, $appName, 'config'); + if(empty($configFiles)) return false; /* 加载每一个配置文件。Load every config file. */ static $loadedConfigs = array(); @@ -2670,36 +2650,8 @@ class baseRouter */ public function loadLang($moduleName, $appName = '') { - /* 初始化变量。Init vars. */ - $modulePath = $this->getModulePath($appName, $moduleName); - $extLangFiles = array(); - $langFilesToLoad = array(); - - /* 判断主语言文件是否存在。Whether the main lang file exists or not. */ - $mainLangFile = $this->getMainLangFile($moduleName, $appName); - if($mainLangFile) $langFilesToLoad[] = $mainLangFile; - - /* 获取扩展语言文件。If extensionLevel > 0, get extension lang files. */ - if($this->config->framework->extensionLevel > 0) - { - $commonExtLangFiles = array(); - $siteExtLangFiles = array(); - - $extLangPath = $this->getModuleExtPath($appName, $moduleName, 'lang'); - if($this->config->framework->extensionLevel >= 1) - { - if(!empty($extLangPath['common'])) $commonExtLangFiles = helper::ls($extLangPath['common'] . $this->clientLang, '.php'); - if(!empty($extLangPath['xuan'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['xuan'] . $this->clientLang, '.php')); - if(!empty($extLangPath['vision'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['vision'] . $this->clientLang, '.php')); - if(!empty($extLangPath['custom'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['custom'] . $this->clientLang, '.php')); - if(!empty($extLangPath['saas'])) $commonExtLangFiles = array_merge($commonExtLangFiles, helper::ls($extLangPath['saas'] . $this->clientLang, '.php')); - } - if($this->config->framework->extensionLevel == 2 and !empty($extLangPath['site'])) $siteExtLangFiles = helper::ls($extLangPath['site'] . $this->clientLang, '.php'); - $extLangFiles = array_merge($commonExtLangFiles, $siteExtLangFiles); - } - /* 计算最终要加载的语言文件。 Get the lang files to be loaded. */ - $langFilesToLoad = array_merge($langFilesToLoad, $extLangFiles); + $langFilesToLoad = $this->getMainAndExtFiles($moduleName, $appName, 'lang'); if(empty($langFilesToLoad)) return false; /* 加载语言文件。Load lang files. */ @@ -2972,6 +2924,59 @@ class baseRouter { return strtolower(getenv('IS_CONTAINER')) == 'true'; } + + /** + * Get main file and ext files. + * + * @param string $moduleName + * @param string $appName + * @param string $type lang|config|control|model + * @access public + * @return array + */ + public function getMainAndExtFiles($moduleName, $appName = '', $type = 'lang') + { + /* 初始化变量。Init vars. */ + $modulePath = $this->getModulePath($appName, $moduleName); + $extFiles = array(); + $filesToLoad = array(); + + /* 判断主文件是否存在。Whether the main file exists or not. */ + if($type == 'lang') + { + $mainFile = $this->getMainLangFile($moduleName, $appName); + } + else + { + $mainFile = $modulePath . $type . '.php'; + } + if($mainFile) $filesToLoad[] = $mainFile; + + /* 获取扩展文件。If extensionLevel > 0, get extension files. */ + if($this->config->framework->extensionLevel > 0) + { + $commonExtFiles = array(); + $siteExtFiles = array(); + + $extPath = $this->getModuleExtPath($appName, $moduleName, $type); + if($this->config->framework->extensionLevel >= 1) + { + $client = $type == 'lang' and isset($this->client) ? $this->client : ''; + if(!empty($extPath['common'])) $commonExtFiles = helper::ls($extPath['common'] . $client, '.php'); + if(!empty($extPath['xuan'])) $commonExtFiles = array_merge($commonExtFiles, helper::ls($extPath['xuan'] . $client, '.php')); + if(!empty($extPath['vision'])) $commonExtFiles = array_merge($commonExtFiles, helper::ls($extPath['vision'] . $client, '.php')); + if(!empty($extPath['custom'])) $commonExtFiles = array_merge($commonExtFiles, helper::ls($extPath['custom'] . $client, '.php')); + if(!empty($extPath['saas'])) $commonExtFiles = array_merge($commonExtFiles, helper::ls($extPath['saas'] . $client, '.php')); + } + if($this->config->framework->extensionLevel == 2 and !empty($extPath['site'])) $siteExtFiles = helper::ls($extPath['site'] . $client, '.php'); + $extFiles = array_merge($commonExtFiles, $siteExtFiles); + } + + /* 计算最终要加载的文件。 Get the files to be loaded. */ + $filesToLoad = array_merge($filesToLoad, $extFiles); + if(empty($filesToLoad)) return false; + return $filesToLoad; + } } /** 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/common/model.php b/module/common/model.php index 9371f28f82..59417cbdf0 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -3556,8 +3556,8 @@ EOD; { if(strpos($moduleName, 'Menu') === false) continue; - $isSecondMenu = strpos($moduleName, 'subMenu') === false; - $moduleName = str_replace($isSecondMenu ? 'Menu' : 'subMenu', '', $moduleName); + $isSecondMenu = strpos($moduleName, 'SubMenu') === false; + $moduleName = str_replace($isSecondMenu ? 'Menu' : 'SubMenu', '', $moduleName); foreach($sectionMenus as $section => $menus) { @@ -3566,7 +3566,7 @@ EOD; /* Get second menu. */ if($isSecondMenu) { - $isDropMenu = strpos($section, 'dropMenu') !== false; + $isDropMenu = strpos($section, 'DropMenu') !== false; if(!$isDropMenu) { if(!isset($lang->{$moduleName}->{$section})) break; @@ -3576,7 +3576,7 @@ EOD; else { /* Get drop menu in second menu. */ - $dropMenuKey = str_replace('dropMenu', '', $section); + $dropMenuKey = str_replace('DropMenu', '', $section); if(!isset($lang->{$moduleName}->menu->{$dropMenuKey}['dropMenu']->{$key})) break; $settingMenu = &$lang->{$moduleName}->menu->{$dropMenuKey}['dropMenu']->{$key}; } 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 122251f66e..960de30b3e 100644 --- a/module/dev/control.php +++ b/module/dev/control.php @@ -89,10 +89,41 @@ class dev extends control * @access public * @return void */ - public function langItem($type = 'common') + public function langItem($type = 'common', $module = '', $method = '', $language = 'zh_cn') { - $this->view->title = $this->lang->langItem; - $this->view->type = $type; + $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 2380ab8e5a..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. * @@ -295,4 +327,37 @@ class devModel extends model { return ltrim(rtrim($line), "* \t\n\r\0\x0B"); } + + /** + * Load default lang. + * + * @access public + * @return object + */ + 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(); + $lang->URCommon = $this->lang->URCommon; + $lang->SRCommon = $this->lang->SRCommon; + $lang->productCommon = $this->lang->productCommon; + $lang->projectCommon = $this->lang->projectCommon; + $lang->executionCommon = $this->lang->executionCommon; + if(!isset($lang->common)) $lang->common = new stdclass(); + + $loadedLangs = array(); + foreach($langFilesToLoad as $langFile) + { + if(in_array($langFile, $loadedLangs)) continue; + include $langFile; + $loadedLangs[] = $langFile; + } + + return $lang; + } } 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 @@ + + diff --git a/module/dev/view/langitem.html.php b/module/dev/view/langitem.html.php index 1e640740b9..ea0eff2b3b 100644 --- a/module/dev/view/langitem.html.php +++ b/module/dev/view/langitem.html.php @@ -1,48 +1,51 @@ - * * @package dev - * * @version $Id$ - * * @link http://www.zentao.net - * */ + * The editor view file of dev module of ZenTaoPMS. + * + * @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com) + * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) + * @author Yidong Wang + * @package dev + * @version $Id$ + * @link http://www.zentao.net + */ ?> -
-
-
默认值
-
-
项目集
-
产品
+
+
+
+
默认值
+
+ $originalLang):?> +
" class="input-label h-32 my-12">
+ +
-
-
-
修改值
-
-
- - -
-
- - -
+
+
修改值
+
+ $originalLang):?> +
+ + + " class="icon icon-angle-right text-primary hidden"> +
+ +
+
-
-
-
+
-