diff --git a/module/custom/control.php b/module/custom/control.php index ebc111a224..b35cb9d979 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -27,10 +27,11 @@ class custom extends control * * @param string $module * @param string $field + * @param string $lang * @access public * @return void */ - public function set($module = 'story', $field = 'priList') + public function set($module = 'story', $field = 'priList', $lang = 'zh_cn') { if($module == 'user' and $field == 'priList') $field = 'roleList'; $currentLang = $this->app->getClientLang(); @@ -69,7 +70,23 @@ class custom extends control } } if(dao::isError()) die(js::error(dao::getError())); - die(js::reload('parent')); + die(js::locate($this->createLink('custom', 'set', "module=$module&field=$field&lang=" . str_replace('-', '_', $lang)), 'parent')); + } + + $lang = str_replace('_', '-', $lang); + $dbFields = $this->custom->getItems("lang=$lang&module=$module§ion=$field"); + if(empty($dbFields)) $dbFields = $this->custom->getItems("lang=" . ($lang == $currentLang ? 'all' : $currentLang) . "&module=$module§ion=$field"); + if($dbFields) + { + $dbField = reset($dbFields); + if($lang != $dbField->lang) + { + $lang = str_replace('-', "_", $dbField->lang); + foreach($fieldList as $key => $value) + { + if(isset($dbFields[$key]) and $value != $dbFields[$key]->value) $fieldList[$key] = $dbFields[$key]->value; + } + } } $this->view->title = $this->lang->custom->common . $this->lang->colon . $this->lang->$module->common; @@ -77,8 +94,9 @@ class custom extends control $this->view->position[] = $this->lang->$module->common; $this->view->needReview = $this->config->story->needReview; $this->view->fieldList = $fieldList; - $this->view->dbFields = $this->custom->getItems("lang=$currentLang,all&module=$module§ion=$field"); + $this->view->dbFields = $dbFields; $this->view->field = $field; + $this->view->setLang = str_replace('_', '-', $lang); $this->view->module = $module; $this->view->currentLang = $currentLang; $this->view->canAdd = strpos($this->config->custom->canAdd[$module], $field) !== false; diff --git a/module/custom/view/set.html.php b/module/custom/view/set.html.php index bbe15596c5..a6511bbf1b 100644 --- a/module/custom/view/set.html.php +++ b/module/custom/view/set.html.php @@ -83,7 +83,7 @@ EOT; system : 1;?> - + value : $value, "class='form-control'");?> @@ -97,7 +97,7 @@ EOT; $lang->custom->currentLang, 'all' => $lang->custom->allLang); - echo html::radio('lang', $appliedTo, 'all'); + echo html::radio('lang', $appliedTo, $setLang); echo html::submitButton(); if(common::hasPriv('custom', 'restore')) echo html::linkButton($lang->custom->restore, inlink('restore', "module=$module&field=$field"), 'hiddenwin'); ?>