From 145c55b4473af26bceb7e5bc362492cfb6ed4252 Mon Sep 17 00:00:00 2001 From: azhi Date: Wed, 7 Aug 2013 10:40:10 +0800 Subject: [PATCH] * finish task#1670. * finish task#1671. * finish task#1672. * finish task#1674. * finish task#1675. * finish task#1676. * finish task#1668. --- framework/router.class.php | 1 + module/common/lang/zh-cn.php | 2 +- module/custom/config.php | 48 +++++++++++--- module/custom/control.php | 58 +++++++++++++++-- module/custom/css/common.css | 1 + module/custom/lang/en.php | 4 ++ module/custom/lang/zh-cn.php | 4 ++ module/custom/model.php | 36 +++++------ module/custom/view/index.html.php | 65 ------------------- module/custom/view/setcustom.html.php | 91 +++++++++++++++++++++++++++ 10 files changed, 214 insertions(+), 96 deletions(-) create mode 100644 module/custom/css/common.css delete mode 100644 module/custom/view/index.html.php create mode 100644 module/custom/view/setcustom.html.php diff --git a/framework/router.class.php b/framework/router.class.php index 80a8e98a1f..249c752779 100755 --- a/framework/router.class.php +++ b/framework/router.class.php @@ -1472,6 +1472,7 @@ class router if($moduleName == $record->module) { if(!$record->key) continue; + unset($lang->{$record->module}->{$record->section}[$record->key]); $lang->{$record->module}->{$record->section}[$record->key] = $record->value; } } diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 1ce3e653e5..d16d99fb9a 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -283,7 +283,7 @@ $lang->convert = new stdclass(); $lang->upgrade = new stdclass(); $lang->action = new stdclass(); $lang->extension = new stdclass(); -$lang->customlang = new stdclass(); +$lang->custom = new stdclass(); $lang->editor = new stdclass(); $lang->mail = new stdclass(); $lang->sso = new stdclass(); diff --git a/module/custom/config.php b/module/custom/config.php index 39a2bfdcd3..4007559eff 100644 --- a/module/custom/config.php +++ b/module/custom/config.php @@ -6,13 +6,47 @@ $config->custom->story->fields['priList'] = '优先级'; $config->custom->story->fields['sourceList'] = '来源'; $config->custom->story->fields['reasonList'] = '关闭原因'; $config->custom->story->fields['reviewResultList'] = '评审结果'; -$config->custom->story->fields['statusList'] = '状态'; $config->custom->story->fields['stageList'] = '阶段'; +$config->custom->story->fields['statusList'] = '状态'; $config->custom->story->canAdd = 'reasonList,reviewResultList,sourceList,priList'; -$config->custom->task = ''; -$config->custom->bug = ''; -$config->custom->testcase = ''; -$config->custom->testtask = ''; -$config->custom->todo = ''; -$config->custom->user = ''; +$config->custom->task = new stdClass(); +$config->custom->task->fields['priList'] = '优先级'; +$config->custom->task->fields['typeList'] = '类型'; +$config->custom->task->fields['reasonList'] = '关闭原因'; +$config->custom->task->fields['statusList'] = '状态'; +$config->custom->task->canAdd = 'priList,typeList'; + +$config->custom->bug = new stdClass(); +$config->custom->bug->fields['priList'] = '优先级'; +$config->custom->bug->fields['severityList'] = '严重程度'; +$config->custom->bug->fields['osList'] = '操作系统'; +$config->custom->bug->fields['browserList'] = '浏览器'; +$config->custom->bug->fields['typeList'] = '类型'; +$config->custom->bug->fields['resolutionList'] = '解决方案'; +$config->custom->bug->fields['statusList'] = '状态'; +$config->custom->bug->canAdd = 'priList,severityList,osList,browserList,typeList,resolutionList'; + +$config->custom->testcase = new stdClass(); +$config->custom->testcase->fields['priList'] = '优先级'; +$config->custom->testcase->fields['typeList'] = '类型'; +$config->custom->testcase->fields['stageList'] = '阶段'; +$config->custom->testcase->fields['resultList'] = '执行结果'; +$config->custom->testcase->fields['statusList'] = '状态'; +$config->custom->testcase->canAdd = 'priList,typeList,stageList'; + +$config->custom->testtask = new stdClass(); +$config->custom->testtask->fields['priList'] = '优先级'; +$config->custom->testtask->fields['statusList'] = '状态'; +$config->custom->testtask->canAdd = 'priList'; + +$config->custom->todo = new stdClass(); +$config->custom->todo->fields['priList'] = '优先级'; +$config->custom->todo->fields['typeList'] = '类型'; +$config->custom->todo->fields['statusList'] = '状态'; +$config->custom->todo->canAdd = 'priList,typeList'; + +$config->custom->user = new stdClass(); +$config->custom->user->fields['roleList'] = '角色'; +$config->custom->user->fields['statusList'] = '状态'; +$config->custom->user->canAdd = 'roleList'; diff --git a/module/custom/control.php b/module/custom/control.php index 9d727c8601..cd39d0a342 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -11,38 +11,86 @@ */ class custom extends control { + /** + * __construct + * + * @access public + * @return void + */ public function __construct() { parent::__construct(); } - public function index($module = 'story', $field = 'priList') + /** + * Index + * + * @access public + * @return void + */ + public function index() { + die(js::locate(inlink('setCustom'))); + } + + /** + * Custom + * + * @param string $module + * @param string $field + * @access public + * @return void + */ + public function setCustom($module = 'story', $field = 'priList') + { + if($module == 'user' and $field == 'priList') $field = 'roleList'; $lang = $this->app->getClientLang(); $this->app->loadLang($module); $fieldList = $this->lang->$module->$field; if(!empty($_POST)) { + $this->custom->deleteItems("{$lang}.{$module}.{$field}"); foreach($_POST['keys'] as $index => $key) { -// $value = $_POST['values'][$index]; - // if(isset($fieldList[$key]) and $fieldList[$key] == $value) continue; - $this->custom->setItem("{$lang}.{$module}.{$field}.{$key}", $value); + $value = $_POST['values'][$index]; + $system = $_POST['systems'][$index]; + $this->custom->setItem("{$lang}.{$module}.{$field}.{$key}.{$system}", $value); } if(!dao::getError()) die(js::reload('parent')); } - $this->view->standardList = $this->custom->getStandardList($module, $field); $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->display(); } + + /** + * Restore the default lang. Delete the related items. + * + * @param string $module + * @param string $field + * @param string $confirm + * @access public + * @return void + */ + public function restore($module, $field, $confirm = 'no') + { + if($confirm == 'no') + { + 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}"); + die(js::reload('parent')); + } } diff --git a/module/custom/css/common.css b/module/custom/css/common.css new file mode 100644 index 0000000000..c438eadb9c --- /dev/null +++ b/module/custom/css/common.css @@ -0,0 +1 @@ +input[type='text'] {border:1px solid #ccc; padding:3px 0px} diff --git a/module/custom/lang/en.php b/module/custom/lang/en.php index 90970f42d9..a577464f86 100644 --- a/module/custom/lang/en.php +++ b/module/custom/lang/en.php @@ -1,5 +1,6 @@ custom->common = 'Custom'; +$lang->custom->custom = 'Custom'; $lang->custom->key = 'Key'; $lang->custom->value = 'Value'; @@ -10,3 +11,6 @@ $lang->custom->testcase = 'Test case'; $lang->custom->testtask = 'Test task'; $lang->custom->todo = 'Todo'; $lang->custom->user = 'User'; + +$lang->custom->restore = 'restore'; +$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 62954b6207..9667bf7ba6 100644 --- a/module/custom/lang/zh-cn.php +++ b/module/custom/lang/zh-cn.php @@ -1,5 +1,6 @@ custom->common = '自定义配置'; +$lang->custom->custom = '自定义配置'; $lang->custom->key = '键'; $lang->custom->value = '值'; @@ -10,3 +11,6 @@ $lang->custom->testcase = '测试用例'; $lang->custom->testtask = '测试任务'; $lang->custom->todo = '待办'; $lang->custom->user = '用户'; + +$lang->custom->restore = '恢复默认'; +$lang->custom->confirmRestore = '是否要恢复默认语言配置?'; diff --git a/module/custom/model.php b/module/custom/model.php index be1f04096a..c20952f2d1 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -1,20 +1,19 @@ - * @package xxx + * @author Congzhi Chen + * @package custom * @version $Id$ * @link http://www.zentao.net */ class customModel extends model { /** - * Get config of system and one user. + * Get all custom lang. * - * @param string $account * @access public * @return array */ @@ -26,7 +25,7 @@ class customModel extends model /** * Set value of an item. * - * @param string $path system.common.global.sn or system.common.sn + * @param string $path zh-cn.story.soucreList.customer.1 * @param string $value * @access public * @return void @@ -34,11 +33,13 @@ class customModel extends model public function setItem($path, $value = '') { $level = substr_count($path, '.'); - $section = ''; + $section = ''; + $system = 1; if($level <= 1) return false; if($level == 2) list($lang, $module, $key) = explode('.', $path); if($level == 3) list($lang, $module, $section, $key) = explode('.', $path); + if($level == 4) list($lang, $module, $section, $key, $system) = explode('.', $path); $item = new stdclass(); $item->lang = $lang; @@ -46,21 +47,21 @@ class customModel extends model $item->section = $section; $item->key = $key; $item->value = $value; + $item->system = $system; $this->dao->replace(TABLE_CUSTOM)->data($item)->exec(); } - public function getStandardList($module, $field) - { - $this->loadModel($module); - $lang = $this->app->getClientLang(); - $currentList = $this->lang->$module->$field; - $dbList = $this->getItems("{$lang}.{$module}.{$field}"); - } - + /** + * Get some items + * + * @param string $paramString see parseItemParam(); + * @access public + * @return void + */ public function getItems($paramString) { - return $this->createDAO($this->parseItemParam($paramString), 'select')->fetchAll('id'); + return $this->createDAO($this->parseItemParam($paramString), 'select')->fetchAll('key'); } /** @@ -78,7 +79,7 @@ class customModel extends model /** * Parse the param string for select or delete items. * - * @param string $paramString owner=xxx&key=sn and so on. + * @param string $paramString lang=xxx&module=story§ion=sourceList&key=customer and so on. * @access public * @return array */ @@ -111,6 +112,5 @@ class customModel extends model ->beginIF($params['section'])->andWhere('section')->in($params['section'])->fi() ->beginIF($params['key'])->andWhere('`key`')->in($params['key'])->fi(); } - } diff --git a/module/custom/view/index.html.php b/module/custom/view/index.html.php deleted file mode 100644 index c79b466f23..0000000000 --- a/module/custom/view/index.html.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @package xxx - * @version $Id$ - * @link http://www.zentao.net - */ -?> - - - - - - - - - -EOT; -?> - -
-
- config->custom->story->fields as $key => $value) - { - echo "" . html::a(inlink('index', "module=$module&field=$key"), $value) . ""; - } - ?> -
-
-
- - - - - - $value):?> - - - - - - -
custom->key;?>custom->value;?>
- - -
-
- - diff --git a/module/custom/view/setcustom.html.php b/module/custom/view/setcustom.html.php new file mode 100644 index 0000000000..074586eda5 --- /dev/null +++ b/module/custom/view/setcustom.html.php @@ -0,0 +1,91 @@ + + * @package custom + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
+
+ "; 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 ""; + ?> +
+
+ + + + + + + + + + + + + +EOT; +?> + +
+
+ custom->{$module}->fields as $key => $value) + { + echo "" . html::a(inlink('setCustom', "module=$module&field=$key"), $value) . ""; + } + ?> +
+
+
+ + + + + + + $value):?> + + system : 1;?> + + + + + + + + +
custom->key;?>custom->value;?>
+ + + + +
custom->restore, inlink('restore', "modult=$modult&field=$field"), 'hiddenwin')?>
+
+ +