* adjust for load lang from db.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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?';
|
||||
|
||||
@@ -14,4 +14,7 @@ $lang->custom->testtask = '测试任务';
|
||||
$lang->custom->todo = '待办';
|
||||
$lang->custom->user = '用户';
|
||||
|
||||
$lang->custom->currentLang = '适用当前语言';
|
||||
$lang->custom->allLang = '适用所有语言';
|
||||
|
||||
$lang->custom->confirmRestore = '是否要恢复默认语言配置?';
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ EOT;
|
||||
<td class='divider'></td>
|
||||
<td>
|
||||
<form method='post'>
|
||||
<table align='center' class='table-1'>
|
||||
<table class='table-1'>
|
||||
<caption><?echo $lang->custom->$module . ' >> ' . $config->custom->$module->fields[$field]?></caption>
|
||||
<tr>
|
||||
<th class='w-100px'><?php echo $lang->custom->key;?></th>
|
||||
@@ -85,7 +85,18 @@ EOT;
|
||||
<?php endif;?>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tfoot><tr><td colspan='<?php $canAdd ? print(3) : print(2);?>' class='a-center'><?php echo html::submitButton() . html::linkButton($lang->custom->restore, inlink('restore', "module=$module&field=$field"), 'hiddenwin')?></td></tr><tfoot>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan='<?php $canAdd ? print(3) : print(2);?>' class='a-center'>
|
||||
<?php
|
||||
$appliedTo = array($currentLang => $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');
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user