diff --git a/framework/router.class.php b/framework/router.class.php index 249c752779..e2fde411c1 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -1465,15 +1465,14 @@ class router } /* Merge from the db lang. */ - if($moduleName != 'common' and isset($lang->db->custom)) + if($moduleName != 'common' and isset($lang->db->custom[$moduleName])) { - foreach($lang->db->custom as $record) + foreach($lang->db->custom[$moduleName] as $section => $fields) { - if($moduleName == $record->module) + foreach($fields as $key => $value) { - if(!$record->key) continue; - unset($lang->{$record->module}->{$record->section}[$record->key]); - $lang->{$record->module}->{$record->section}[$record->key] = $record->value; + unset($lang->{$moduleName}->{$section}[$key]); + $lang->{$moduleName}->{$section}[$key] = $value; } } } diff --git a/module/custom/control.php b/module/custom/control.php index cd39d0a342..b761a95d27 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -11,17 +11,6 @@ */ class custom extends control { - /** - * __construct - * - * @access public - * @return void - */ - public function __construct() - { - parent::__construct(); - } - /** * Index * @@ -44,13 +33,14 @@ class custom extends control public function setCustom($module = 'story', $field = 'priList') { if($module == 'user' and $field == 'priList') $field = 'roleList'; - $lang = $this->app->getClientLang(); + $currentLang = $this->app->getClientLang(); $this->app->loadLang($module); $fieldList = $this->lang->$module->$field; if(!empty($_POST)) { - $this->custom->deleteItems("{$lang}.{$module}.{$field}"); + $lang = $_POST['lang']; + $this->custom->deleteItems("lang=$lang&module=$module§ion=$field"); foreach($_POST['keys'] as $index => $key) { $value = $_POST['values'][$index]; @@ -60,14 +50,15 @@ class custom extends control if(!dao::getError()) die(js::reload('parent')); } - $this->view->title = $this->lang->custom->common . $this->lang->colon . $this->lang->custom->story; - $this->view->position[] = $this->lang->custom->common; - $this->view->position[] = $this->lang->custom->$module; - $this->view->fieldList = $fieldList; - $this->view->dbFields = $this->custom->getItems("{$lang}.{$module}.{$field}"); - $this->view->field = $field; - $this->view->module = $module; - $this->view->canAdd = strpos($this->config->custom->$module->canAdd, $field) !== false; + $this->view->title = $this->lang->custom->common . $this->lang->colon . $this->lang->custom->story; + $this->view->position[] = $this->lang->custom->common; + $this->view->position[] = $this->lang->custom->$module; + $this->view->fieldList = $fieldList; + $this->view->dbFields = $this->custom->getItems("module=$module§ion=$field"); + $this->view->field = $field; + $this->view->module = $module; + $this->view->currentLang = $currentLang; + $this->view->canAdd = strpos($this->config->custom->$module->canAdd, $field) !== false; $this->display(); } @@ -88,8 +79,7 @@ class custom extends control die(js::confirm($this->lang->custom->confirmRestore, inlink('restore', "module=$module&field=$field&confirm=yes"))); } - $lang = $this->app->getClientLang(); - $this->custom->deleteItems("{$lang}.{$module}.{$field}"); + $this->custom->deleteItems("module=$module§ion=$field"); die(js::reload('parent')); } } diff --git a/module/custom/lang/en.php b/module/custom/lang/en.php index 080b658e2f..589a104d5c 100644 --- a/module/custom/lang/en.php +++ b/module/custom/lang/en.php @@ -14,4 +14,7 @@ $lang->custom->testtask = 'Test task'; $lang->custom->todo = 'Todo'; $lang->custom->user = 'User'; +$lang->custom->currentLang = 'For current language'; +$lang->custom->allLang = 'For all language'; + $lang->custom->confirmRestore = 'Are you sure to restore the default lang setting?'; diff --git a/module/custom/lang/zh-cn.php b/module/custom/lang/zh-cn.php index bc56aa91ea..039722fd9e 100644 --- a/module/custom/lang/zh-cn.php +++ b/module/custom/lang/zh-cn.php @@ -14,4 +14,7 @@ $lang->custom->testtask = '测试任务'; $lang->custom->todo = '待办'; $lang->custom->user = '用户'; +$lang->custom->currentLang = '适用当前语言'; +$lang->custom->allLang = '适用所有语言'; + $lang->custom->confirmRestore = '是否要恢复默认语言配置?'; diff --git a/module/custom/model.php b/module/custom/model.php index c20952f2d1..71914c1025 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -19,7 +19,17 @@ class customModel extends model */ public function getAll() { - return $this->dao->select('*')->from(TABLE_CUSTOM)->orderBy('id')->fetchAll('id'); + $allCustomLang = $this->dao->select('*')->from(TABLE_CUSTOM)->orderBy('lang,id')->fetchAll('id'); + + $currentLang = $this->app->getClientLang(); + $processedLang = array(); + foreach($allCustomLang as $id => $customLang) + { + if($customLang->lang != $currentLang and $customLang->lang != 'all') continue; + $processedLang[$customLang->module][$customLang->section][$customLang->key] = $customLang->value; + } + + return $processedLang; } /** @@ -61,7 +71,7 @@ class customModel extends model */ public function getItems($paramString) { - return $this->createDAO($this->parseItemParam($paramString), 'select')->fetchAll('key'); + return $this->createDAO($this->parseItemParam($paramString), 'select')->orderBy('lang,id')->fetchAll('key'); } /** @@ -113,4 +123,3 @@ class customModel extends model ->beginIF($params['key'])->andWhere('`key`')->in($params['key'])->fi(); } } - diff --git a/module/custom/view/setcustom.html.php b/module/custom/view/setcustom.html.php index 896ee7e1ed..13dad68c49 100644 --- a/module/custom/view/setcustom.html.php +++ b/module/custom/view/setcustom.html.php @@ -63,7 +63,7 @@ EOT;
- +
@@ -85,7 +85,18 @@ EOT; - + + + + +
custom->$module . ' >> ' . $config->custom->$module->fields[$field]?>
custom->key;?>
custom->restore, inlink('restore', "module=$module&field=$field"), 'hiddenwin')?>
+ $lang->custom->currentLang, 'all' => $lang->custom->allLang); + echo html::radio('lang', $appliedTo, 'all'); + echo html::submitButton(); + if(common::hasPriv('custom', 'restore')) echo html::linkButton($lang->custom->restore, inlink('restore', "module=$module&field=$field"), 'hiddenwin'); + ?> +