From ea739d600b07704d3e48cfea87fc36fdb1bf6acd Mon Sep 17 00:00:00 2001 From: azhi Date: Wed, 7 Aug 2013 15:48:55 +0800 Subject: [PATCH 01/18] * adjust for load lang from db. --- framework/router.class.php | 11 ++++---- module/custom/control.php | 36 ++++++++++----------------- module/custom/lang/en.php | 3 +++ module/custom/lang/zh-cn.php | 3 +++ module/custom/model.php | 15 ++++++++--- module/custom/view/setcustom.html.php | 15 +++++++++-- 6 files changed, 49 insertions(+), 34 deletions(-) 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'); + ?> +
From 1f3cde2847149f66c240cc932450906dabb666f3 Mon Sep 17 00:00:00 2001 From: azhi Date: Wed, 7 Aug 2013 16:37:28 +0800 Subject: [PATCH 02/18] * code for custom set. --- module/custom/control.php | 8 +++++--- module/custom/js/{setcustom.js => set.js} | 0 module/custom/lang/en.php | 2 +- module/custom/lang/zh-cn.php | 2 +- .../view/{setcustom.html.php => set.html.php} | 18 +++++++++--------- module/group/lang/resource.php | 8 ++++---- 6 files changed, 20 insertions(+), 18 deletions(-) rename module/custom/js/{setcustom.js => set.js} (100%) rename module/custom/view/{setcustom.html.php => set.html.php} (86%) diff --git a/module/custom/control.php b/module/custom/control.php index b761a95d27..fbb0ba8355 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -19,7 +19,7 @@ class custom extends control */ public function index() { - die(js::locate(inlink('setCustom'))); + die(js::locate(inlink('set'))); } /** @@ -30,7 +30,7 @@ class custom extends control * @access public * @return void */ - public function setCustom($module = 'story', $field = 'priList') + public function set($module = 'story', $field = 'priList') { if($module == 'user' and $field == 'priList') $field = 'roleList'; $currentLang = $this->app->getClientLang(); @@ -44,10 +44,12 @@ class custom extends control foreach($_POST['keys'] as $index => $key) { $value = $_POST['values'][$index]; + if(!$value or !$key) continue; $system = $_POST['systems'][$index]; $this->custom->setItem("{$lang}.{$module}.{$field}.{$key}.{$system}", $value); } - if(!dao::getError()) die(js::reload('parent')); + if(dao::isError()) die(js::error(dao::getError())); + die(js::reload('parent')); } $this->view->title = $this->lang->custom->common . $this->lang->colon . $this->lang->custom->story; diff --git a/module/custom/js/setcustom.js b/module/custom/js/set.js similarity index 100% rename from module/custom/js/setcustom.js rename to module/custom/js/set.js diff --git a/module/custom/lang/en.php b/module/custom/lang/en.php index 589a104d5c..7986930cf0 100644 --- a/module/custom/lang/en.php +++ b/module/custom/lang/en.php @@ -1,7 +1,7 @@ custom->common = 'Custom'; $lang->custom->index = 'Index'; -$lang->custom->setCustom = 'Set custom'; +$lang->custom->set = 'Set custom'; $lang->custom->restore = 'restore'; $lang->custom->key = 'Key'; $lang->custom->value = 'Value'; diff --git a/module/custom/lang/zh-cn.php b/module/custom/lang/zh-cn.php index 039722fd9e..ddaa4a83b7 100644 --- a/module/custom/lang/zh-cn.php +++ b/module/custom/lang/zh-cn.php @@ -1,7 +1,7 @@ custom->common = '自定义'; $lang->custom->index = '首页'; -$lang->custom->setCustom = '自定义配置'; +$lang->custom->set = '自定义配置'; $lang->custom->restore = '恢复默认'; $lang->custom->key = '键'; $lang->custom->value = '值'; diff --git a/module/custom/view/setcustom.html.php b/module/custom/view/set.html.php similarity index 86% rename from module/custom/view/setcustom.html.php rename to module/custom/view/set.html.php index 13dad68c49..cc1471e65e 100644 --- a/module/custom/view/setcustom.html.php +++ b/module/custom/view/set.html.php @@ -1,6 +1,6 @@
"; common::printLink('custom', 'setCustom', "module=story", $lang->custom->story); echo ''; - echo ""; common::printLink('custom', 'setCustom', "module=task", $lang->custom->task); echo ''; - echo ""; common::printLink('custom', 'setCustom', "module=bug", $lang->custom->bug); echo ''; - echo ""; common::printLink('custom', 'setCustom', "module=testcase", $lang->custom->testcase); echo ''; - echo ""; common::printLink('custom', 'setCustom', "module=testtask", $lang->custom->testtask); echo ''; - echo ""; common::printLink('custom', 'setCustom', "module=todo", $lang->custom->todo); echo '' ; - echo ""; common::printLink('custom', 'setCustom', "module=user", $lang->custom->user); echo ''; + echo ""; common::printLink('custom', 'set', "module=story", $lang->custom->story); echo ''; + echo ""; common::printLink('custom', 'set', "module=task", $lang->custom->task); echo ''; + echo ""; common::printLink('custom', 'set', "module=bug", $lang->custom->bug); echo ''; + echo ""; common::printLink('custom', 'set', "module=testcase", $lang->custom->testcase); echo ''; + echo ""; common::printLink('custom', 'set', "module=testtask", $lang->custom->testtask); echo ''; + echo ""; common::printLink('custom', 'set', "module=todo", $lang->custom->todo); echo '' ; + echo ""; common::printLink('custom', 'set', "module=user", $lang->custom->user); echo ''; ?>
@@ -54,7 +54,7 @@ EOT; custom->{$module}->fields as $key => $value) { - echo "
  • " . html::a(inlink('setCustom', "module=$module&field=$key"), $value) . "
  • "; + echo "
  • " . html::a(inlink('set', "module=$module&field=$key"), $value) . "
  • "; } ?> diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 611087db2a..b9f1514d13 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -491,12 +491,12 @@ $lang->mail->methodOrder[30] = 'reset'; /* custom. */ $lang->resource->custom = new stdclass(); -$lang->resource->custom->index = 'index'; -$lang->resource->custom->setCustom = 'setCustom'; -$lang->resource->custom->restore = 'restore'; +$lang->resource->custom->index = 'index'; +$lang->resource->custom->set = 'set'; +$lang->resource->custom->restore = 'restore'; $lang->custom->methodOrder[5] = 'index'; -$lang->custom->methodOrder[10] = 'setCustom'; +$lang->custom->methodOrder[10] = 'set'; $lang->custom->methodOrder[15] = 'restore'; /* Subversion. */ From ed3371923aab0fdce0d50955d29e5bdfa44a6840 Mon Sep 17 00:00:00 2001 From: wyd621 Date: Wed, 7 Aug 2013 16:44:41 +0800 Subject: [PATCH 03/18] * fix a bug for webapp pager. --- module/webapp/control.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/webapp/control.php b/module/webapp/control.php index 9bca1db02d..d6932ed716 100644 --- a/module/webapp/control.php +++ b/module/webapp/control.php @@ -57,6 +57,7 @@ class webapp extends control if($type == 'bysearch') $param = helper::safe64Encode($this->post->key); /* Get results from the api. */ + $recPerPage = $this->cookie->pagerWebappObtain ? $this->cookie->pagerWebappObtain : $recPerPage; $results = $this->webapp->getAppsByAPI($type, $param, $recTotal, $recPerPage, $pageID); if($results) { From 4e97e8e8cb3738d9d4786b61e363d4032be68831 Mon Sep 17 00:00:00 2001 From: azhi Date: Wed, 7 Aug 2013 16:49:10 +0800 Subject: [PATCH 04/18] * add 'system' column. --- db/update4.3.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/update4.3.sql b/db/update4.3.sql index 5c74da0efd..743ee51395 100644 --- a/db/update4.3.sql +++ b/db/update4.3.sql @@ -5,6 +5,8 @@ CREATE TABLE IF NOT EXISTS `zt_custom` ( `section` varchar(30) NOT NULL, `key` varchar(60) NOT NULL, `value` text NOT NULL, + `system` enum('0','1') NOT NULL default '1', PRIMARY KEY (`id`), UNIQUE KEY `lang` (`lang`,`module`,`section`,`key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; + From 8b5d33ef6174669e629b4163335ee6071aaf6362 Mon Sep 17 00:00:00 2001 From: wyd621 Date: Thu, 8 Aug 2013 08:12:25 +0800 Subject: [PATCH 05/18] * fix a bug for get db lang. --- module/custom/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/custom/control.php b/module/custom/control.php index fbb0ba8355..378c585e1b 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -56,7 +56,7 @@ class custom extends control $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->dbFields = $this->custom->getItems("lang=$currentLang,all&module=$module§ion=$field"); $this->view->field = $field; $this->view->module = $module; $this->view->currentLang = $currentLang; From 2b4218185251a95c9b799e4c8aa9934f637a6fd9 Mon Sep 17 00:00:00 2001 From: wyd621 Date: Thu, 8 Aug 2013 08:51:02 +0800 Subject: [PATCH 06/18] * init object. --- module/common/model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/common/model.php b/module/common/model.php index a7f63644cc..a9bd1fa173 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -129,6 +129,7 @@ class commonModel extends model if(!$this->config->db->name) return; $records = $this->loadModel('custom')->getAll(); if(!$records) return; + $this->lang->db = new stdclass(); $this->lang->db->custom = $records; } From 7983d567db618190006ee7a205db8c36544e7af1 Mon Sep 17 00:00:00 2001 From: azhi Date: Thu, 8 Aug 2013 09:24:56 +0800 Subject: [PATCH 07/18] * code for task#1678. --- www/js/my.full.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/js/my.full.js b/www/js/my.full.js index 19193fc2bb..af06c77518 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -300,12 +300,14 @@ function toggleTreeBox() function() { $('.side').hide() + $('.divider').hide() $('.treeSlider span').css("border-right", "0 none"); $('.treeSlider span').css("border-left", "4px solid #000000"); }, function() { $('.side').show() + $('.divider').show() $('.treeSlider span').css("border-right", "4px solid #000000"); $('.treeSlider span').css("border-left", "0 none"); } From df52457ceff5bedb9a20adb35c3d07c4f5e9697c Mon Sep 17 00:00:00 2001 From: azhi Date: Thu, 8 Aug 2013 09:34:52 +0800 Subject: [PATCH 08/18] * code for task#1678. --- module/common/view/action.html.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/module/common/view/action.html.php b/module/common/view/action.html.php index 36500a98bf..cd2f2c0e57 100755 --- a/module/common/view/action.html.php +++ b/module/common/view/action.html.php @@ -132,14 +132,14 @@ $(function(){ action->printAction($action);?> history)) echo " ";?> - - id)'")?> - comment) or !empty($action->history)):?> comment)) echo "
    ";?> + + id)'")?> + comment) { @@ -148,7 +148,6 @@ $(function(){ echo "
    "; } ?> -